nemo_automodel.components.models.ling_v2
nemo_automodel.components.models.ling_v2
Submodules
nemo_automodel.components.models.ling_v2.confignemo_automodel.components.models.ling_v2.layersnemo_automodel.components.models.ling_v2.modelnemo_automodel.components.models.ling_v2.state_dict_adapter
Package Contents
Classes
API
Bases: PretrainedConfig
Configuration class for the BailingMoeV2 model (Ling 2.0).
The defaults reflect the Ling-mini-2.0 (16B-A1.4B) variant. Larger
variants (Ling-flash-2.0 100B-A6B and Ling-1T 1T-A50B) override
sizing knobs but share the same architecture: GQA attention with per-head
QK-RMSNorm, partial RoPE, sigmoid-routed grouped MoE with shared experts,
and first_k_dense_replace dense MLP layers at the start.
Bases: HFCheckpointingMixin, Module, MoEFSDPSyncMixin
Causal-LM head wrapping BailingMoeV2Model.
Run the decoder and project the kept positions to vocabulary logits.
Parameters:
Token IDs of shape [batch, sequence], or packed (THD) IDs of shape [1, tokens], which the decoder squeezes to [tokens]. Later pipeline stages pass hidden states of shape [batch, sequence, hidden] or [1, tokens, hidden].
Optional positions of shape [batch, sequence], or [1, tokens] for packed input, which requires them.
Optional Tensor of shape [batch, sequence], 1 at valid tokens and 0 at padding, or, with SDPA and an explicit padding_mask, a dense mask of shape [batch, 1, sequence, sequence]; packed input ignores it.
Optional bool Tensor of shape [batch, sequence], or [1, tokens] when packed, true at padding; when None, the MoE layers derive it from attention_mask.
0 keeps every position, a positive int keeps the last N positions, and an integer
Tensor of shape [kept] keeps those positions.
Whether the output carries the final hidden states, which the fused
cross-entropy path needs; None reads config.output_hidden_states.
Backend metadata for the decoder. Packed input sets qkv_format="thd" and passes
int32 cu_seqlens and cu_seqlens_padded of shape [1, documents + 1], padded with -1000, and
max_seqlen.
Returns: CausalLMOutputWithPast
CausalLMOutputWithPast whose logits have shape [batch, kept, vocab], or [1, kept, vocab] for packed
Return parallelism capabilities for a specific Ling/Bailing-MoE config.
Three checkpoint variants share this class:
inclusionAI/Ling-1T— 1T-param MoE, requires PP. Demonstrated by examples/llm_finetune/ling/ling_1t_sft.yaml (pp=4) and ling_1t_lora_pp.yaml (pp=8); both with ep_size>=8.inclusionAI/Ling-flash-2.0— mid-size MoE, single-rank EP only. Demonstrated by ling_flash_2_0_sft.yaml / ling_flash_2_0_lora.yaml (pp=1, ep=8-32).inclusionAI/Ling-mini-2.0— small MoE, single-rank EP only. Demonstrated by ling_mini_2_0_{hellaswag,sft,squad}.yaml (pp=1, ep=4-8).
Dispatch is on num_hidden_layers since Ling-1T (~80 layers) is well separated from Ling-flash-2.0 (~32) and Ling-mini-2.0 (~20).