Skip to content

Draw jump times in the time's type; build Float32/BigFloat priority tables - #718

Open
isaacsas wants to merge 5 commits into
SciML:masterfrom
isaacsas:typed-randexp
Open

isaacsas wants to merge 5 commits into
SciML:masterfrom
isaacsas:typed-randexp

Conversation

@isaacsas

Copy link
Copy Markdown
Member

Supersedes #716, whose priority-table fix is ported in the second commit (with its author as co-author). Fixes #674.

Changes

  1. Jump times are drawn in the numeric type of the time. The SSA aggregators drew every waiting time with randexp(rng), a Float64, so t + randexp(rng) / rate widened Float32 times (making CCNRM's Float32 time table fail with a MethodError) and gave BigFloat times only Float64 draws. VR_Direct mixed typed and untyped draws. A new internal typed_randexp(rng, t) draws in typeof(one(t)), the time's numeric type without units: randexp(rng, T) for floating-point types, and a converted Float64 draw for other numbers such as ForwardDiff.Dual. All 25 exponential draws in the SSA aggregators and the 6 in VR_FRM, VR_Direct and VR_DirectFW use it. The uniform rand(rng) draws used for selection stay Float64.
  2. DirectCR, RSSACR and DirectCRDirect build Float32 and BigFloat priority tables (from Fix Float32/BigFloat priority-table setup (issue #674) #716). The minimum rate is built in the rates' type (T(2)^minexponent instead of 2.0^minexponent). PriorityTable keeps at least its three base groups: for Float32, the default minimum rate 2^-40 is below eps(Float32), so the initial table would otherwise have no groups and a zero maxpriority, and growing it to fit a rate would loop forever. Fix Float32/BigFloat priority-table setup (issue #674) #716's converts in update!(::PriorityTimeTable) aren't needed after the first change, since times now arrive in the table's type.

On master, DirectCR, RSSACR and DirectCRDirect fail with a MethodError when building a problem with Float32 or BigFloat rates, and CCNRM fails when solving one with Float32 times. With this PR, every SSA aggregator, NSM and DirectCRDirect solve problems with Float32 and BigFloat times, except RDirect with BigFloat, which still fails at construction (a separate issue).

No Float64 changes

For Float64, randexp(rng, Float64) is randexp(rng), T(2)^e is 2.0^e, and the table already had three groups (2 * minrate > eps(Float64)). Checked on Julia 1.13.3 against master d9c94ec:

  • Seeded paths are identical in 18 cases: every SSA aggregator with mass-action and with constant-rate jumps, Coevolve with a bounded VariableRateJump, VR_FRM, VR_Direct, VR_DirectFW, NSM and DirectCRDirect.
  • The LLVM of the 192 JumpProcesses methods reachable through non-inlined calls from each aggregator's initialize!, generate_jumps! and execute_jumps! is identical, except for the GC stack-slot offsets in a few spatial methods, which also differ between two builds of the same code. The VR aggregators' affect and initialization code is identical too. The priority-table changes run only when a JumpProblem is built.
  • Benchmarks of 13 networks with all SSA aggregators, the VR aggregators, and NSM/DirectCRDirect, in rotated rounds against master and an A/A control (a second build of master): all differences are within the A/A spread.

Seeded results can change for Float32 problems (the same draws, but Float32 arithmetic) and BigFloat problems (full-precision draws), as noted in HISTORY.

Tests

  • test/fp_unknowns.jl: typed_randexp's types (Float32, Float64, BigFloat, Dual); Float32 and BigFloat solves with every SSA aggregator (except RDirect for BigFloat), NSM and DirectCRDirect, checking the mean of a birth-death process.
  • test/table_test.jl: Float32 priority tables, including the one DirectCR builds (from Fix Float32/BigFloat priority-table setup (issue #674) #716).
  • test/isolated_copy.jl: unsolved BigFloat problems now include DirectCR and RSSACR.
  • Run locally: fp_unknowns.jl, table_test.jl, isolated_copy.jl, ssa_aggregator_smoke.jl, spatial/ABC.jl and variable_rate.jl pass.

🤖 Generated with Claude Code 2.1.321 (model: claude-opus-5-5)

isaacsas and others added 2 commits November 11, 2026 08:37
The SSA aggregators drew every waiting time with `randexp(rng)`, a Float64, so
`t + randexp(rng) / rate` widened Float32 times (making CCNRM's Float32 time table fail) and
gave BigFloat times only Float64 draws; VR_Direct mixed typed and untyped draws. A new
`typed_randexp(rng, t)` draws in `typeof(one(t))`, the time's numeric type without units:
floating-point types with `randexp(rng, T)`, other numbers (e.g. dual numbers) by converting
a Float64 draw. All exponential draws in the aggregators and the VR aggregators use it.

For Float64, `randexp(rng, Float64)` is `randexp(rng)`: seeded results are unchanged, and the
compiled code of every JumpProcesses method reached from the aggregators is identical (up to
stack-slot assignment in four spatial methods), as are timings within run-to-run noise.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rectCRDirect

Ported from SciML#716 (issue SciML#674). The composition-rejection aggregators computed their minimum
rate as `2.0^minexponent`, a Float64, so building a problem with Float32 or BigFloat rates
failed with a MethodError. The minimum rate is now in the rates' type. For Float32, the
default minimum rate 2^-40 is also below eps(Float32), which `priortogid` maps to group 1, so
the initial table (maxpriority = 2 * minrate) would get no groups and a zero maxpriority, and
growing it to fit a rate would loop forever: `PriorityTable` now keeps at least the three
base groups {0}, (0, minpriority) and [minpriority, 2 * minpriority).

For Float64, 2 * minrate is above eps, so the table already had three groups; both changes
run only when a JumpProblem is built, and seeded results and the compiled solve code are
unchanged. SciML#716's `convert`s in `update!(::PriorityTimeTable)` aren't needed, since times are
now drawn in the time's type.

Tests: Float32 priority tables (from SciML#716); Float32 and BigFloat solves with every SSA
aggregator (except RDirect for BigFloat), NSM and DirectCRDirect, checking the mean; and
isolated_copy of unsolved BigFloat DirectCR and RSSACR problems.

Co-Authored-By: ChrisRackauckas-Claude <224351616+ChrisRackauckas-Claude@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark Results (Julia v1)

Time benchmarks
master 49901d4 master / 49901d4
aggregators/CCNRM 0.15 ± 0.0033 ms 0.149 ± 0.0033 ms 1.01 ± 0.031
aggregators/Coevolve 0.178 ± 0.0035 ms 0.174 ± 0.0036 ms 1.02 ± 0.029
aggregators/DirectCR 0.17 ± 0.0046 ms 0.17 ± 0.0035 ms 0.999 ± 0.034
aggregators/DirectFW 0.127 ± 0.0024 ms 0.125 ± 0.0028 ms 1.01 ± 0.029
aggregators/FRM 0.119 ± 0.0025 ms 0.117 ± 0.0033 ms 1.02 ± 0.036
aggregators/FRMFW 0.12 ± 0.0026 ms 0.119 ± 0.0033 ms 1.01 ± 0.036
aggregators/NRM 0.155 ± 0.0034 ms 0.146 ± 0.0037 ms 1.06 ± 0.035
aggregators/RDirect 0.152 ± 0.0032 ms 0.151 ± 0.0031 ms 1.01 ± 0.03
aggregators/RSSA 0.145 ± 0.003 ms 0.145 ± 0.0036 ms 1 ± 0.033
aggregators/RSSACR 0.167 ± 0.0057 ms 0.165 ± 0.0062 ms 1.01 ± 0.051
aggregators/SortingDirect 0.127 ± 0.0036 ms 0.125 ± 0.0041 ms 1.01 ± 0.044
construct/jumpproblem_constantrate 0.12 ± 0.01 μs 0.12 ± 0.01 μs 1 ± 0.12
construct/jumpproblem_massaction 0.42 ± 0.03 μs 0.42 ± 0.02 μs 1 ± 0.086
construct/vr_direct 5.62 ± 0.34 μs 5.64 ± 0.27 μs 0.996 ± 0.077
construct/vr_frm 7.97 ± 5.5 μs 8.86 ± 5.6 μs 0.899 ± 0.84
events/ode_division/Direct 0.457 ± 0.0037 ms 0.473 ± 0.0037 ms 0.966 ± 0.011
events/sde_dosing/Direct 0.269 ± 0.004 ms 0.271 ± 0.0029 ms 0.991 ± 0.018
events/ssa_dosing/Direct 0.103 ± 0.0012 ms 0.104 ± 0.0013 ms 0.994 ± 0.018
events/vrj_reset/VR_Direct 1.38 ± 0.014 ms 1.39 ± 0.0086 ms 0.988 ± 0.012
events/vrj_reset/VR_FRM 2.35 ± 0.021 ms 2.3 ± 0.019 ms 1.02 ± 0.013
ode/mixed/VR_Direct 1.48 ± 0.013 ms 1.48 ± 0.019 ms 0.999 ± 0.015
ode/mixed/VR_FRM 2.55 ± 0.013 ms 2.51 ± 0.043 ms 1.02 ± 0.018
ode/sir_zero_drift/Direct 0.347 ± 0.0052 ms 0.368 ± 0.0079 ms 0.943 ± 0.025
ode/sir_zero_drift/NRM 0.38 ± 0.0046 ms 0.399 ± 0.0084 ms 0.952 ± 0.023
ode/telegraph/Coevolve 0.163 ± 0.0017 ms 0.165 ± 0.0027 ms 0.988 ± 0.019
ode/telegraph/Direct 0.163 ± 0.0018 ms 0.15 ± 0.0026 ms 1.08 ± 0.022
ode/telegraph/NRM 0.151 ± 0.0018 ms 0.155 ± 0.0017 ms 0.975 ± 0.016
pure_jump/bounded_vrj/Coevolve 0.341 ± 0.0035 ms 0.344 ± 0.0039 ms 0.991 ± 0.015
pure_jump/chain/CCNRM 0.816 ± 0.011 ms 0.796 ± 0.0081 ms 1.03 ± 0.017
pure_jump/chain/Direct 4.53 ± 0.037 ms 4.39 ± 0.023 ms 1.03 ± 0.0099
pure_jump/chain/DirectCR 0.516 ± 0.0078 ms 0.527 ± 0.0063 ms 0.979 ± 0.019
pure_jump/chain/NRM 0.632 ± 0.0097 ms 0.623 ± 0.012 ms 1.01 ± 0.025
pure_jump/chain/RSSA 2.05 ± 0.019 ms 2.05 ± 0.011 ms 1 ± 0.01
pure_jump/chain/RSSACR 0.486 ± 0.0057 ms 0.493 ± 0.0048 ms 0.987 ± 0.015
pure_jump/chain/SortingDirect 1.26 ± 0.015 ms 1.25 ± 0.011 ms 1.01 ± 0.015
sde/mixed/VR_Direct 1.06 ± 0.0078 ms 1.03 ± 0.0097 ms 1.03 ± 0.012
sde/mixed/VR_FRM 5.29 ± 0.024 ms 5.25 ± 0.033 ms 1.01 ± 0.0079
sde/telegraph/Direct 0.275 ± 0.0032 ms 0.277 ± 0.0026 ms 0.992 ± 0.015
solve/constantrate 0.123 ± 0.0023 ms 0.123 ± 0.003 ms 1 ± 0.031
solve/massaction 0.127 ± 0.0029 ms 0.125 ± 0.0031 ms 1.01 ± 0.034
vrj/m1_1/VR_Direct 0.328 ± 0.0018 ms 0.323 ± 0.0023 ms 1.01 ± 0.0091
vrj/m1_1/VR_DirectFW 0.353 ± 0.0021 ms 0.351 ± 0.0019 ms 1.01 ± 0.008
vrj/m1_1/VR_FRM 0.517 ± 0.0053 ms 0.524 ± 0.0038 ms 0.988 ± 0.012
vrj/m1_16/Coevolve 0.176 ± 0.0028 ms 0.178 ± 0.0033 ms 0.986 ± 0.024
vrj/m1_16/VR_Direct 0.66 ± 0.0069 ms 0.648 ± 0.0077 ms 1.02 ± 0.016
vrj/m1_16/VR_DirectFW 0.892 ± 0.012 ms 0.879 ± 0.0081 ms 1.01 ± 0.016
vrj/m1_16/VR_FRM 2.22 ± 0.037 ms 2.21 ± 0.02 ms 1.01 ± 0.019
time_to_load 0.976 ± 0.032 s 0.984 ± 0.0026 s 0.992 ± 0.033
Memory benchmarks
master 49901d4 master / 49901d4
aggregators/CCNRM 3.65 k allocs: 0.231 MB 3.65 k allocs: 0.231 MB 1
aggregators/Coevolve 3.65 k allocs: 0.232 MB 3.65 k allocs: 0.232 MB 1
aggregators/DirectCR 3.66 k allocs: 0.232 MB 3.66 k allocs: 0.232 MB 1
aggregators/DirectFW 3.71 k allocs: 0.234 MB 3.71 k allocs: 0.234 MB 1
aggregators/FRM 3.68 k allocs: 0.233 MB 3.68 k allocs: 0.233 MB 1
aggregators/FRMFW 3.68 k allocs: 0.233 MB 3.68 k allocs: 0.233 MB 1
aggregators/NRM 3.65 k allocs: 0.232 MB 3.65 k allocs: 0.232 MB 1
aggregators/RDirect 3.69 k allocs: 0.233 MB 3.69 k allocs: 0.233 MB 1
aggregators/RSSA 3.63 k allocs: 0.231 MB 3.63 k allocs: 0.231 MB 1
aggregators/RSSACR 3.71 k allocs: 0.234 MB 3.71 k allocs: 0.234 MB 1
aggregators/SortingDirect 3.69 k allocs: 0.233 MB 3.69 k allocs: 0.233 MB 1
construct/jumpproblem_constantrate 15 allocs: 0.625 kB 15 allocs: 0.625 kB 1
construct/jumpproblem_massaction 14 allocs: 0.688 kB 14 allocs: 0.688 kB 1
construct/vr_direct 0.106 k allocs: 5.08 kB 0.106 k allocs: 5.08 kB 1
construct/vr_frm 0.086 k allocs: 13 kB 0.086 k allocs: 13 kB 1
events/ode_division/Direct 0.082 k allocs: 4.34 kB 0.082 k allocs: 4.34 kB 1
events/sde_dosing/Direct 0.184 k allocs: 9.94 kB 0.184 k allocs: 9.94 kB 1
events/ssa_dosing/Direct 15 allocs: 1 kB 15 allocs: 1 kB 1
events/vrj_reset/VR_Direct 0.099 k allocs: 5.64 kB 0.099 k allocs: 5.64 kB 1
events/vrj_reset/VR_FRM 0.142 k allocs: 7.58 kB 0.142 k allocs: 7.58 kB 1
ode/mixed/VR_Direct 0.082 k allocs: 4.36 kB 0.082 k allocs: 4.36 kB 1
ode/mixed/VR_FRM 0.123 k allocs: 6.09 kB 0.123 k allocs: 6.09 kB 1
ode/sir_zero_drift/Direct 0.068 k allocs: 3.62 kB 0.068 k allocs: 3.62 kB 1
ode/sir_zero_drift/NRM 0.075 k allocs: 3.91 kB 0.075 k allocs: 3.91 kB 1
ode/telegraph/Coevolve 0.079 k allocs: 4.05 kB 0.079 k allocs: 4.05 kB 1
ode/telegraph/Direct 0.07 k allocs: 3.69 kB 0.07 k allocs: 3.69 kB 1
ode/telegraph/NRM 0.077 k allocs: 3.97 kB 0.077 k allocs: 3.97 kB 1
pure_jump/bounded_vrj/Coevolve 25 allocs: 2.2 kB 25 allocs: 2.2 kB 1
pure_jump/chain/CCNRM 19 allocs: 8.8 kB 19 allocs: 8.8 kB 1
pure_jump/chain/Direct 16 allocs: 5.61 kB 16 allocs: 5.61 kB 1
pure_jump/chain/DirectCR 16 allocs: 5.61 kB 16 allocs: 5.61 kB 1
pure_jump/chain/NRM 26 allocs: 18.4 kB 26 allocs: 18.4 kB 1
pure_jump/chain/RSSA 16 allocs: 5.61 kB 16 allocs: 5.61 kB 1
pure_jump/chain/RSSACR 16 allocs: 5.61 kB 16 allocs: 5.61 kB 1
pure_jump/chain/SortingDirect 16 allocs: 5.61 kB 16 allocs: 5.61 kB 1
sde/mixed/VR_Direct 0.204 k allocs: 11.6 kB 0.204 k allocs: 11.6 kB 1
sde/mixed/VR_FRM 0.328 k allocs: 17.9 kB 0.328 k allocs: 17.9 kB 1
sde/telegraph/Direct 0.183 k allocs: 9.81 kB 0.183 k allocs: 9.81 kB 1
solve/constantrate 3.71 k allocs: 0.234 MB 3.71 k allocs: 0.234 MB 1
solve/massaction 3.71 k allocs: 0.234 MB 3.71 k allocs: 0.234 MB 1
vrj/m1_1/VR_Direct 0.082 k allocs: 4.33 kB 0.082 k allocs: 4.33 kB 1
vrj/m1_1/VR_DirectFW 0.082 k allocs: 4.33 kB 0.082 k allocs: 4.33 kB 1
vrj/m1_1/VR_FRM 0.123 k allocs: 6.19 kB 0.123 k allocs: 6.19 kB 1
vrj/m1_16/Coevolve 0.079 k allocs: 6.67 kB 0.079 k allocs: 6.67 kB 1
vrj/m1_16/VR_Direct 0.082 k allocs: 6.52 kB 0.082 k allocs: 6.52 kB 1
vrj/m1_16/VR_DirectFW 0.082 k allocs: 6.52 kB 0.082 k allocs: 6.52 kB 1
vrj/m1_16/VR_FRM 0.159 k allocs: 20.3 kB 0.159 k allocs: 20.3 kB 1
time_to_load 0.201 k allocs: 12.1 kB 0.201 k allocs: 12.1 kB 1

Benchmark Results (Julia lts)

Time benchmarks
master 49901d4 master / 49901d4
aggregators/CCNRM 0.107 ± 0.0016 ms 0.107 ± 0.0014 ms 0.998 ± 0.02
aggregators/Coevolve 0.127 ± 0.002 ms 0.126 ± 0.0017 ms 1.01 ± 0.021
aggregators/DirectCR 0.126 ± 0.0016 ms 0.127 ± 0.0017 ms 0.992 ± 0.018
aggregators/DirectFW 0.0879 ± 0.002 ms 0.0876 ± 0.0019 ms 1 ± 0.032
aggregators/FRM 0.0857 ± 0.0028 ms 0.0875 ± 0.0025 ms 0.979 ± 0.042
aggregators/FRMFW 0.0884 ± 0.0026 ms 0.0906 ± 0.0025 ms 0.976 ± 0.039
aggregators/NRM 0.111 ± 0.002 ms 0.111 ± 0.0018 ms 0.999 ± 0.024
aggregators/RDirect 0.106 ± 0.0022 ms 0.109 ± 0.0018 ms 0.97 ± 0.026
aggregators/RSSA 0.0991 ± 0.0034 ms 0.101 ± 0.0019 ms 0.986 ± 0.038
aggregators/RSSACR 0.121 ± 0.0026 ms 0.125 ± 0.0022 ms 0.972 ± 0.027
aggregators/SortingDirect 0.0878 ± 0.0017 ms 0.0899 ± 0.0014 ms 0.977 ± 0.024
construct/jumpproblem_constantrate 0.16 ± 0.021 μs 0.15 ± 0.02 μs 1.07 ± 0.2
construct/jumpproblem_massaction 0.34 ± 0.02 μs 0.35 ± 0.02 μs 0.971 ± 0.08
construct/vr_direct 4.21 ± 0.3 μs 4.34 ± 0.36 μs 0.97 ± 0.11
construct/vr_frm 7 ± 0.51 μs 7.01 ± 0.63 μs 0.999 ± 0.12
events/ode_division/Direct 0.344 ± 0.0051 ms 0.348 ± 0.002 ms 0.988 ± 0.016
events/sde_dosing/Direct 0.186 ± 0.002 ms 0.187 ± 0.0019 ms 0.997 ± 0.015
events/ssa_dosing/Direct 0.0669 ± 0.0006 ms 0.0655 ± 0.00064 ms 1.02 ± 0.014
events/vrj_reset/VR_Direct 1 ± 0.0053 ms 1.02 ± 0.0049 ms 0.981 ± 0.007
events/vrj_reset/VR_FRM 1.32 ± 0.0067 ms 1.34 ± 0.009 ms 0.986 ± 0.0083
ode/mixed/VR_Direct 0.976 ± 0.0053 ms 0.976 ± 0.0048 ms 1 ± 0.0074
ode/mixed/VR_FRM 1.58 ± 0.0076 ms 1.56 ± 0.0091 ms 1.01 ± 0.0077
ode/sir_zero_drift/Direct 0.296 ± 0.005 ms 0.297 ± 0.0048 ms 0.997 ± 0.023
ode/sir_zero_drift/NRM 0.325 ± 0.0051 ms 0.327 ± 0.0046 ms 0.994 ± 0.021
ode/telegraph/Coevolve 0.124 ± 0.0011 ms 0.122 ± 0.001 ms 1.01 ± 0.012
ode/telegraph/Direct 0.106 ± 0.00076 ms 0.108 ± 0.0011 ms 0.986 ± 0.012
ode/telegraph/NRM 0.11 ± 0.00082 ms 0.111 ± 0.00085 ms 0.997 ± 0.011
pure_jump/bounded_vrj/Coevolve 0.201 ± 0.0029 ms 0.207 ± 0.002 ms 0.972 ± 0.017
pure_jump/chain/CCNRM 0.444 ± 0.0035 ms 0.417 ± 0.0032 ms 1.06 ± 0.012
pure_jump/chain/Direct 2.07 ± 0.039 ms 2.11 ± 0.03 ms 0.981 ± 0.023
pure_jump/chain/DirectCR 0.338 ± 0.0025 ms 0.337 ± 0.0028 ms 1 ± 0.011
pure_jump/chain/NRM 0.427 ± 0.0065 ms 0.426 ± 0.0058 ms 1 ± 0.021
pure_jump/chain/RSSA 1.01 ± 0.016 ms 0.992 ± 0.0057 ms 1.01 ± 0.017
pure_jump/chain/RSSACR 0.256 ± 0.0033 ms 0.263 ± 0.0039 ms 0.973 ± 0.019
pure_jump/chain/SortingDirect 0.624 ± 0.0053 ms 0.612 ± 0.005 ms 1.02 ± 0.012
sde/mixed/VR_Direct 0.659 ± 0.02 ms 0.619 ± 0.0055 ms 1.07 ± 0.033
sde/mixed/VR_FRM 3.56 ± 0.022 ms 3.45 ± 0.022 ms 1.03 ± 0.0092
sde/telegraph/Direct 0.189 ± 0.0026 ms 0.19 ± 0.0023 ms 0.993 ± 0.018
solve/constantrate 0.0809 ± 0.0022 ms 0.0803 ± 0.0024 ms 1.01 ± 0.041
solve/massaction 0.0875 ± 0.0024 ms 0.0887 ± 0.0021 ms 0.986 ± 0.036
vrj/m1_1/VR_Direct 0.22 ± 0.0047 ms 0.232 ± 0.011 ms 0.949 ± 0.048
vrj/m1_1/VR_DirectFW 0.254 ± 0.0033 ms 0.242 ± 0.0021 ms 1.05 ± 0.016
vrj/m1_1/VR_FRM 0.298 ± 0.001 ms 0.294 ± 0.0011 ms 1.01 ± 0.0052
vrj/m1_16/Coevolve 0.128 ± 0.0013 ms 0.127 ± 0.0015 ms 1.01 ± 0.016
vrj/m1_16/VR_Direct 0.432 ± 0.0029 ms 0.434 ± 0.0025 ms 0.996 ± 0.0088
vrj/m1_16/VR_DirectFW 0.48 ± 0.0026 ms 0.486 ± 0.0029 ms 0.986 ± 0.008
vrj/m1_16/VR_FRM 1.54 ± 0.0087 ms 1.51 ± 0.0083 ms 1.02 ± 0.008
time_to_load 0.798 ± 0.032 s 0.794 ± 0.022 s 1 ± 0.049
Memory benchmarks
master 49901d4 master / 49901d4
aggregators/CCNRM 1.82 k allocs: 0.192 MB 1.82 k allocs: 0.192 MB 1
aggregators/Coevolve 1.83 k allocs: 0.192 MB 1.83 k allocs: 0.192 MB 1
aggregators/DirectCR 1.83 k allocs: 0.193 MB 1.83 k allocs: 0.193 MB 1
aggregators/DirectFW 1.85 k allocs: 0.194 MB 1.85 k allocs: 0.194 MB 1
aggregators/FRM 1.84 k allocs: 0.194 MB 1.84 k allocs: 0.194 MB 1
aggregators/FRMFW 1.84 k allocs: 0.194 MB 1.84 k allocs: 0.194 MB 1
aggregators/NRM 1.83 k allocs: 0.192 MB 1.83 k allocs: 0.192 MB 1
aggregators/RDirect 1.84 k allocs: 0.194 MB 1.84 k allocs: 0.194 MB 1
aggregators/RSSA 1.82 k allocs: 0.192 MB 1.82 k allocs: 0.192 MB 1
aggregators/RSSACR 1.85 k allocs: 0.194 MB 1.85 k allocs: 0.194 MB 1
aggregators/SortingDirect 1.84 k allocs: 0.194 MB 1.84 k allocs: 0.194 MB 1
construct/jumpproblem_constantrate 12 allocs: 0.781 kB 12 allocs: 0.781 kB 1
construct/jumpproblem_massaction 10 allocs: 0.703 kB 10 allocs: 0.703 kB 1
construct/vr_direct 0.1 k allocs: 5.36 kB 0.1 k allocs: 5.36 kB 1
construct/vr_frm 0.097 k allocs: 15 kB 0.097 k allocs: 15 kB 1
events/ode_division/Direct 0.059 k allocs: 4.8 kB 0.059 k allocs: 4.8 kB 1
events/sde_dosing/Direct 0.133 k allocs: 10.7 kB 0.133 k allocs: 10.7 kB 1
events/ssa_dosing/Direct 10 allocs: 1.03 kB 10 allocs: 1.03 kB 1
events/vrj_reset/VR_Direct 0.072 k allocs: 6.09 kB 0.072 k allocs: 6.09 kB 1
events/vrj_reset/VR_FRM 0.093 k allocs: 8.06 kB 0.093 k allocs: 8.06 kB 1
ode/mixed/VR_Direct 0.059 k allocs: 4.81 kB 0.059 k allocs: 4.81 kB 1
ode/mixed/VR_FRM 0.079 k allocs: 6.58 kB 0.079 k allocs: 6.58 kB 1
ode/sir_zero_drift/Direct 0.052 k allocs: 4.17 kB 0.052 k allocs: 4.17 kB 1
ode/sir_zero_drift/NRM 0.056 k allocs: 4.45 kB 0.056 k allocs: 4.45 kB 1
ode/telegraph/Coevolve 0.057 k allocs: 4.53 kB 0.057 k allocs: 4.53 kB 1
ode/telegraph/Direct 0.052 k allocs: 4.17 kB 0.052 k allocs: 4.17 kB 1
ode/telegraph/NRM 0.056 k allocs: 4.45 kB 0.056 k allocs: 4.45 kB 1
pure_jump/bounded_vrj/Coevolve 16 allocs: 2.28 kB 16 allocs: 2.28 kB 1
pure_jump/chain/CCNRM 12 allocs: 9.34 kB 12 allocs: 9.34 kB 1
pure_jump/chain/Direct 11 allocs: 6.09 kB 11 allocs: 6.09 kB 1
pure_jump/chain/DirectCR 11 allocs: 6.09 kB 11 allocs: 6.09 kB 1
pure_jump/chain/NRM 15 allocs: 19 kB 15 allocs: 19 kB 1
pure_jump/chain/RSSA 11 allocs: 6.09 kB 11 allocs: 6.09 kB 1
pure_jump/chain/RSSACR 11 allocs: 6.09 kB 11 allocs: 6.09 kB 1
pure_jump/chain/SortingDirect 11 allocs: 6.09 kB 11 allocs: 6.09 kB 1
sde/mixed/VR_Direct 0.144 k allocs: 12.1 kB 0.144 k allocs: 12.1 kB 1
sde/mixed/VR_FRM 0.21 k allocs: 19 kB 0.21 k allocs: 19 kB 1
sde/telegraph/Direct 0.133 k allocs: 10.6 kB 0.133 k allocs: 10.6 kB 1
solve/constantrate 1.85 k allocs: 0.194 MB 1.85 k allocs: 0.194 MB 1
solve/massaction 1.85 k allocs: 0.194 MB 1.85 k allocs: 0.194 MB 1
vrj/m1_1/VR_Direct 0.059 k allocs: 4.78 kB 0.059 k allocs: 4.78 kB 1
vrj/m1_1/VR_DirectFW 0.059 k allocs: 4.78 kB 0.059 k allocs: 4.78 kB 1
vrj/m1_1/VR_FRM 0.079 k allocs: 6.67 kB 0.079 k allocs: 6.67 kB 1
vrj/m1_16/Coevolve 0.057 k allocs: 7.17 kB 0.057 k allocs: 7.17 kB 1
vrj/m1_16/VR_Direct 0.059 k allocs: 6.97 kB 0.059 k allocs: 6.97 kB 1
vrj/m1_16/VR_DirectFW 0.059 k allocs: 6.97 kB 0.059 k allocs: 6.97 kB 1
vrj/m1_16/VR_FRM 0.107 k allocs: 20.8 kB 0.107 k allocs: 20.8 kB 1
time_to_load 0.153 k allocs: 14.6 kB 0.153 k allocs: 14.6 kB 1

isaacsas and others added 2 commits November 11, 2026 23:04
Test the sample means to 4 standard deviations of a Poisson mean, with 4000 Float32 and 1000
BigFloat simulations: within 2% (Float32) and 4% (BigFloat) of the mean of X(10), where they
were within 5% and 10%. The two-site spatial totals used twice the one-site tolerance, about
7 standard deviations; they now use their own, sqrt(20 / Nsims). All the current means are
within 1.2 standard deviations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From the second review of SciML#718:

- NSM and DirectCRDirect stored reaction rates as Float64 (`RxRates`), so a BigFloat rate
  below floatmin(Float64) rounded to zero and its reaction never fired. `RxRates` now takes
  the rate type, and both use the time's type, as the other aggregators do; the two-argument
  constructor still makes Float64 rates.
- DirectCR, RSSACR and DirectCRDirect took the exponent of a `minrate` keyword before
  converting it to the rates' type: with `minrate = 1e-50` and Float32 rates, the minimum
  rate became zero and growing the table looped forever. `minrate` is now converted first
  and raised to at least floatmin(T) (converting 1e-50 to Float32 gives zero, whose exponent
  is an error); rates that small are in the table's lowest group either way.
- A rate of at least 2^exponent(floatmax(T)) (e.g. 2f0^127) is in the group whose upper bound
  overflows to Inf, so `sample` could never accept it. `padtable!` caps a new group's
  rejection bound at floatmax(T), while the table's `maxpriority` still reaches Inf. The
  constructor never makes that group, since its groups end below `maxpriority`. This also
  affected Float64, on master too.
- `typed_randexp` draws floating-point times in their own type without `one(t)`, which
  allocated a BigFloat per draw (~93 bytes).
- The Float32 table-growth test inserted id 1 twice; it now updates it, and checks `resum!`.

Float64 results are unchanged (seeded paths identical to master in 18 cases), and the
compiled solve code is identical except `padtable!`, which runs only when a table grows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ChrisRackauckas

Copy link
Copy Markdown
Member

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

Independent review (Codex CLI v0.164.0 / gpt-6.1-sol), reviewer session 01a1cf3c-03f2-7cb3-aab3-147657206439, reviewed head cb1a0be

  • Verdict: CHANGES
  • Risk assessment: medium (M2: changes numerical results on working Float32 spatial paths; a silent regression is confirmed against the base revision).
  • Round / slot: 2 / 1

This is a blind code-only review by a session other than the PR author's, copied below from the reviewer's report with only the grading metadata removed. The posting agent did not re-run the reviewer's commands. A MERGE verdict is advice; merging is left to the maintainers.

CI: green
Session: 01a1cf3c-03f2-7cb3-aab3-147657206439

Risk

medium (M2: changes numerical results on working Float32 spatial paths; a silent regression is confirmed against the base revision).

Blocking findings

  1. [P1] Preserve surviving spatial reactions when Float32 rate totals cancel. src/spatial/nsm.jl:62, src/spatial/directcrdirect.jl:76, and src/spatial/reaction_rates.jl:35 select Float32 reaction buffers from the time type. The incremental accumulation at src/spatial/reaction_rates.jl:99 then loses a slower channel when the fast channel stops. This produces incorrect trajectories without an error.

    Confirmed by running this model with StableRNG(31):

    using JumpProcesses, SciMLBase, StableRNGs
    maj = MassActionJump([1e8, 3.0], [[1 => 1], [2 => 1]],
        [[1 => -1], [2 => -1]])
    prob = DiscreteProblem(ones(Int, 2, 1), (0.0f0, 10.0f0))
    jp = JumpProblem(prob, NSM(), maj;
        hopping_constants = zeros(Float32, 2, 1),
        spatial_system = CartesianGrid((1,)))
    integrator = init(jp, SSAStepper(); rng = StableRNG(31))
    step!(integrator)

    After the fast decay, the head has u = [0; 1;;], stored reaction rates Float32[0; 3;;], total rate 0.0f0, and next jump time Inf32. Completing the solve leaves the second species at one. The base revision d9c94ec8bef13903cab1f3f36972ccaf59394e6b with the same NSM model and seed retains total rate 3.0, schedules the next reaction at 1.3295975f0, and finishes at [0; 0;;]. This is cancellation of Float32(1e8 + 3) - Float32(1e8), rather than a random difference between trajectories. Both MassActionJump and SpatialMassActionJump reproduce it; the newly enabled Float32 DirectCRDirect path also fails.

    Suggested fix: detect inaccurate spatial reaction/site/table sums and recompute them from stored propensities before scheduling or deciding that no jumps remain. Add this fast/slow-channel regression for both spatial aggregators and reaction representations, checking the completed trajectory as well as the totals.

  • Verdict: CHANGES
  • Round: 2
  • Blocking priorities: P1
  • Deferred P2 issues: none; no P2 blockers.

Non-blocking findings

None.

What I ran

Reviewer: codex-cli 0.164.0, model gpt-6.1-sol. Julia reported julia version 1.13.2. I preserved the supplied layered JULIA_DEPOT_PATH, exported the requested TMPDIR, and used only the requested scratch directory for test copies, environments and probes. No repository-root AGENTS.md or CLAUDE.md exists in this checkout.

  • From an unchanged git archive HEAD scratch copy, with four Julia threads, four precompile tasks, and a 12 GiB memory scope:

    using Pkg
    for group in ("InterfaceI", "InterfaceII")
        ENV["GROUP"] = group
        println("REVIEW_GROUP_START ", group)
        Pkg.test(; julia_args = ["--threads=4"])
        println("REVIEW_GROUP_PASS ", group)
    end

    Exit 0; both groups reported Testing JumpProcesses tests passed. InterfaceI: 2,873 passing assertions; InterfaceII: 5,795. These include fp_unknowns.jl (76), table_test.jl (56), variable-rate tests (314), isolated_copy.jl (2,205), and the spatial suites.

  • julia --project=../scratch/probeenv ../scratch/multiscale.jl: 12/12 assertions failed, covering NSM/DirectCRDirect and ordinary/spatial mass-action representations. Observed zero totals despite a stored propensity of three, infinite next times, and the surviving species never decaying.

  • julia --project=../scratch/baseenv ../scratch/multiscale-base.jl: 6/6 passed for the two NSM representations on the unmodified base. Both used copies of the same resolved test dependency environment, differing in the package source path.

  • julia --project=../scratch/probeenv ../scratch/probes.jl: analytic exponential first/second moments passed 6/6 (20,000 draws per floating type); categorical probabilities passed 12/12 (50,000 samples per case, tiny/ordinary/near-overflow priorities in Float32/Float64, analytic weights 0.8/0.2/0). Spatial extinction checks passed 6 and failed 6: rates [0, 0] retained total 1.4901161f-8; NSM scheduled another event at 2.6768333f8. This supports the same blocking finding.

  • float64_paths.jl ran against base and head in their respective scratch environments: 26/26 seeded Float64 trajectories matched exactly, covering every nonspatial aggregator with mass-action and constant-rate jumps, plus both spatial aggregators.

  • git diff --check origin/master...HEAD: exit 0. Final git status --porcelain=v1: empty.

  • uv run --locked python --version: Python 3.15.0, with uv's warning that --locked has no effect outside a project. There is no Python project/uv.lock or committed Julia Manifest in this checkout; Julia tests used scratch-resolved environments, with their manifests retained.

What I did not verify

Other Julia versions, QA, the dedicated ThreadSafety group, GPU execution, or the documentation build. CI green is supplied by the review job; I did not inspect remote CI, the PR body, comments, reviews, author risk ratings, or sibling review artifacts. The newest commit has no Agent-Harness or Agent-Model trailers, so both author attribution fields below are unknown.


🤖 Posted by an AI agent — harness: Claude Code 2.1.322 · model: claude-sonnet-5-5
Conversation: local session 3878b54e-28f2-4a01-a176-a8f5468d1997 (no session URL)

@isaacsas

Copy link
Copy Markdown
Member Author

Thanks for the report. The cancellation is real, but it isn't specific to Float32 or to this PR. On master, NSM and DirectCRDirect lose the slow channel the same way in Float64 once the rates differ by about 1e16: with rates [1e17, 3.0] the slow species is left in 100 of 100 seeded runs. The spatial aggregators never got #706's running-sum error checks; that is now tracked in #719.

This PR makes the spatial reaction rates follow the time's type, like every other aggregator's rates, so Float32 problems reach the cancellation at a smaller rate ratio. We're keeping the rates in the problem's type rather than computing Float32 rates in Float64: choosing Float32 accepts its lower accuracy, and the cancellation needs fixing in the running sums themselves, for every type, in #719.

🤖 Generated with Claude Code 2.1.321 (model: claude-opus-5-5)

From the fourth review of SciML#718. Rates at or below eps(T) all go in the tables' first group, so
a smaller minrate only adds empty groups, one per power of two: with
minrate = floatmin(BigFloat) (2^-1073741824 on Julia 1.13), a rate of 1 maps to group about
1.07e9, and growing the table to it exhausts memory. DirectCR, RSSACR and DirectCRDirect now
raise minrate to at least eps(T), replacing the floatmin(T) floor. The Float64 and BigFloat
defaults (2^-40) are unchanged; the Float32 default rises to eps(Float32) = 2^-23, which
removes 17 empty groups and leaves seeded paths unchanged.

The suggested upper bound, floatmax(T) / 2, is left out: a minrate of 2f0^127 fails at
construction (DomainError), and clamping it to 2^126 puts every ordinary rate in one group
rejection-sampled against 2^126, so a solve with rates [10, 1] doesn't finish.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ChrisRackauckas

Copy link
Copy Markdown
Member

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

PR: #718

Reviewed head: 49901d4
Raw SHA-256: 838710d4524cd64b8781b240e698b3632dea0265d3459f7eaef0cd146bbb7d46
Source SHA-256: ccf8a0d5f074228d735534396aafcebd041db20e146daa8daa295bab7c06ce2a
Source: standard-review-v1 (harness-log)
Reviewer session: 01a1d0ad-c81d-7063-befa-75b6f88eee50
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes

Risk assessment

  • Risk: medium (M2)
  • Verdict: CHANGES
  • Reviewed head: 49901d4

Review report

VERDICT: CHANGES
Round: 3
Head: 49901d4
Slot: 1
CI: CI is not green
Session: 01a1d0ad-c81d-7063-befa-75b6f88eee50

Risk

medium (M2: changes trajectories on working Float32 spatial paths; a silent regression is confirmed against the base revision).

Blocking findings

  1. [P1] The round-two spatial cancellation blocker remains unresolved. src/spatial/nsm.jl:62 and src/spatial/directcrdirect.jl:77 select Float32 reaction buffers through src/spatial/reaction_rates.jl:35. The incremental total at src/spatial/reaction_rates.jl:99 then discards a surviving slow reaction when the fast reaction stops. The delta changes the rejection-table minimum, not this accumulation.

    Confirmed by running this reproducer:

    using JumpProcesses, SciMLBase, StableRNGs
    maj = MassActionJump([1e8, 3.0], [[1 => 1], [2 => 1]],
        [[1 => -1], [2 => -1]])
    jp = JumpProblem(DiscreteProblem(ones(Int, 2, 1), (0.0f0, 10.0f0)),
        NSM(), maj; hopping_constants = zeros(Float32, 2, 1),
        spatial_system = CartesianGrid((1,)))
    integrator = init(jp, SSAStepper(); rng = StableRNG(31))
    step!(integrator)

    After the fast decay, the head stores propensities Float32[0; 3;;], but its reaction total is 0.0f0 and its next jump time is Inf32. solve!(integrator) leaves the second species at one. This is cancellation of Float32(1e8 + 3) - Float32(1e8), not a stochastic trajectory difference. All four combinations of NSM/DirectCRDirect and ordinary/spatial mass-action jumps reproduce it: 12 failing assertions, with four initial-state assertions passing. On base d9c94ec8bef13903cab1f3f36972ccaf59394e6b, both NSM representations retain total 3.0, schedule the next reaction at 1.3295975f0, and finish at zero: 8/8 assertions pass with the same dependency versions and seed.

    Suggested fix: detect unreliable incremental spatial totals and recompute reaction, site and table sums before scheduling or concluding that no reactions remain. Add the fast/slow regression for both aggregators and both reaction representations, checking totals and the completed trajectory.

  • Verdict: CHANGES
  • Round: 3
  • Blocking priorities: P1
  • Deferred P2 issues: none.

Non-blocking findings

None found in the delta. The minimum-rate change passes the targeted execution, sampling and seeded-trajectory checks below.

What I ran

Reviewer: codex-cli 0.164.0, model gpt-6.1-sol. Julia reported julia version 1.13.2. I preserved the supplied layered JULIA_DEPOT_PATH, exported the requested TMPDIR, and used only the requested scratch directory for source copies, resolved environments, logs and probes. No repository-root AGENTS.md or CLAUDE.md exists. The independent risk was recorded before any author rating; none was inspected.

  • Read the supplied delta, the explicitly requested previous-head review and the whole PR diff. git diff cb1a0bef4d84361a2c0359f4d01e83f203b5e781 HEAD | cmp - ../delta.diff: exit 0.

  • Official tests, from an unchanged git archive HEAD scratch copy, with four Julia threads/precompile tasks and a 12 GiB memory scope:

    using Pkg
    for group in ("InterfaceI", "InterfaceII")
        ENV["GROUP"] = group
        Pkg.test(; julia_args = ["--threads=4", "-L", joinpath(@__DIR__, "capture_env.jl")])
    end

    The preload only retains Pkg's resolved test Project/Manifest for probes. InterfaceI reported Testing JumpProcesses tests passed: 2,891 passing assertions, including fp_unknowns.jl 94/94 and table_test.jl 56/56. InterfaceII also reported Testing JumpProcesses tests passed: 5,795 passing assertions, including isolated_copy.jl 2,205/2,205 and all spatial suites. The complete two-group runner exited 0. An initial reviewer launcher attempt stopped before tests because a preload print interfered with Pkg's cache-flags query; removing that print allowed the official run to proceed.

  • julia --project=../scratch/probeenv ../scratch/spatial_cancellation.jl: exit 1, 4 pass / 12 fail, confirming the P1 on the reviewed head. REVIEW_BASELINE=true julia --project=../scratch/baseenv ../scratch/spatial_cancellation.jl: exit 0, 8/8 pass on the base, using the same resolved dependencies with only the package source path changed.

  • julia --project=../scratch/probeenv ../scratch/minrate_probes.jl: exit 0, 24/24 pass. Minimum-rate contracts pass for three floating types and all three affected aggregators. Actual BigFloat solves with minrate=floatmin(BigFloat) complete, using 258/260/258 groups for DirectCR/RSSACR/DirectCRDirect. For priorities proportional to [4, 1, 0] below eps(T), 50,000 draws per type produce counts [39984, 10016, 0], within six binomial standard deviations of analytic weights [0.8, 0.2, 0].

  • REVIEW_BEFORE_DELTA=true julia --project=../scratch/deltaenv ../scratch/minrate_probes.jl: exit 1, 9/9 constructor-floor assertions fail on cb1a0bef4d84361a2c0359f4d01e83f203b5e781. I did not attempt its potentially memory-exhausting BigFloat solve.

  • Ran float32_seeded.jl against the reviewed head and pre-delta head: all nine complete seeded Float32 trajectories match exactly, covering DirectCR, RSSACR and DirectCRDirect with seeds 1, 31 and 12345. Both commands and cmp exited 0; each serialized result was 48,011 bytes.

  • uv run --locked python --version: Python 3.15.0; uv warned that --locked has no effect outside a project. The checkout has no Python project/uv.lock, committed Julia Manifest or interpreter-version pin. Julia verification therefore uses the installed 1.13.2 interpreter and retained Pkg-resolved test manifests, not a repository-supplied lock.

  • git diff --check origin/master...HEAD: exit 0. Final git status --porcelain=v1 was empty; no checkout files, commits or GitHub content were changed.

What I did not verify

Other Julia versions, QA, the dedicated ThreadSafety group, GPU execution or the documentation build. I did not inspect remote CI, the PR body, comments, author ratings, same-head prior reviews or sibling review directories. CI status above is supplied by the review job. The newest commit has neither Agent-Harness nor Agent-Model trailers, so both author attribution values are unknown.

AUTHOR_GRADE: {"task":"bugfix","score":3,"difficulty":3,"rounds":3,"author_harness":"unknown","author_model":"unknown","note":"The minimum-rate delta passes constructor, BigFloat solve, analytic sampling and seeded compatibility probes, but the prior Float32 spatial regression remains reproducible on the head and passes on the base."}

Head link: 49901d4


🤖 Posted by an AI agent — harness: codex-cli 0.164.0 · model: gpt-6.1-sol
Conversation: local session 01a1d0ad-c81d-7063-befa-75b6f88eee50 (no session URL)

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.

DirectCR, RSSACR and CCNRM fail with Float32 rates/tspan (Float64 hardcoded in priority-table setup)

2 participants