Documentation

9.18 Worked determinism and scaling experiment

The reproducibility harness uses Chapter 8's analytic ADVAN2 model with a generated dataset of 400 subjects, eight observations per subject and 16 simulation subproblems.

Invocation pattern

For each thread count \(N\in\{1,2,4\}\):

nlmx sims documents/ch08/analytic.ctl `
  --data documents/ch09/benchmark.csv `
  --subproblems 16 --seed 90901 --threads N `
  --no-plots --no-metrics -o documents/ch09/results/threads-N

The model has fixed-zero OMEGA and sampled EPS, so the experiment exercises labelled subject/simulation residual streams and parallel event execution.

Reproduce safely

python tools/ch09_examples.py `
  --nlmx ../nlmx/target/release/nlmx.exe `
  --output documents/ch09/results-recheck

Use a new output directory. The harness refuses a non-empty destination or changed fixture.

Determinism result

The SHA-256 hashes of analytic_sim.csv were identical across all three thread counts. analytic_subjects.csv hashes were also identical. The logs and settings-used files correctly differed because they record active threads and elapsed time.

Timing result

csvthread_timings.csv retained one end-to-end observation per count: about 0.226, 0.238 and 0.178 seconds for 1, 2 and 4 threads. This yields 1.00×, 0.95× and 1.27× speedup. It proves neither universal scaling nor a stable performance rank; the short job includes setup and CSV/report output.

Reference values

jsonexample_summary.json also freezes the SHA-256 known vector, normal 0.975 quantile, type-7 quartile, Wilson interval and chi-square reference threshold used in this chapter.

Interpretation

This is strong evidence for thread-count identity in one simulation workflow and executable hash. Expand release tests to fitted likelihoods, VPC, power/SSE, posterior resampling, bootstrap and failure/resume paths. Benchmark larger compute-heavy cases separately.

Common mistakes

  • Calling one-shot subsecond timings a formal benchmark.
  • Expecting logs to hash identically.
  • Generalising one simulation fixture to every command.

Checklist

  • Freeze seed, executable and input hashes.
  • Compare stable outputs byte-for-byte.
  • Repeat performance measurements before publishing them.

Further reading

Continue with the planned Chapter 10, reports, figures and outputs, or formalize this matrix in Chapter 42.