pub struct SlidingWindow {
pub window: usize,
pub chunk: usize,
pub pattern: Option<usize>,
}Expand description
Sliding-window attention, which caps how many positions a layer ever keeps.
Fields§
§window: usizePositions a query may attend back over.
chunk: usizePrefill chunk size. A chunk of chunk tokens is processed
against one cache state, so the first token of the chunk still
needs its whole window live while the last one is being
processed: window + chunk - 1 positions, not window.
pattern: Option<usize>Gemma 2+/3 alternating pattern (ModelConfig::swa_pattern):
layer il is sliding iff (il + 1) % period != 0, so every
period-th layer keeps the full context. None means every
layer slides.
Implementations§
Source§impl SlidingWindow
impl SlidingWindow
Sourcepub fn resident_positions(&self, tokens: usize) -> usize
pub fn resident_positions(&self, tokens: usize) -> usize
Positions a sliding layer keeps once the sequence is long enough to saturate it.
Trait Implementations§
Source§impl Clone for SlidingWindow
impl Clone for SlidingWindow
Source§fn clone(&self) -> SlidingWindow
fn clone(&self) -> SlidingWindow
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for SlidingWindow
Source§impl Debug for SlidingWindow
impl Debug for SlidingWindow
impl Eq for SlidingWindow
Source§impl PartialEq for SlidingWindow
impl PartialEq for SlidingWindow
impl StructuralPartialEq for SlidingWindow
Auto Trait Implementations§
impl Freeze for SlidingWindow
impl RefUnwindSafe for SlidingWindow
impl Send for SlidingWindow
impl Sync for SlidingWindow
impl Unpin for SlidingWindow
impl UnsafeUnpin for SlidingWindow
impl UnwindSafe for SlidingWindow
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> 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