nemo_automodel.components.models.praxis.layers
nemo_automodel.components.models.praxis.layers
Transformer layers shared by the two towers of the Praxis video backbone.
Every block is pre-norm with a zero-centred RMSNorm (scale 1 + weight), gated
grouped-query attention over integer rotary positions, and either a dense SwiGLU or an
Automodel MoE feed-forward. The decoder
tower modulates each block input with a per-token shift and scale from the encoder.
Norms, rotary rotation, modulation and the router run in float32; everything else in the parameter dtype (bf16 in the released checkpoint).
Module Contents
Classes
Functions
Data
API
Bases: Module
Grouped-query attention with a sigmoid output gate per head.
Order: project, rotate q and k, RMS-normalize q and k per head, attend, gate, project out.
Attend within one sequence.
Parameters:
Tensor of shape [batch, tokens, hidden].
Float32 rotary table of shape [batch, tokens, head_dim // 2, 2].
A flex BlockMask over [tokens, tokens], a boolean tensor of shape
[tokens, tokens] (true where attention is allowed), or None for full attention.
Returns: Tensor
Tensor of shape [batch, tokens, hidden].
Bases: Module
Rotary (cos, sin) table for large integer positions.
Only the first effective_dim // 2 frequency pairs rotate; the remaining pairs have
zero frequency. A position p is split as p = high * table_size + low and the
angle of each part is formed in float64 so that positions in the millions keep their
precision; the two parts are combined with the angle-sum identity.
Build the rotary table.
Parameters:
Integer tensor of shape [batch, tokens].
Returns: Tensor
Float32 tensor of shape [batch, tokens, dim // 2, 2] holding (cos, sin) per pair.
Per-pair frequencies of shape [dim // 2] in float32 on device (zero beyond effective_dim).
Bases: Module
Pre-norm block x + attn(norm(x) * s), x + ffn(norm(x) * s) with s = 1 / sqrt(layer_index).
s is a persistent buffer so the checkpoint value (rounded to the parameter dtype) is used.
Expose the feed-forward sub-block (ffn) under the name the shared MoE parallelizer looks up.
Run the block.
Parameters:
Tensor of shape [batch, tokens, hidden].
Float32 rotary table of shape [batch, tokens, head_dim // 2, 2].
Attention mask (see GatedAttention.forward).
Per-token conditioning of shape [batch, tokens, modulation_dim] when the block
has a modulator, else None.
Returns: Tensor
Tensor of shape [batch, tokens, hidden].
Bases: Module
A stack of TransformerBlock sharing one rotary table.
Blocks listed in dense_blocks use a dense SwiGLU; the others an Automodel MoE.
Run every block and collect the tap outputs.
Parameters:
Tensor of shape [batch, tokens, hidden].
Integer tensor of shape [batch, tokens] with the rotary positions.
Attention mask (see GatedAttention.forward).
Per-token conditioning of shape [batch, tokens, modulation_dim], or None.
Indices of the blocks whose outputs are returned.
Returns: Tensor
The output of shape [batch, tokens, hidden] and the tap outputs, each of shape
Bases: Module
RMSNorm whose scale is 1 + weight; cast_dtype selects the compute dtype.
Normalize over the last axis.
Parameters:
Tensor of shape […, hidden].
Returns: Tensor
Tensor of shape […, hidden] in the dtype of x.
Rotate x with a rotary table in float32 (rotate-half layout).
Parameters:
Tensor of shape [batch, heads, tokens, head_dim]; channel j pairs with j + head_dim // 2.
Float32 tensor of shape [batch, tokens, head_dim // 2, 2] from IntegerRotaryEmbedding.
Returns: Tensor
Tensor of shape [batch, heads, tokens, head_dim] in the dtype of x.
MoE settings of the Praxis trunk: fp32 sigmoid router with a selection bias, one shared expert.
The routed sum is scaled by routed_scaling_factor and the top-k scores are
renormalized to sum to one, as in DeepSeek-V3.
Return x * scale + shift in the dtype of x.
Parameters:
Tensor of shape [batch, tokens, hidden].
Tensor broadcastable to x.
Tensor broadcastable to x.
"mixed" and "float32" compute in float32, "bfloat16" in bf16.
Returns: Tensor
Tensor of shape [batch, tokens, hidden] in the dtype of x.