Commit d0dba22
test: fix RNG-stream degeneracy in saveat_regression under threading
Under EnsembleThreads, SciMLBase v3.18 isolates the JumpProblem per task
(deepcopy into task_local_storage — race-free; verified 8 distinct RNG
objects on 8 threads). But the test passes no seed to solve, so every
per-task deepcopy starts from the identical StableRNG(12345) and replays
the SAME stream: the ensemble collapses to ~nthreads distinct
trajectories and the rtol=0.1 mean stops tracking exp(-10t). Deterministic
(not a data race): 202/202 single-threaded, ~6/101 at 8 threads. This is
the documented "uniqueness requires explicit seeding" behavior, not a bug
in SciMLBase.
Fix: give each trajectory an independent seeded StableRNG via the
EnsembleProblem prob_func (keyed on ctx.sim_id), matching the
ensemble_uniqueness.jl idiom. Race-free, reproducible, 202/202
multithreaded on Julia 1.10.11 and 1.11.9.
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent b339e6d commit d0dba22
1 file changed
Lines changed: 22 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
| |||
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
13 | | - | |
14 | 12 | | |
15 | | - | |
16 | 13 | | |
17 | | - | |
18 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
19 | 32 | | |
20 | 33 | | |
21 | 34 | | |
| |||
26 | 39 | | |
27 | 40 | | |
28 | 41 | | |
29 | | - | |
| 42 | + | |
30 | 43 | | |
31 | 44 | | |
32 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
33 | 48 | | |
34 | 49 | | |
35 | 50 | | |
| |||
0 commit comments