nemo_automodel.components.models.beam
nemo_automodel.components.models.beam
Submodules
nemo_automodel.components.models.beam.layersnemo_automodel.components.models.beam.modelnemo_automodel.components.models.beam.parallelizationnemo_automodel.components.models.beam.state_dict_adapternemo_automodel.components.models.beam.tokenization
Package Contents
Classes
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: Qwen3MoeStateDictAdapter
Converts between Hugging Face Beam checkpoints and the grouped-experts native format.
Beam stores its experts exactly like Qwen3-MoE, so the Qwen3-MoE conversion (including fused PEFT v5
ParamWrapper LoRA export/import and low-memory DCP loading) applies unchanged. The native module tree
mirrors the HF one, so every tensor outside the experts keeps its HF name and passes through unchanged
(attention projections and gate_bias, q/k norms, the four per-layer norms, the dense MLP,
mlp.gate.weight and the mlp.gate.e_score_correction_bias buffer, embeddings, final norm,
lm_head). Experts differ:
HF checkpoint (per expert, the qwen2_moe conversion mapping)::
model.layers.{L}.mlp.experts.{E}.gate_proj.weight [moe_inter_dim, hidden] model.layers.{L}.mlp.experts.{E}.up_proj.weight [moe_inter_dim, hidden] model.layers.{L}.mlp.experts.{E}.down_proj.weight [hidden, moe_inter_dim]
Native (grouped)::
model.layers.{L}.mlp.experts.gate_and_up_projs [n_experts, hidden, 2 * moe_inter_dim] model.layers.{L}.mlp.experts.down_projs [n_experts, moe_inter_dim, hidden]
to_hf therefore writes the per-expert layout that transformers itself produces with
save_pretrained, not the stacked in-memory layout.