Physics · Article
High-performance computing, visualization, and machine learning
Compare a complete parallel run with a serial baseline, read a position-model graph, and test a fitted predictor at values that were kept out of its training.
Previous article: Molecular, particle, continuum, and agent-based simulation
Back to PhysicsAfter reading, you can
- Identify independent work and dependencies before assigning tasks to workers.
- Calculate complete elapsed time and speedup under an explicit timing model.
- Read quantity-valued curves, training values and unused checks on honest axes.
- Fit a simple supervised predictor and distinguish its training agreement from later discrepancies.
- Keep computing performance, predictive agreement and physical validity as separate questions.
Begin with a computing question
A supplied position model gives 0.20 m at 0 s and 1.40 m at 2 s. A straight line through those two values predicts 2.00 m at 3 s. The supplied model gives 2.30 m there. Fitting two values exactly has left a 0.30 m discrepancy at a third input. How should we compute, display and check results before using them?
Our reference is an exact teaching model, x(t) = 0.20 m + (0.40 m/s)t + (0.10 m/s²)t², on 0 ≤ t ≤ 4 s. Position x is measured along a fixed straight coordinate, positive to the right; elapsed time t starts at the declared origin. The formula supplies values for this example. It is not an instrument record or an established law for a real object.
Computing resources can produce many outputs, visualization can expose their relationships, and machine learning can fit a predictive rule from supplied input–output pairs. These roles meet in this small example. Algebra, functions, graphs, and logarithms provides useful published preparation for substitution and axes. Every fitting and timing calculation needed here is introduced locally; no programming language is required.
Find independent work
High-performance computing combines suitable algorithms and computing resources for demanding calculations. Parallel execution is one approach: different workers perform work during overlapping time intervals. Before dividing a task, identify which inputs each part needs and which results it must wait for.
Suppose we request twelve reference outputs at times tᵢ = (i/3)s, with i = 0, …, 11. The index i labels the request, rather than a new physical quantity. Each direct polynomial evaluation uses its own supplied time and the same fixed coefficients. It does not need another output, so these twelve evaluations can be assigned independently and collected by their original indices.
A different rule can have a dependency. For example, an update Sₙ₊₁ = Sₙ + 0.5 m reads its predecessor’s position; n labels a step. Running adjacent updates without obtaining the needed predecessor is not justified by the independent-output example. Dependencies must be respected, or a different parallel algorithm must be shown to give the intended result. More workers do not erase a required input.
Count complete elapsed time
Use a separate stipulated workload to study timing: twelve indivisible independent tasks each take 1 s on an identical worker. Setup takes 2 s before any task starts. The serial baseline has no extra collection overhead, so its complete time is 2 s + 12 s = 14 s. These invented timings do not estimate the cost of evaluating our small polynomial on actual hardware.
With four workers taking three tasks each, the compute stage lasts 3 s. Suppose collection and communication add 1 s after all tasks finish, with no overlap. The complete parallel time is 2 s + 3 s + 1 s = 6 s. Speedup is the serial time divided by parallel time: 14 s/6 s = 7/3, approximately 2.33. The seconds cancel; speedup has no unit.
Overhead and uneven work change the comparison. If collection takes 4 s, the run takes 9 s. If four workers receive 6, 2, 2 and 2 tasks instead, the slowest needs 6 s, giving 9 s with the original 1 s overhead. In both cases speedup is 14/9. The table’s additional worker counts keep exactly the same task costs, setup and 1 s overhead.
| Run | Longest worker computation | Complete elapsed time | Speedup against 14 s |
|---|---|---|---|
| Serial baseline | 12 s | 14 s | 1 |
| Four workers: three tasks each | 3 s | 6 s | 7/3 |
| Eight workers: four take two tasks, four take one | 2 s | 5 s | 14/5 |
| Twelve workers: one task each | 1 s | 4 s | 7/2 |
Check the calculation being timed
Compare timings for the same required outputs and declared correctness conditions. Here both schedules must return all twelve positions with their time indices and units. Returning fewer outputs, changing the model or omitting required collection would change the task being compared. A shorter compute stage alone does not establish a shorter complete run.
For this finite schedule, twelve or more workers cannot reduce the compute stage below 1 s: at least one indivisible task must run. With the stated 2 s setup and 1 s collection, total time is therefore at least 4 s. This conclusion belongs to these task and overhead assumptions. A different task size, algorithm or hardware needs its own timing evidence.
When implementing a larger calculation, save enough information to reconstruct what was computed: model and domain, input values and units, algorithm and software versions, worker assignment, correctness checks, and the start and end events used for timing. Numerical approximation and arithmetic rounding require checks appropriate to that implementation. A correct small reference case is useful preparation for those checks; it does not establish every later result.
Fit a simple supervised predictor
In supervised learning, input–output pairs are used to fit a predictive rule. Here the input is elapsed time and the target output is position. Choose the affine family x̂(t) = a + bt before inspecting the unused checks. The hat distinguishes the predictor from the supplied reference. The intercept a has units m and the coefficient b has units m/s.
Use only the training pairs (0 s, 0.20 m) and (2 s, 1.40 m). The first gives a = 0.20 m. Subtracting the two equations gives b = (1.40 m − 0.20 m)/(2 s − 0 s) = 0.60 m/s. Thus x̂(t) = 0.20 m + (0.60 m/s)t. Distinct training times uniquely determine this affine fit.
A least-squares fit minimizes the sum of squared prediction discrepancies at the training inputs. Our two discrepancies are zero, so their sum of squares is zero and cannot be made smaller. This learned surrogate is a substitute predictor for the reference output. Exact training agreement does not make it the same function: at 1 s it gives 0.80 m, while the reference gives 0.70 m. No training speed or prediction speed has been measured here.
Use a graph to see the fit
Predict where the fitted line and the reference curve will separate, then inspect the graph. Both share elapsed time in seconds on the horizontal axis and position in metres on the vertical axis. Equal tick intervals represent equal quantity differences. Increasing graph height represents increasing rightward position x. The solid curve is the supplied model; the dashed line is the fitted surrogate. Shape and line style distinguish roles as well as colour.
Open circles mark the two training values. Diamonds mark values at 1 s and 3 s that were reserved before fitting. Dotted vertical segments compare each unused reference value with the surrogate at exactly the same time. They show position discrepancies, not uncertainty intervals. The table gives the same numerical comparisons, including the extra query at 4 s.
The training inputs span 0–2 s. Using the fitted line inside that range is interpolation; using it beyond the range is extrapolation. The 3 s and 4 s queries are outside the training range but inside the separately supplied reference domain 0–4 s. The shaded range boundary helps distinguish those facts. A plotted continuation neither creates training evidence nor extends the physical model’s stated domain.
Where does the fitted line agree?
- Solid curve: supplied position model
- Dashed line: fitted linear surrogate
- Open circles: training values at 0 s and 2 s
- Diamonds: held-out values at 1 s and 3 s
- Dotted segments: signed discrepancy r = x̂ − x
| Elapsed time | Reference position x | Surrogate position x̂ | Signed discrepancy r | Role |
|---|---|---|---|---|
| 0 s | 0.20 m | 0.20 m | 0 m | Training |
| 1 s | 0.70 m | 0.80 m | +0.10 m | Held-out check; inside training range |
| 2 s | 1.40 m | 1.40 m | 0 m | Training |
| 3 s | 2.30 m | 2.00 m | −0.30 m | Held-out check; beyond training range |
| 4 s | 3.40 m | 2.60 m | −0.80 m | Additional query; beyond training range |
Evaluate without reusing the checks
For the two prespecified held-out checks, the signed discrepancies are +0.10 m and −0.30 m. Mean absolute error is the average of their magnitudes: (0.10 m + 0.30 m)/2 = 0.20 m. Their signed mean is instead (+0.10 m − 0.30 m)/2 = −0.10 m. Opposite signs partly cancel in the signed mean, so it answers a different question from typical absolute discrepancy on this list.
A score always needs its evaluation set, units and rule. These two checks are fixed exact values from a teaching reference. Their 0.20 m mean absolute error describes this list; it is not a probability expectation, confidence interval, bound on all times or measured accuracy for a real instrument. One check inside the training range and one outside it also should not be silently described as the same prediction setting.
Keep an untouched evaluation set out of decisions about the predictor. If you use its results to choose a new family or tune parameters, it has become selection or validation data. Reporting the same list again cannot provide a fresh untouched test. A larger physical application needs evaluation inputs and observations appropriate to its intended use, together with an honest account of which information guided training.
Connect performance to a physical question
Ask three separate questions. Did the implementation compute the intended outputs? Did the complete run use fewer seconds or other declared resources? Did a predictor agree adequately at the inputs where it will be used? Here exact output checks, the 14 s versus 6 s timing comparison, and the held-out discrepancies answer different parts of that sequence.
A surrogate can help explore a model, but agreement with that model cannot by itself establish that the model represents a real system. Physical interpretation also needs justified assumptions, parameters, observations and measurement uncertainty. Likewise, a polished graph cannot repair a wrong quantity label or an inappropriate input domain. Return to the original physical question when deciding what an acceptable result would mean.
For this example, report the reference formula and 0–4 s domain, the separate timing assumptions, the two training pairs, the fixed held-out times, the chosen affine family and the score definition. Keep model values, predictions and any later observations identifiable. Reconstructing a calculation, accelerating it and testing its physical usefulness are connected tasks with distinct evidence.
Worked examples
Compare complete runs
Twelve independent tasks take 1 s each. Setup takes 2 s. Compare the 14 s serial baseline with four identical workers taking three tasks each and 1 s of collection after computation. Why is the speedup not four?
- The serial baseline performs twelve tasks in succession: 2 s of setup + 12 s of work = 14 s.
- The four workers compute simultaneously. Each takes 3 s; collection waits for all of them and takes a further 1 s. Total time is 2 s + 3 s + 1 s = 6 s.
- Divide whole-run times: speedup = 14/6 = 7/3, approximately 2.33. Its unit is s/s, which cancels.
- Only the 12 s work stage shrinks to 3 s. Setup remains sequential and the parallel run adds collection. Comparing 12 s with 3 s would describe compute-stage speedup, rather than the complete task specified here.
The complete parallel run takes 6 s and has speedup 7/3. Fixed setup and additional collection prevent a fourfold whole-run speedup under these assumptions.
Fit and check a surrogate
Fit x̂(t) = a + bt only to reference values 0.20 m at 0 s and 1.40 m at 2 s. Then find the signed discrepancy at the held-out time 3 s, where x = 2.30 m.
- At 0 s the bt term is zero, so a = 0.20 m.
- The position difference is 1.20 m over 2 s, giving b = 0.60 m/s. Hence x̂(t) = 0.20 m + (0.60 m/s)t.
- At 3 s, x̂ = 0.20 m + 1.80 m = 2.00 m. With r = x̂ − x, r = 2.00 m − 2.30 m = −0.30 m.
- The negative sign means the surrogate is below the supplied position at this time. The query is beyond the training range 0–2 s but still inside the reference’s 0–4 s domain. The two zero training discrepancies did not predict this nonzero check discrepancy.
a = 0.20 m and b = 0.60 m/s. The 3 s prediction is 2.00 m, with signed discrepancy −0.30 m.
Compare two evaluation scores
At the two fixed held-out times, discrepancies are +0.10 m and −0.30 m. Calculate mean absolute error and mean signed discrepancy. What does each result describe?
- Take magnitudes for mean absolute error: |+0.10 m| = 0.10 m and |−0.30 m| = 0.30 m.
- Average them: (0.10 m + 0.30 m)/2 = 0.20 m. Dividing by a count retains metres.
- For the signed mean, retain the signs: (+0.10 m − 0.30 m)/2 = −0.10 m. The positive discrepancy partly cancels the negative one.
- Both summarize the same two-value list by different rules. Neither value establishes a distribution of prediction errors, an all-input error bound or empirical instrument accuracy. Keep the list and rule with the score.
Mean absolute error is 0.20 m; mean signed discrepancy is −0.10 m. The first summarizes magnitudes on this list, while the second includes cancellation and direction.
Try it yourself
Keep the four balanced workers, 2 s setup and 1 s per task, but increase post-compute collection to 4 s. Find complete time and speedup against the same serial baseline.
Show the answer and reasoning
Complete time is 9 s; speedup is 14/9, approximately 1.56.
Each worker still computes for 3 s. Non-overlapped stages add: 2 s + 3 s + 4 s = 9 s. The fixed whole-run baseline remains 14 s. Faster workers have not been stipulated.
Four identical workers receive 6, 2, 2 and 2 one-second tasks. Setup is 2 s and collection is 1 s after all workers finish. What is the total, and would averaging the four worker times give the compute-stage duration?
Show the answer and reasoning
The total is 9 s. The compute stage lasts 6 s, rather than the workers’ 3 s average.
The assignments still sum to twelve tasks, but collection cannot begin until the six-task worker finishes. The maximum worker duration is therefore 6 s, giving 2 + 6 + 1 = 9 s. The average does not describe this waiting condition.
Starting at S₀ = 0 m, use Sₙ₊₁ = Sₙ + 0.5 m. Can two workers compute the updates for S₁ and S₂ without sharing or otherwise obtaining the required predecessor values, just because the reference polynomial outputs were independent?
Show the answer and reasoning
That independent-output reasoning does not justify the update schedule. S₂ needs the value S₁ = 0.5 m and should equal 1 m.
The recurrence reads the previous state: S₁ = 0.5 m, then S₂ = 0.5 m + 0.5 m = 1 m. Dependencies must be respected. A different parallel algorithm might reconstruct the same answers, but it would need its own stated rule and correctness argument.
At 4 s, calculate the fitted surrogate, supplied reference and signed discrepancy. Is this time outside the training range, outside the reference domain, or both?
Show the answer and reasoning
x̂ = 2.60 m, x = 3.40 m and r = −0.80 m. The time is outside the training range but inside the reference domain.
The line gives 0.20 m + (0.60 m/s)(4 s) = 2.60 m. The reference gives 0.20 m + (0.40 m/s)(4 s) + (0.10 m/s²)(4 s)² = 3.40 m. Their difference is −0.80 m. Training inputs span 0–2 s; the supplied reference includes the endpoint 4 s.
The graph’s 1 s diamond is at 0.70 m and the surrogate is at 0.80 m. Find r and the vertical gap’s magnitude. Does the dotted segment supply a measurement uncertainty interval?
Show the answer and reasoning
r = +0.10 m and the gap magnitude is 0.10 m. The segment is not an uncertainty interval.
Subtract reference from surrogate: 0.80 m − 0.70 m = +0.10 m. The graph compares two exact teaching values at one time. No probability law, instrument uncertainty or coverage statement was assigned to the segment.
After seeing the 3 s held-out discrepancy, you choose a new predictor family using that value. You then report its score on the same 1 s and 3 s list as an untouched test. What needs correcting?
Show the answer and reasoning
The list has influenced model selection and must be identified as validation or selection data. Its repeated score is not a fresh untouched test.
Unused checks were meant to evaluate decisions made without those values. Using one to choose the predictor changes that role. Report the information used, and reserve a genuinely separate evaluation appropriate to the intended application if an untouched test is required. Two fictional reference values still cannot establish empirical physical validity.
What to carry forward
- Parallel tasks need suitable independent work or correct coordination of dependencies.
- Whole-run speedup includes setup, waiting and declared overhead; compare the same required task.
- A graph needs quantity labels, honest scales and visible distinctions among reference, prediction and data roles.
- Exact training agreement can coexist with nonzero held-out discrepancies and poor extrapolation.
- Computational correctness, performance, predictive evaluation and physical validity require distinct evidence.
References
Sources for the concepts and teaching approaches in this article.
- Introduction to Parallel Computing TutorialBlaise Barney and Donald Frederick — Lawrence Livermore National LaboratoryTeaching resource
- Chart details: Axes and gridlinesOffice for National Statistics — Service manualReference guide
- User Guidescikit-learn developers — scikit-learn 1.9.1 documentationReference guideUser Guide1.1. Linear Models12. Common pitfalls and recommended practices