Skip to content

JumpProcesses 10#570

Open
isaacsas wants to merge 34 commits intomasterfrom
v10_working
Open

JumpProcesses 10#570
isaacsas wants to merge 34 commits intomasterfrom
v10_working

Conversation

@isaacsas
Copy link
Copy Markdown
Member

  1. Needs the Project.toml, and CI workflows updated to remove sources and references to this branch.
  2. Blocked waiting on a SciMLBase release with Ensemble rng redesign SciMLBase.jl#1252

isaacsas and others added 30 commits February 23, 2026 22:05
Make the integrator the single source of truth for RNG (Phase 1 Step 4).
Remove rng field from all aggregator structs, JumpProblem, and variable-rate
callback structs. All code now reads get_rng(integrator) at runtime.

Key changes:
- Remove RNG type param from AbstractSSAJumpAggregator and all concrete aggregators
- Remove rng from build_jump_aggregation and all aggregate() signatures
- Add rng field to SSAIntegrator with has_rng/get_rng/set_rng! interface
- Add resolve_rng utility for rng/seed/fallback priority resolution
- Remove rng from VR_FRMEventCallback and VR_DirectEventCache
- JumpProblem rng kwarg now forwards to solver via solkwargs
- Simplify solve.jl: remove _derive_jump_seed, simplify __jump_init
- Update SimpleTauLeaping/SimpleExplicitTauLeaping to use rng kwarg
- Add rng_kwarg_tests.jl covering all three solve pathways
- Update docs with RNG control section and FAQ entry
- Bump version to 9.23.0, SciMLBase compat to 2.144

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Breaking: JumpProblem no longer accepts an `rng` keyword argument.
Passing `rng` now throws an ArgumentError directing users to pass
it to `solve` or `init` instead. This fixes inconsistent RNG
priority ordering across solver pathways (SSAStepper, ODE/SDE,
tau-leaping) and makes the integrator the single source of truth
for RNG state.

- Simplify resolve_rng to 2-arg form (remove fallback_rng)
- Remove jump_prob.kwargs rng fallback from tau-leaping solvers
- Update all tests to pass rng to solve/init instead of JumpProblem
- Update docs and HISTORY.md with breaking change notes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ecking

- Revert <:Any back to named type params in ssajump.jl (minimize diff from master)
- Revert solkwargs to simpler ternary form in problem.jl (rng removal made filter unnecessary)
- Add type checking to SSAIntegrator set_rng! to match StochasticDiffEq pattern

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The GPU tau-leaping kernel uses PassthroughRNG internally; the
StableRNG was never consumed by the EnsembleGPUKernel path.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
solve(; rng = nothing) falls through to default_rng() via resolve_rng,
so the ternary guards are redundant.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Comparing continuous-valued jump times is more robust than discrete
final state values, which could collide by chance.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Check jump_u thresholds directly via init, and verify both event times
and post-event thresholds from ensemble solve.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Resolves conflicts by combining integrator RNG (get_rng) with
u_modified!(true) fix, and using robust first_jump_time helpers
in tests that account for the initialization save.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove StochasticDiffEq from [deps] (test-only, belongs in [extras])
- Move EnsembleThreads data race tests from ensemble_problems.jl to
  thread_safety.jl with stronger assertions (400 trajectories, allunique
  on first reaction times, all 3 VR aggregators, adaptive SDE solver)
- Renumber remaining ensemble_problems.jl sections

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- ensemble_problems.jl: check initial jump_u threshold (u[2]) instead
  of post-event (u[3]) now that u_modified!(true) produces init save
- extended_jump_array_remake.jl: rework to solve → remake → init →
  compare jump_u, verifying fresh thresholds after remake
- geneexpr_test.jl: remove unnecessary isnothing(rng) branch
- linearreaction_test.jl: make rng const for type stability
- variable_rate.jl: switch getmean from seed integer to StableRNG
- rng_kwarg_tests.jl: add SDE+VR different seeds test, SDE+VR no-rng
  functional test, seed kwarg reproducibility and different-seeds tests
  for all pathways (SSAStepper, ODE+VR, SDE+VR), use first_jump_time
  helper for robust event time extraction

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
… strengthen thread_safety assertions

- docs/advanced_point_process.md: move rng from JumpProblem to solve
- rng_kwarg_tests.jl: add seed kwarg tests for SimpleTauLeaping (tests 13-14), renumber 15-20
- thread_safety.jl: SSAStepper EnsembleThreads now runs 400 trajectories and asserts allunique first jump times

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Create ThreadSafety.yml workflow: runs thread_safety.jl with --threads=4
- Add ThreadSafety group to Tests.yml matrix (serial) and runtests.jl
- Move thread_safety.jl from InterfaceII to ThreadSafety group
- Fix shared rng data race: SSAStepper ensemble tests now use task-local
  default_rng() instead of a shared StableRNG across threads

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…-scaling

When MTKBase/Catalyst constructs MassActionJumps, the symbolic rate expressions
already include stoichiometric scaling (e.g. k/3! for 3X → Y), so they pass
scale_rates=false. However, update_parameters! defaulted to scale_rates=true,
causing every subsequent parameter update path (reset_aggregated_jumps!, remake,
finalize_parameters_hook!) to double-scale the rates.

