pub struct StateKnockoutSpec {
pub positions: Vec<usize>,
pub layers: LayerSpec,
}Expand description
Specification for RWKV-6 state knockout intervention.
State knockout makes specific token positions invisible to all future tokens by skipping the recurrent state update at those positions. This is the RNN analogue of all-edge attention knockout in transformers.
Fields§
§positions: Vec<usize>Token positions where state update is skipped.
layers: LayerSpecWhich layers to apply knockout.
Implementations§
Source§impl StateKnockoutSpec
impl StateKnockoutSpec
Sourcepub fn layer_range(self, start: usize, end: usize) -> Self
pub fn layer_range(self, start: usize, end: usize) -> Self
Target a range of layers (inclusive).
Sourcepub fn applies_to_layer(&self, layer: usize) -> bool
pub fn applies_to_layer(&self, layer: usize) -> bool
Check if knockout applies to this layer.
Sourcepub fn position_set(&self) -> HashSet<usize>
pub fn position_set(&self) -> HashSet<usize>
Get knockout positions as a HashSet for O(1) lookup in the WKV loop.
Trait Implementations§
Source§impl Clone for StateKnockoutSpec
impl Clone for StateKnockoutSpec
Source§fn clone(&self) -> StateKnockoutSpec
fn clone(&self) -> StateKnockoutSpec
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StateKnockoutSpec
impl Debug for StateKnockoutSpec
Auto Trait Implementations§
impl Freeze for StateKnockoutSpec
impl RefUnwindSafe for StateKnockoutSpec
impl Send for StateKnockoutSpec
impl Sync for StateKnockoutSpec
impl Unpin for StateKnockoutSpec
impl UnsafeUnpin for StateKnockoutSpec
impl UnwindSafe for StateKnockoutSpec
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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