pub struct AttentionModuleOptions {
pub scale: Option<f64>,
pub softcap: Option<f64>,
pub is_causal: bool,
pub causal_alignment: CausalAlignment,
}Expand description
Options for the attention module.
Fields§
§scale: Option<f64>Custom scale factor applied to QK^T. When None, defaults to 1/sqrt(head_dim).
softcap: Option<f64>Soft capping applied before softmax: softcap * tanh(scores / softcap).
Used by Gemma-2 and similar models. Must be positive when set.
is_causal: boolWhen true, applies causal (autoregressive) masking so that each query position
can only attend to key positions at or before it. This is more efficient than
passing an explicit lower-triangular bool mask because backends can use optimized
kernel paths (e.g. flash attention with causal mode).
When seq_q != seq_k, causal_alignment decides which
query row lines up with which key column.
causal_alignment: CausalAlignmentWhere the causal diagonal is anchored when seq_q != seq_k. Ignored unless
is_causal is set. Both alignments agree when seq_q == seq_k.
Options serialized before this field existed deserialize as
BottomRight, the alignment burn used until then.