The fix stores the intended scaling behavior on the struct as
rescale_rates_on_update, which update_parameters! now reads as its default.
This field is propagated through all merge/combine paths and validated for
consistency when merging multiple MassActionJumps.

Also fixes SpatialMassActionJump conversion constructor to default
scale_rates=false since it receives already-scaled rates.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The mapper now conditionally applies scalerates! based on scale_rates,
matching MTKBase JumpSysMajParamMapper behavior. Previously it ignored
scale_rates entirely, so the test would pass even with the old buggy
default of scale_rates=true.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Document that JumpProblem contains mutable state and is not thread-safe
for concurrent solve calls. Note that EnsembleProblem handles isolation
automatically via SciMLBase per-task deepcopy and per-trajectory RNG.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…structs

Move mutable rate working-copy (maj_rates) out of MassActionJump and into
all 10 aggregation structs + RxRates. Rates are now lazily materialized via
fill_scaled_rates! during initialize! instead of eagerly in the JumpProblem
constructor. This fixes aliasing bugs where multiple JumpProblems sharing
the same MAJ could silently corrupt each others rates.

Key changes:
- Add maj_rates field to all aggregation structs and RxRates
- Add fill_scaled_rates! dispatcher for parameterized vs explicit MAJs
- Update evalrxrate to 4-arg signature taking explicit maj_rates
- Propagate maj_rates through calculate_jump_rate, rejectrx, bracketing
- Remove update_parameters!, finalize_parameters_hook!
- Simplify reset_aggregated_jumps! (remove update_jump_params kwarg)
- JumpProblem constructor keeps original parameterized MAJ
- Add merge guards for mapper-backed MAJs
- Add SpatialMassActionJump guard for parameterized MAJs
- Remove dead 1-arg mapper callables
- Update all tests for lazy rate materialization pattern

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Narrow MAJ merge guards to only block custom (non-MassActionJumpParamMapper)
  mapper types. Built-in parameterized MAJ merges via varargs and JumpSet
  vectors work correctly and are tested in ssa_callback_test.jl.
- Fix 3-arg evalrxrate call in test/spatial/reaction_rates.jl to use
  eval_massaction_rate which handles both MassActionJump and
  SpatialMassActionJump correctly.
- Add fill_scaled_rates! call before spatial rate tests to populate maj_rates.
- Update scale_rates_field_test.jl merge test to verify built-in merges
  succeed and custom mapper merges error.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- setup_majump_to_merge now copies arrays before creating the merge
  accumulator, preventing in-place mutation from corrupting the original
  MAJ net_stoch/reactant_stoch arrays
- massaction_jump_combine(::Nothing, ::MassActionJump) now creates a safe
  copy via setup_majump_to_merge instead of returning the original MAJ
- Remove scale_rates and useiszero as JumpProblem kwargs; they are now
  properties of the MassActionJump itself. Passing them raises an
  informative ArgumentError

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Merge master into revamp_maj_initialization, bringing in:
- OrdinaryDiffEqCore package extension for __init ambiguity fix
- ExtendedJumpArray lmul!/ldiv! bug fix
- SDE+jump callback duplication test
- Doc updates for Catalyst v16

Reverted master update_jump_params kwarg addition to SSAIntegrator
reset_aggregated_jumps! and removed associated test, since this branch
removes that kwarg entirely (throws ArgumentError if passed).

Dropped OrdinaryDiffEqCore =3.15 pin in favor of master compat bound.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Move rng kwarg from JumpProblem to solve/init in merged test files
  (extended_jump_array.jl, callbacks.jl)
- Remove stale seed! import from JumpProcesses.jl (QA failure)
- Add fill_scaled_rates! in spatial bracketing test to populate maj_rates
- Remove old prob_func(prob, i, repeat) signature in thread_safety.jl
  (use default EnsembleProblem which already deepcopies)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
… update bracketing test

- Add fill_scaled_rates! no-op for SpatialMassActionJump (rates stored in
  struct, no working copy needed). Placed in spatial_massaction_jump.jl since
  the type is defined after jumps.jl in the include order.
- Update test/bracketing.jl: pass maj_rates to get_majump_brackets, add
  maj_rates field to DummyAggregator, call fill_scaled_rates! to init rates.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
isaacsas and others added 4 commits March 21, 2026 22:27
Bug 1: A single parameterized MassActionJump with scalar param_idxs
(e.g. param_idxs = 1) would segfault when passed directly to JumpProblem
without merging, because the scalar MassActionJumpParamMapper{Int} had no
callable method. Fix: convert scalar param_idxs to a one-element vector at
construction time, and add a JumpSet constructor for single-reaction
parameterized MAJs to normalize them to collection format.

Bug 2: Merging two single-reaction parameterized MAJs with vector-backed
param_idxs would mutate the first MAJ's mapper via aliasing in
to_collection. Fix: to_collection now copies the param_idxs vector.

Also: add docstring for the mapper callable API, remove dead code for
Int-typed mappers, and add tests for both bugs.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…TORY.md

- Move mapper callable API docstring from the method to
  MassActionJumpParamMapper struct where it belongs
- Add HISTORY.md entries for v10 breaking changes: scale_rates/useiszero
  removal from JumpProblem, immutable parameterized MAJ design,
  update_parameters! removal with reset_aggregated_jumps! guidance,
  custom mapper 3-arg callable requirement, scalar param_idxs normalization

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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