pub struct AttentionSpec {Show 15 fields
pub q: Symbol,
pub kc: Symbol,
pub vc: Symbol,
pub out: Symbol,
pub h: usize,
pub kv: usize,
pub hd: usize,
pub vd: usize,
pub scale: Option<Factor>,
pub softcap: Option<Factor>,
pub l: usize,
pub pos: Option<RowIndex>,
pub rows: usize,
pub window: Option<Window>,
pub sinks: Option<Symbol>,
}Expand description
ctx = attention(q over kc, vc) — single-query multi-head GQA attention: q is 1 × (h·hd), kc is l × (kv·hd)
and vc l × (kv·vd) (the cached keys/values), query head g attends to kv head g / (h/kv) and writes vd
values. pos is the position bound of the masked up to P form (the KV cache as carried state); None is the
unmasked form that attends to every cached row.
Fields§
§q: Symbol§kc: Symbol§vc: Symbol§out: Symbol§h: usize§kv: usize§hd: usize§vd: usizeThe value head width: hd, or narrower (V holding kv·vd columns).
scale: Option<Factor>The score scale a program gives (scaled by S); None is the default 1/√hd, which a given scale equal to
it also lifts as.
softcap: Option<Factor>The capped at C form’s C: every scaled score s taken as C·tanh(s/C) before the softmax (Gemma 2).
l: usize§pos: Option<RowIndex>The masked up to P form’s bound: attend over the first P of the l cached positions. For a block of rows
query rows (causal attention … from P) it is the FIRST row’s: row r (0-based) attends P + r positions.
rows: usizeQuery rows: 1 for the single-query form, T for a causal block.
window: Option<Window>The positions a query keeps of the n it attends: the last W (within a window of W), or those of its own chunk
of C (within chunks of C).
sinks: Option<Symbol>The with sinks S form’s S: a logit per query head joining its softmax, taking no value.
Trait Implementations§
Source§impl Clone for AttentionSpec
impl Clone for AttentionSpec
Source§fn clone(&self) -> AttentionSpec
fn clone(&self) -> AttentionSpec
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AttentionSpec
impl Debug for AttentionSpec
Source§impl PartialEq for AttentionSpec
impl PartialEq for AttentionSpec
impl Eq for AttentionSpec
impl StructuralPartialEq for AttentionSpec
Auto Trait Implementations§
impl Freeze for AttentionSpec
impl RefUnwindSafe for AttentionSpec
impl Send for AttentionSpec
impl Sync for AttentionSpec
impl Unpin for AttentionSpec
impl UnsafeUnpin for AttentionSpec
impl UnwindSafe for AttentionSpec
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,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.