nemo_automodel.components.models.inkling2.flex_attention
nemo_automodel.components.models.inkling2.flex_attention
Compiled learned-relative GQA, with differentiable per-query attention sinks.
Module Contents
Classes
API
Bases: Module
Own compiled callables, with masks rebuilt from each forward’s token validity.
Relative profiles have shape [batch, heads, sequence, relative_extent]; no sequence-by-sequence score/bias tensor is constructed. The Triton backend supports gradients to captured profiles and returned log-sum-exp values.
Compute content plus learned relative attention, including its sink.
Parameters:
Query tensor of shape [batch, sequence, heads, head_dim].
Key tensor of shape [batch, key_sequence, kv_heads, head_dim].
Value tensor of shape [batch, key_sequence, kv_heads, head_dim].
Relative logits of shape [batch, heads, sequence, relative_extent]. Retains the projection’s FP32/BF16 rounding boundary.
Sink logits of shape [batch, sequence, heads].
Boolean tensor of shape [batch, sequence]. Each batch row has a local slice of one global contiguous real-token span.
Boolean [batch, key_sequence] validity, global under CP; defaults to valid for CP1. Global real-token positions are consecutive.
Logical query positions [batch, sequence], reset per document.
Logical key positions [batch, key_sequence], global under CP.
First local query’s global token column, zero without CP.
Returns: torch.Tensor
FP32 tensor of shape [batch, sequence, heads, head_dim]. Inputs remain