fix(integrators/fde): CaputoEuler.reset state desync + set_default_fdeint#846
Merged
Merged
Conversation
…lt_fdeint - CaputoEuler.reset replaced its f_states Variables with plain Arrays, causing state desync and wrong results after reset under IntegratorRunner; store f_states in a bm.VarDict so reset does in-place .value updates (High) - fdeint(method='l1') literal default made set_default_fdeint a no-op for default-method calls; default to method=None so the fallback runs (Medium) Findings recorded in docs/issues-found-20260619-integrators-fde-pde.md
Reviewer's GuideFixes a state desynchronization bug in the CaputoEuler fractional integrator reset path and restores correct honoring of the global default FDE method in fdeint, with regression tests and an audit report documenting FDE/PDE integrator issues and prior fixes. Sequence diagram for CaputoEuler.reset state synchronizationsequenceDiagram
actor User
participant CaputoEuler
participant VarDict as bm.VarDict
participant Variable as bm.Variable
participant IntegratorRunner
User->>CaputoEuler: __init__(alpha, num_memory, inits)
CaputoEuler->>VarDict: create VarDict({v: Variable(zeros)})
VarDict-->>CaputoEuler: f_states (VarDict of Variable)
User->>CaputoEuler: reset(inits)
CaputoEuler->>VarDict: f_states[key] = bm.zeros(...)
VarDict->>Variable: update .value in place
User->>IntegratorRunner: IntegratorRunner(CaputoEuler, dt, inits)
User->>IntegratorRunner: run(t_end)
IntegratorRunner->>CaputoEuler: _integral_func(...)
CaputoEuler->>Variable: read/write memory buffer
Sequence diagram for fdeint default method selection via set_default_fdeintsequenceDiagram
actor User
participant Generic as generic_module
participant Global as _DEFAULT_FDE_METHOD
participant FDEInt as fdeint
participant CaputoEuler
participant CaputoL1Schema
User->>Generic: set_default_fdeint("euler")
Generic->>Global: set _DEFAULT_FDE_METHOD = "euler"
User->>FDEInt: fdeint(alpha, num_memory, inits, method=None)
FDEInt->>Global: read _DEFAULT_FDE_METHOD
FDEInt-->>FDEInt: method = _DEFAULT_FDE_METHOD
alt method == "euler"
FDEInt->>CaputoEuler: construct CaputoEuler(...)
else method == "l1"
FDEInt->>CaputoL1Schema: construct CaputoL1Schema(...)
end
FDEInt-->>User: return chosen integrator
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fresh review of
brainpy/integratorsfractional/partial integrators.CaputoEuler.resetreplaced itsf_statesVariables with plain Arrays → state desync → wrong results after reset underIntegratorRunner(0.911 vs correct 0.380). Now stored in abm.VarDictso reset updates in place.fdeint(method='l1')literal default madeset_default_fdeinta no-op for default-method calls; defaultmethod=Noneso the global fallback applies.Core solver numerics (CaputoEuler/L1/GL) validated against reference recurrences; prior-audit FDE bugs (C-08, H-30/31/32) verified already-fixed. In-scope: 5 passed. Findings:
docs/issues-found-20260619-integrators-fde-pde.md.Summary by Sourcery
Fix fractional integrator state handling and default method selection for FDE solvers.
Bug Fixes:
Documentation:
Tests: