nemo_automodel.components.models.beam.model
nemo_automodel.components.models.beam.model
Native Beam decoder: gated attention, RoPE/NoPE with root10 SSMax, sandwich norms, depth-scaled residuals, dense/MoE SwiGLU, and soft-capped logits. The module tree preserves HF names; BeamStateDictAdapter converts the grouped expert weights.
Module Contents
Classes
Functions
Data
API
Bases: HFCheckpointingMixin, Module, MoEFSDPSyncMixin
Beam causal LM on Automodel’s MoE stack (see module docstring).
Return soft-capped logits or pipeline-stage hidden states.
Parameters:
Integer tensor [batch, sequence] or packed [tokens]; later PP stages receive floating hidden states with an extra final hidden axis. Positions are local under CP.
Optional integer tensor [batch, sequence] or [tokens], absolute within each document.
Optional [batch, sequence] bool/0-1 mask; True/1 means valid. None on flex.
Optional bool tensor matching the position axes; True skips routing.
Zero for all positions, a positive final-position count, or integer tensor [selected_positions] indexing the sequence axis.
Whether to return the final hidden states.
Backend metadata: qkv_format (bshd/thd), integer cu_seqlens and cu_seqlens_padded [documents + 1], scalar max_seqlen, cp_size and cp_rank.
Returns: CausalLMOutputWithPast
logits [batch, selected_sequence, vocab] or packed
Construct the native model from an HF BeamConfig and optional backend/MoE overrides.
Construct from the checkpoint’s config; framework checkpoint loading supplies the weights.
Return this stage’s embedding module, or None when another stage owns it.
Return this stage’s LM head, or None when another stage owns it.
Initialize weights and cast to dtype while preserving original FP32 router values.
Replace this stage’s embedding module; None marks a later pipeline stage.
Replace this stage’s LM head; None marks a non-final pipeline stage.
Bases: Module
Embedding, decoder layers and final norm (the model. subtree of the HF checkpoint).
Run this pipeline stage with one shared FP32 RoPE-table pair per layer type.
Parameters:
Integer tensor [batch, sequence] or packed [tokens]; later PP stages receive floating hidden states with an extra final hidden axis. Positions are local under CP.
Optional integer tensor [batch, sequence] or [tokens], absolute within each document.
Optional [batch, sequence] bool/0-1 mask; True/1 means valid. None on flex.
Optional bool tensor matching the position axes; True skips routing.
Backend metadata: qkv_format (bshd/thd), integer cu_seqlens and cu_seqlens_padded [documents + 1], scalar max_seqlen, cp_size and cp_rank.
Returns: torch.Tensor
Hidden states [batch, sequence, hidden] or [tokens, hidden], local under CP,
Initialize this stage’s parameters and select the rotary-buffer device.
Map Beam’s sigmoid/grouped-top-k router and SwiGLU experts to MoEConfig.
Correction bias affects selection only and is never updated. Router storage and compute remain fp32. Automodel applies routed_scaling_factor to routing weights; HF applies it after expert aggregation, differing only in rounding.
Default router compute to fp32 and reject lower precision to preserve HF expert selection.