Skip to content

fix data race in resetted_jump_problem, decorrelate jump/noise seeds#556

Merged
isaacsas merged 4 commits intoSciML:masterfrom
isaacsas:fix_data_race_condit
Feb 23, 2026
Merged

fix data race in resetted_jump_problem, decorrelate jump/noise seeds#556
isaacsas merged 4 commits intoSciML:masterfrom
isaacsas:fix_data_race_condit

Conversation

@isaacsas
Copy link
Copy Markdown
Member

Remove dead randexp!(_jump_prob.rng, ...) blocks from resetted_jump_problem and reset_jump_problem! that caused a data race when called from multiple threads via EnsembleThreads. The jump_u values they wrote were unconditionally overwritten anyways by VR_FRMEventCallback's initialize method.

Add _derive_jump_seed to decorrelate the jump aggregator's seed from the noise process seed when StochasticDiffEq passes the same seed to both.

Add test/ensemble_problems.jl covering serial stream uniqueness, sequential solve independence, threaded completion (no data race), seed-based stream independence, and VR_FRM jump_u threshold uniqueness.

isaacsas and others added 2 commits February 23, 2026 12:18
Remove dead randexp!(_jump_prob.rng, ...) blocks from resetted_jump_problem
and reset_jump_problem! that caused a data race when called from multiple
threads via EnsembleThreads. The jump_u values they wrote were unconditionally
overwritten by VR_FRMEventCallback's initialize method.

Add _derive_jump_seed to decorrelate the jump aggregator's seed from the
noise process seed when StochasticDiffEq passes the same seed to both.

Add test/ensemble_problems.jl covering serial stream uniqueness, sequential
solve independence, threaded completion (no data race), seed-based stream
independence, and VR_FRM jump_u threshold uniqueness.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Strengthens _derive_jump_seed by hashing the input seed with a fixed
salt before passing through Xoshiro. This ensures decorrelation from
the caller's seed regardless of the JumpProblem's stored RNG type.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Comment thread src/solve.jl
Comment on lines +73 to +74
const _JUMP_SEED_SALT = 0x4a756d7050726f63 # "JumPProc" in ASCII
_derive_jump_seed(seed) = rand(Random.Xoshiro(hash(seed, _JUMP_SEED_SALT)), UInt64)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChrisRackauckas I'm not sure what the best approach to take here is. The problem is we don't want to just use Xoshiro(seed) as that will sample from the same stream that StochasticDiffEq is using (currently, this will all go away when we get the rng updates here too, but I'd like something right now we can have here for a non-breaking release fix).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My impression is the Xoshiro seeding should be quite good at mixing, so I'm hoping this is reasonable...

isaacsas and others added 2 commits February 23, 2026 13:00
…mport

The variable_rate.jl test was checking prob.u0.jump_u, but VR_FRM's
callback initialize sets integrator.u.jump_u (a copy). Updated the test
to use init() and check the integrator's jump_u values directly.

Also removed the stale randexp! import that was flagged by ExplicitImports.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@isaacsas isaacsas merged commit 2d1f9d7 into SciML:master Feb 23, 2026
11 checks passed
@isaacsas isaacsas deleted the fix_data_race_condit branch February 23, 2026 21:39
@isaacsas isaacsas mentioned this pull request Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant