Skip to content

fix: ngrc rmn resetcarry - #562

Open
MartinuzziFrancesco wants to merge 5 commits into
masterfrom
fm/fix-ngrc-rmn-resetcarry
Open

MartinuzziFrancesco wants to merge 5 commits into
masterfrom
fm/fix-ngrc-rmn-resetcarry

Conversation

@MartinuzziFrancesco

@MartinuzziFrancesco MartinuzziFrancesco commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

Additional context

Add any other context about the problem here.

MartinuzziFrancesco and others added 5 commits October 14, 2026 10:16
…ps multi-state carries

NGRC's resetcarry! warned that the model has no internal state and returned
the states unchanged, but the DelayLayer history and clock carry over from
train into predict. It now clears the history (rebuilt from init_delay on the
next call) or sets it to init_carry(rng, in_dims, num_delays), and restarts
the clock. Readout and state-modifier states are kept.

The generic resetcarry! built a one-state carry and read the cell's out_dims,
which broke RMNESN and RMNResESN (RMNCell holds a hidden and a memory state
and has no out_dims field). It now calls init_carry once per state, with sizes
from the existing carry or from __carry_dimensions(cell). The docstring now
names st′.reservoir.carry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
resetcarry! with an init_carry function threw a FieldError on ContinuousESN,
LSM and SciMLProblemReservoir models, which have no StatefulLayer. The carry is
now the ODE state vector: out_dims for ContinuousESN, length(prob.u0) in
eltype(prob.u0) for SciMLProblemReservoir, and for LSM init_carry sets the
membrane potentials with the rest of the state zero.

DelayLayer histories in input_delay, state_modifiers (also inside Extend and
ReservoirChain), DeepESN and DeepReservoir per-layer modifiers, and NGRC
modifiers survived resetcarry!, so the previous sequence leaked into the next
one. They are now cleared (init_carry=nothing) or set to
init_carry(rng, in_dims, num_delays), with the clock at zero.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since every LocalInformationFlow window replays from a cached start_states
and an input buffer, resetcarry! on LIFESN only replaced the carry, which the
windows ignore, so the next sequence continued as if no reset happened. The
generic resetcarry! and the DeepReservoir reset now clear the input buffer
and set start_states to the new carry: nothing re-samples both lazily, and an
init_carry function sets start_states to the same states as the carry.

The lazy initialization no longer stores the advanced rng copy, so a
re-initialization draws the same start_states and buffer as a fresh setup.
Every window starts from start_states, so a different random start would
change every output and no longer fit the trained readout. Runs without a
reset are unchanged.

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

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.

1 participant