fix(dyn/rates): RNN cell reset_state crash + ThresholdLinearModel noise dt-scaling#850
Merged
Merged
Conversation
…odel noise dt-scaling - RNNCell/GRUCell/LSTMCell.reset_state() crashed (ValueError) in default bp.reset_state usage; build state via variable() not parameter((None,...)) (High) - ThresholdLinearModel scaled its Euler-Maruyama noise by dt instead of sqrt(dt), making the noise intensity dt-dependent (Medium) Findings recorded in docs/issues-found-20260619-dyn-rates-base.md
Reviewer's GuideFixes a crash in RNN-style rate cells when resetting state by constructing state via mode-aware variables instead of parameters, and corrects the stochastic update of ThresholdLinearModel so its noise term scales as sqrt(dt) rather than dt, with new regression tests and an audit doc recording other findings. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The new
TestThresholdLinearModelNoisetests rely on large Monte Carlo samples and a relatively tightdeltafor a stochastic ratio; consider either reducing the sample size and/or relaxing the tolerance or structuring the test to avoid randomness to reduce the risk of slow or flaky behavior across platforms and JAX backends.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `TestThresholdLinearModelNoise` tests rely on large Monte Carlo samples and a relatively tight `delta` for a stochastic ratio; consider either reducing the sample size and/or relaxing the tolerance or structuring the test to avoid randomness to reduce the risk of slow or flaky behavior across platforms and JAX backends.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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/dyn/{rates,outs,others}+ dyn base/utils.RNNCell/GRUCell/LSTMCell.reset_state()crashed (ValueError) in default usage; state now built viavariable()instead ofparameter((None, ...)).ThresholdLinearModelscaled Euler-Maruyama noise bydtinstead ofsqrt(dt)(dt-dependent noise intensity).Prior-audit rate/oscillator/noise bugs (StuartLandau coupling, etc.) verified already-fixed. In-scope: 118 passed. Findings:
docs/issues-found-20260619-dyn-rates-base.md.Summary by Sourcery
Fix RNN cell state resetting and correct ThresholdLinearModel noise scaling in the dyn/rates module.
Bug Fixes:
Documentation:
Tests: