Skip to content

Use MassActionJump directly in stochastic tau-leaping solvers - #4523

Draft
ChrisRackauckas-Claude wants to merge 3 commits into
SciML:masterfrom
ChrisRackauckas-Claude:feature/native-massaction-leaping
Draft

ChrisRackauckas-Claude wants to merge 3 commits into
SciML:masterfrom
ChrisRackauckas-Claude:feature/native-massaction-leaping

Conversation

@ChrisRackauckas-Claude

@ChrisRackauckas-Claude ChrisRackauckas-Claude commented Sep 12, 2026 •

Copy link
Copy Markdown
Member

Tau-leaping solvers currently require RegularJump callbacks and estimate rate scales by evaluating at u ./ u. Add native MassActionJump support to TauLeaping, CaoTauLeaping, ImplicitTauLeaping, and ThetaTrapezoidalTauLeaping: retain stoichiometry, read stored constants directly, and fuse drift evaluation during implicit iteration.

The new public StochasticDiffEqCore.jump_noise_data hook lets each solver choose its reaction representation. General in-place/out-of-place regular jumps and exact SSA callbacks remain supported. Integer rate constants use floating propensity buffers. Documentation covers the native input and corrects the incomplete adaptive Cao selector; no GPU implementation is added.

Depends on the public mass-action operations and JumpProcesses 9.33 from SciML/JumpProcesses.jl#652 . Registry-only CI cannot resolve that version until it is released. Core advances to 2.3 and Leaping to 2.2 for the new public API and input support. The new documentation dependency, JumpProcesses, is MIT licensed, like this repository.

Verification

Julia 1.12.6, with the JumpProcesses prerequisite and monorepo dependencies developed locally. Ran the existing test entry points; Pkg.test hit a local relative-[sources] resolution error before launching tests.

GROUP=Core julia +1.12.6 --project=native-validation OrdinaryDiffEq.jl/lib/StochasticDiffEqLeaping/test/runtests.jl
GROUP=Core julia +1.12.6 --project=native-validation OrdinaryDiffEq.jl/lib/StochasticDiffEqCore/test/runtests.jl
julia +1.12.6 --project=native-validation OrdinaryDiffEq.jl/lib/StochasticDiffEqLeaping/test/qa/qa.jl
julia +1.12.6 --project=native-validation OrdinaryDiffEq.jl/lib/StochasticDiffEqCore/test/qa/qa.jl
julia +1.12.6 --project=OrdinaryDiffEq.jl/docs OrdinaryDiffEq.jl/docs/make.jl
Native mass-action leaping     | 118  118
Module loads and constructors |   5    5
Module loads and types        |  13   13
Quality Assurance (Leaping)   |  21   21
Quality Assurance (Core)      |  21   21
[ Info: HTMLWriter: rendering HTML pages.
[ Info: Automatic `version="7.8.1"` for inventory from ../Project.toml

Both QA suites used their declared-compatible JET 0.11.6. Aqua's Leaping subprocess used a temporary local JumpProcesses source entry to resolve the unreleased prerequisite; it was restored before committing. Runic on changed lines, typos over changed files, and git diff --check passed. Actual GPU execution and other stochastic algorithm groups were not run.

Discriminating tests caught two errors in the initial implementation (667d58e):

Exact mass-action jumps alongside regular leaps: Error During Test
ArgumentError: Mass-action leaping requires a DiscreteProblem with PureLeaping()

Test Failed: eltype(data.jump_prototype) <: AbstractFloat
Evaluated: Int64 <: AbstractFloat

The same cases now pass in the 118-check mass-action set, including fixed-seed trajectory equality, higher-order rates with zero populations, mixed exact/regular jumps, and fractional propensities with integer constants.

Measurements

The committed lib/StochasticDiffEqLeaping/benchmark/massaction.jl compares native input with a data-backed RegularJump adapter using the same mass-action operations. The model is a first-order reaction ring, fixed dt=0.01, time span (0,1), seed 123. Table entries are medians from three fresh processes per case; each process measures nine warmed-up solves on a shared machine.

Method Reactions Compilation: adapter → native (s) Warm solve: adapter → native (μs) Allocations: adapter → native (bytes)
explicit 10 3.621 → 3.007 53.7 → 56.9 6832 → 7056
explicit 1000 3.415 → 2.917 2492.7 → 2597.7 157592 → 149824
implicit 10 3.555 → 3.354 121.8 → 116.1 8192 → 8448
implicit 1000 3.917 → 3.226 7078.3 → 6776.6 206392 → 198784

Compilation and large-model allocation costs decreased in these cases. Warm runtime differences changed sign between repeated runs, so these measurements do not establish a general throughput improvement. Small-model allocation costs increased slightly.

CI status

The documentation, downgrade, and inspected downstream jobs fail dependency resolution because the registry currently ends at JumpProcesses 9.32.3 while this change requires 9.33. The documentation log is https://github.com/SciML/OrdinaryDiffEq.jl/actions/runs/34685462635/job/103531578714 .

Runic and spelling also found unchanged master errors in BDF and DiffEqBase tests. Their separately validated mechanical correction is #4524 . These failures are not suppressed in this branch.

Ignore this PR until reviewed by @ChrisRackauckas.

🤖 Generated with Codex CLI 0.153.4 (model: gpt-6-astra; local session ID: 01a070e6-21f2-7dd3-bf52-2ddaf108ac53).

🤖 Automated review section from an AI agent running as Chris Rackauckas's account — not written or reviewed by Chris.

Risk assessment (independent review, Codex CLI 0.164.0-alpha.11.1 gpt-6-astra, slot 1, head 3442f3a)

  • Risk: high (H6: Adds governing instructions in lib/StochasticDiffEqLeaping/AGENTS.md; the new dependency-facing numerical path also needs corrected compatibility and execution evidence.)
  • Verdict: CHANGES
  • Session: 01a18da8-0055-70e2-850a-45982d205850
  • Blocking priorities: P1, P2

Review round 1, written by the reviewer named above (Codex CLI 0.164.0-alpha.11.1 / gpt-6-astra) in a session other than the PR author's, and copied here by the posting agent without change to its findings. The posting agent did not re-run the reviewer's commands.

Summary: The PR adds native MassActionJump support and a documented jump_noise_data hook for four tau-leaping solvers. The new documentation example actually fails with an admitted JumpProcesses release because the required massaction_rates! API is absent.

Blast radius: StochasticDiffEqCore jump initialization and explicit/implicit tau-leaping, plus new repository-local governing instructions; regular-jump initialization is also refactored.

Evidence: Exact diff/head reviewed; docs CI resolved JumpProcesses 9.33.1 then failed in the new example with UndefVarError: massaction_rates! not defined. All Leaping Core jobs were canceled. Analytic propensity and manual-adapter tests are present (G1), but successful execution of the new supported paths with released dependencies is missing (G2).

Blocking findings

  1. [P1] lib/StochasticDiffEqLeaping/Project.toml:39 and lib/StochasticDiffEqLeaping/src/massaction.jl:5 — confirmed by running (PR CI; reviewer inspected the log): the declared JumpProcesses = "9.33" admits v9.33.1, which the documentation job installed. Running the newly added solve(prob, TauLeaping()) example then throws UndefVarError: massaction_rates! not defined in JumpProcesses instead of producing a trajectory. The same module provides the required drift and stoichiometry calls. Depend on a released version that actually contains all three public operations, update both package and docs compatibility, and exercise the minimum supported version; merely waiting for a version numbered 9.33 is insufficient.
  2. [P2] lib/StochasticDiffEqLeaping/test/runtests.jl:11 — suspected from reading (needs-verification/G2): all three Leaping Core CI jobs at this head are canceled, so the committed 151-line mass-action suite has no successful reviewer/CI run with the admitted released dependency stack. After correcting the prerequisite, run the existing Core test entry point for all four methods, in-place/out-of-place, fixed/adaptive supported modes, and the mixed exact/regular regression. The author's development-checkout output is useful context but is not independent execution evidence for this head's package contract.

Non-blocking findings

  1. lib/StochasticDiffEqLeaping/benchmark/README.md:1: the author correctly reports mixed warmed-runtime results rather than claiming a general speedup. Preserve that qualification when updating the dependency and rerunning measurements.

What I ran

  • git rev-parse HEAD returned 3442f3a201f0aa6f7e0c7f53e412bc0fdaff0754; exact detached PR head verified (exit 0).
  • git diff origin/master...HEAD and git diff --check origin/master...HEAD completed (exit 0); changed files, tests, callers, and repository instructions inspected. Root AGENTS.md and CLAUDE.md are absent. Risk was frozen before opening the description.
  • git rev-parse origin/master returned 14b964b315e1310b5e3621a1bcfe6b92e9e506aa; GitHub's PR metadata base is ab07f5de97257dce2a22c91a8f708158c75d6f90. The review diff uses the three-dot merge base; the header records the fetched base-branch tip.
  • git log -1 --first-parent --no-merges --format=%B inspected (exit 0); author trailers recorded below, or unknown when absent.
  • gh pr view 4523 --repo SciML/OrdinaryDiffEq.jl --json number,url,state,isDraft,headRefOid,baseRefName,baseRefOid,title,files,statusCheckRollup and the subsequent PR body read succeeded. Live state was OPEN.
  • Inspected gh pr checks 4523 --repo SciML/OrdinaryDiffEq.jl data: 28 success, 1 failure, 130 canceled, 1 skipped. The failure is documentation; all Leaping Core/QA/downgrade jobs are canceled.
  • gh run view 38459047603 --repo SciML/OrdinaryDiffEq.jl --log-failed (retrieval exit 0) shows Installed JumpProcesses v9.33.1, then the example at docs/src/stochastic/Algorithms.md:112 fails: UndefVarError: massaction_rates! not defined in JumpProcesses, with the call at src/massaction.jl:5. makedocs terminates on [:example_block]. Documentation CI.
  • Recent default-branch runs were inspected with gh run list --repo SciML/OrdinaryDiffEq.jl --branch master --event push --limit 5. Default docs run reports success; the PR failure is specifically in this PR's newly added example, not a claimed pre-existing default failure.
  • Inspected the newly added input rejection paths, manual second-order propensity/stoichiometry oracle, fractional-propensity test, and initialization callers. The dependency's MIT license is named in the PR description.

What I did not verify

No reviewer Julia solve or benchmark was run for this PR. GPU support is explicitly outside this implementation. Successful execution after the prerequisite API lands, AD behavior of the implicit mass-action drift, parameter-update/reinit behavior, and the full stochastic downstream suite remain unverified. The review is an independent session; the author trailer and reviewer both name gpt-6-astra, which is disclosed rather than hidden.

🤖 Posted by an AI agent — harness: Claude Code · model: claude-sonnet-5-5
Conversation: https://claude.ai/code/session_01379heiiB35TtywhR7uSU74

ChrisRackauckas and others added 2 commits September 12, 2026 04:59
Initialize reaction noise through a solver-owned public hook, retain mass-action
stoichiometry for updates, and fuse implicit drift evaluation. Cover in-place
and out-of-place solves, general rates, and stored higher-order rate constants.
Document supported stepping and add a reproducible representation benchmark.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Codex <noreply@openai.com>
Agent-Harness: Codex CLI 0.153.4
Agent-Model: gpt-6-astra
Agent-Session: local session ID 01a070e6-21f2-7dd3-bf52-2ddaf108ac53
Restrict native mass-action initialization to PureLeaping so existing regular
leaps can retain exact SSA callbacks. Promote propensity buffers when rate
constants are integers. Keep the executable StochasticDiffEq example with its
own package so the JumpProcesses prerequisite can be released independently.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Codex <noreply@openai.com>
Agent-Harness: Codex CLI 0.153.4
Agent-Model: gpt-6-astra
Agent-Session: local session ID 01a070e6-21f2-7dd3-bf52-2ddaf108ac53
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Devin <noreply@cognition.ai>
Agent-Harness: Devin CLI 3000.11.3 (conflict resolution), Claude Code 2.1.285 (orchestration)
Agent-Model: fusion-claude-opus-5-5-high-sidekick-swe-2-medium
Agent-Session: local Claude session 3c311569-dda6-4687-bc9f-65febb212c33 (fleet master); Devin log /Users/chrisrackauckas/sandbox/master/fusion-fixes/SciML_OrdinaryDiffEq.jl-4523/log.txt

# Conflicts:
#	lib/StochasticDiffEqCore/Project.toml
@ChrisRackauckas

Copy link
Copy Markdown
Member

🤖 Automated comment from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris.

Merged the default branch into this PR to resolve conflicts (head 3442f3a). Re-review the resolution before merging.

Conflict resolution report

STATUS: RESOLVED

Conflicting files

  • lib/StochasticDiffEqCore/Project.toml: the only conflict was the version line. Master went 2.2.2 → 2.2.3 (patch, in Require OrdinaryDiffEqCore 4.17.1 where its new internals are used #4525, which also raised the compat to OrdinaryDiffEqCore = "4.17.1"). The PR goes 2.2.2 → 2.3.0, a minor bump for the new public jump_noise_data hook. I kept 2.3.0, which is newer than both. Master's other changes to this file (the OrdinaryDiffEqCore 4.17.1 compat) merged in automatically and are kept.

Every other file merged without conflict. I checked how master's StochasticDiffEqCore changes fit with the PR. The first is the split of __init(::JumpProblem, ...) into separate methods (#4707), which sits in a different region of solve.jl from the PR's jump_noise_data rewrite of _sde_init. The second is the @cache handling of Vector{...} fields in misc_utils.jl. Neither interferes with the PR, and the tests below pass.

Runic: the only file I touched is a .toml, so there were no .jl files for Runic to format.

Tests

The PR needs JumpProcesses.massaction_rates!, massaction_stoichiometry_mul! and massaction_drift!. These exist only in the unmerged SciML/JumpProcesses.jl#652, which now carries version 9.34.0. The registered JumpProcesses 9.33.1 and 10.0.0 do not have them. So the sublibrary's own Pkg.test() cannot pass against the registry yet, and that was true before this merge too.

To test, I cloned that PR branch (ChrisRackauckas-Claude/JumpProcesses.jl at 087b42c9bec5129ac2b9741658821c7d6027cbf4) into scratch/JumpProcesses.jl. I then built the scratch env scratch/env on Julia 1.12.7, Pkg.develop-ing these paths: lib/DiffEqBase, lib/OrdinaryDiffEqCore, lib/OrdinaryDiffEqNonlinearSolve, lib/StochasticDiffEqLevyArea, lib/StochasticDiffEqCore, lib/StochasticDiffEqLeaping, and the JumpProcesses clone. Loaded JumpProcesses: 9.34.0 from the clone.

GROUP=Core julia +1.12 --project=scratch/env lib/StochasticDiffEqLeaping/test/runtests.jl
  Native mass-action leaping    | 118 pass / 118
  Module loads and constructors |   5 pass / 5
GROUP=Core julia +1.12 --project=scratch/env lib/StochasticDiffEqCore/test/runtests.jl
  Module loads and types        |  13 pass / 13
julia +1.12 --project=scratch/qaenv lib/StochasticDiffEqLeaping/test/qa/qa.jl
  Quality Assurance             |  21 pass / 21
julia +1.12 --project=scratch/qaenv lib/StochasticDiffEqCore/test/qa/qa.jl
  Quality Assurance             |  21 pass / 21

No failures or errors. The first QA run errored in Aqua's persistent-tasks check because Scratch was missing from the hand-built env; adding Scratch and GPUCompiler to scratch/qaenv fixed it, and no test was changed. Logs are in scratch/{leaping_core,core_core,leaping_qa,core_qa}.log. All Julia processes started for this run have been stopped.

Notes for review (not changed: outside the scope of a merge)

  • lib/StochasticDiffEqLeaping/Project.toml declares JumpProcesses = "9.33". 9.33.x lacks the required functions, so the lower bound needs to be raised to whatever release ships JumpProcesses.jl#652 (currently 9.34.0).
  • JumpProcesses 10.0.0 is registered, and the "9.33" compat excludes it.

Links


🤖 Posted by an AI agent — harness: Devin CLI 3000.11.3 (merge), Claude Code 2.1.285 (posting) · model: fusion-claude-opus-5-5-high-sidekick-swe-2-medium
Conversation: local Claude session 3c311569-dda6-4687-bc9f-65febb212c33 (fleet master)

This branch has not been deployed

No deployments
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.

2 participants