pub struct RecurrentPassSpec {
pub loop_start: usize,
pub loop_end: usize,
pub feedback: Vec<RecurrentFeedbackEntry>,
pub sustained: bool,
pub depth: usize,
}Expand description
Specification for a recurrent multi-pass forward through a layer block.
The recurrence re-runs layers loop_start..=loop_end a total of depth
times, with optional feedback injected into the hidden state between
passes.
§Without feedback
Each subsequent pass receives the previous pass’s output (true recurrence — extra depth).
§With feedback
Each subsequent pass resets to the saved pre-loop hidden state plus
feedback vectors: hidden[position] += strength * vector.
This means every recurrent pass sees the same clean input with the
nudge applied — the layers process H₀ + nudge rather than
iterating on their own output, which would cause degeneration.
Fields§
§loop_start: usizeFirst layer of the recurrent block (inclusive).
loop_end: usizeLast layer of the recurrent block (inclusive).
feedback: Vec<RecurrentFeedbackEntry>Feedback vectors to inject between passes.
When present, each recurrent pass resets to the saved pre-loop state and injects these vectors before re-running the loop layers. If empty, each pass receives the previous pass’s output unmodified (pure depth increase).
sustained: boolIf true, also inject feedback at the current last token position during each autoregressive generation step (sustained recurrence).
If false, feedback is only injected at the original prompt positions (prefill-only recurrence).
depth: usizeNumber of times to run the recurrent layer block.
Must be at least 1 (a single pass, no recurrence). The default is 2 (one initial pass plus one recurrent pass with feedback injection).
Implementations§
Source§impl RecurrentPassSpec
impl RecurrentPassSpec
Sourcepub const fn no_feedback(loop_start: usize, loop_end: usize) -> Self
pub const fn no_feedback(loop_start: usize, loop_end: usize) -> Self
Create a spec with no feedback (pure double-pass, depth 2).
Sourcepub const fn with_sustained(self, sustained: bool) -> Self
pub const fn with_sustained(self, sustained: bool) -> Self
Set the sustained flag (builder pattern).
Sourcepub const fn with_depth(self, depth: usize) -> Self
pub const fn with_depth(self, depth: usize) -> Self
Set the recurrence depth (builder pattern).
depth is the total number of times the recurrent layer block is
executed. The default is 2 (one initial pass plus one recurrent
pass). A depth of 1 means no recurrence (single pass).
Sourcepub fn add_feedback(&mut self, position: usize, vector: Tensor, strength: f32)
pub fn add_feedback(&mut self, position: usize, vector: Tensor, strength: f32)
Add a feedback entry.
Trait Implementations§
Source§impl Clone for RecurrentPassSpec
impl Clone for RecurrentPassSpec
Source§fn clone(&self) -> RecurrentPassSpec
fn clone(&self) -> RecurrentPassSpec
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for RecurrentPassSpec
impl !RefUnwindSafe for RecurrentPassSpec
impl Send for RecurrentPassSpec
impl Sync for RecurrentPassSpec
impl Unpin for RecurrentPassSpec
impl UnsafeUnpin for RecurrentPassSpec
impl !UnwindSafe for RecurrentPassSpec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more