nemo_automodel.components.models.ling_v2.layers

View as Markdown

Attention layer for BailingMoeV2 (Ling 2.0).

GQA + per-head QK-RMSNorm + partial RoPE. Equivalent to Qwen3-MoE attention with an additional partial_rotary_factor knob that rotates only the first head_dim * partial_rotary_factor channels and passes the rest through (GPT-J / GPT-NeoX half-RoPE).

Module Contents

Classes

NameDescription
BailingMoeV2AttentionBailing MoE V2 attention block.

API

class nemo_automodel.components.models.ling_v2.layers.BailingMoeV2Attention(
config,
backend: nemo_automodel.components.models.common.BackendConfig
)

Bases: Module

Bailing MoE V2 attention block.

head_dim
k_norm
k_proj
num_heads
= config.num_attention_heads
num_kv_heads
= config.num_key_value_heads
o_proj
q_norm
q_proj
use_qk_norm
= bool(getattr(config, 'use_qk_norm', False))
v_proj
nemo_automodel.components.models.ling_v2.layers.BailingMoeV2Attention.forward(
x: torch.Tensor,
freqs_cis: torch.Tensor,
attention_mask: torch.Tensor | None = None,
attn_kwargs: typing.Any = {}
) -> torch.Tensor
nemo_automodel.components.models.ling_v2.layers.BailingMoeV2Attention.init_weights(
buffer_device: torch.device,
init_std: float = 0.02
) -> None