nemo_automodel.components.models.flint.layers
nemo_automodel.components.models.flint.layers
Flint’s sink-aware attention and shared dense/MoE decoder blocks.
Eager, SDPA and TE attention have distinct numerical validation scopes. Magi uses model-owned packed token plans and requires an upstream learned-sink training kernel. FP32 component parity does not establish full-model parity with the serving kernels’ BF16 rounding order.
Module Contents
Classes
Functions
API
Bases: Module
Separate Q/K/V, per-head RMSNorm, selective Neox RoPE and learned sinks.
Expose shared TE attention for CP discovery without a second state path.
Rotate corresponding channels in the two halves of each head.
Parameters:
Tensor [batch, sequence, heads, head_dim] or THD [tokens, heads, head_dim].
Integer tensor [batch, sequence] or [tokens] on values’ device.
Returns: torch.Tensor
Rotated tensor of shape [batch, sequence, heads, head_dim], in values’
Compute full-sequence causal attention with a zero-value sink category.
Parameters:
Floating projection-dtype tensor [batch, sequence, hidden_size], or [tokens, hidden_size] for explicit THD packing.
Optional integer tensor of shape [batch, sequence] or document-local [tokens] for THD; contiguous zero-based positions are used by default.
Optional binary tensor of shape [batch, sequence], with one/True for valid tokens. Both padded queries and keys are excluded from real attention; the sink remains valid. TE BSHD supports trailing padding; arbitrary padding uses THD packing.
Shared TE THD boundaries, padding metadata and formats, model-owned Magi plan, or integer document_ids [batch, sequence] for the eager/SDPA block-diagonal mask.
Returns: torch.Tensor
Tensor of shape [batch, sequence, hidden_size] in the output
Initialize projections, head-normalization scales and trainable sinks.
Parameters:
Device context after any meta materialization.
Optional normal-initialization deviation for projections.
Bases: Module
Pre-norm attention and a dense or shared NeMo MoE, each with a residual.
Apply the block while preserving the shared MoE’s padding convention.
Parameters:
Residual tensor [batch, sequence, hidden_size] or THD [tokens, hidden_size]. Explicit residual_dtype preserves its chosen dtype while normalized branches use projection dtype.
Integer [batch, sequence] or document-local [tokens].
Optional binary [batch, sequence], with one for valid tokens; shared MoE instead receives True for padding.
Optional True-for-padding expert mask [batch, sequence] or THD [tokens], derived from real/padded document lengths.
Shared TE metadata or an immutable model-owned Magi plan retained across activation-checkpoint recomputation.
Returns: torch.Tensor
Residual tensor in the input layout and configured stream dtype. Padded-query outputs
Initialize every component without depending on a base checkpoint.
Parameters:
Device context after any meta materialization.
Optional normal-initialization deviation for projections/experts.
Bases: Module
Own the trainable FP32 denominator logits in a separate dtype unit.
Return unscaled sink logits through the module’s normal call path.
Returns: torch.Tensor
FP32 tensor of shape [query_heads], with independent storage and
Reject backend choices outside the supported native component contract.
Parameters:
Shared backend settings, preserved without mutation.