pub enum CausalAlignment {
BottomRight,
TopLeft,
}Expand description
Anchor of the causal diagonal for AttentionModuleOptions::is_causal.
Query i may attend key j iff j <= i + offset, where offset is 0 for
TopLeft and seq_k - seq_q for BottomRight.
Variants§
BottomRight
The last query row sees every key: offset = seq_k - seq_q. This is the
KV-cache convention (the queries are the newest seq_q positions), used by
FlashAttention 2.1+ and by ONNX Attention when a past_key is supplied.
TopLeft
The first query row sees the first key: offset = 0 (tril on [seq_q, seq_k]).
This is PyTorch’s scaled_dot_product_attention(is_causal=True) and ONNX
Attention without a KV cache.
Implementations§
Trait Implementations§
Source§impl Clone for CausalAlignment
impl Clone for CausalAlignment
impl Copy for CausalAlignment
Source§impl Debug for CausalAlignment
impl Debug for CausalAlignment
Source§impl Default for CausalAlignment
impl Default for CausalAlignment
Source§impl<'de> Deserialize<'de> for CausalAlignment
impl<'de> Deserialize<'de> for CausalAlignment
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for CausalAlignment
Source§impl Hash for CausalAlignment
impl Hash for CausalAlignment
Source§impl PartialEq for CausalAlignment
impl PartialEq for CausalAlignment
Source§impl Serialize for CausalAlignment
impl Serialize for CausalAlignment
impl StructuralPartialEq for CausalAlignment
Auto Trait Implementations§
impl Freeze for CausalAlignment
impl RefUnwindSafe for CausalAlignment
impl Send for CausalAlignment
impl Sync for CausalAlignment
impl Unpin for CausalAlignment
impl UnsafeUnpin for CausalAlignment
impl UnwindSafe for CausalAlignment
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.