nemo_automodel.components.models.hy_mt2.layers

View as Markdown

Module Contents

Classes

NameDescription
HyMT2AttentionHy-MT2-30B-A3B attention: GQA, per-head Q/K RMSNorm, and RoPE.

API

class nemo_automodel.components.models.hy_mt2.layers.HyMT2Attention(
config: typing.Any,
backend: nemo_automodel.components.models.common.BackendConfig
)

Bases: Module

Hy-MT2-30B-A3B attention: GQA, per-head Q/K RMSNorm, and RoPE.

Differences vs. the existing Hy3-preview HYV3Attention:

  • qk_norm is gated by config.qk_norm (defaults to True). For Hy-MT2-30B-A3B this is always True; the flag is here so the same module can also be reused for non-qk-norm variants without code edits.
  • Dimensions follow Hy-MT2-30B-A3B: 32 Q heads / 4 KV heads, head_dim=128, hidden_size=2048.
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
qk_norm_enabled
= bool(getattr(config, 'qk_norm', True))
v_proj
nemo_automodel.components.models.hy_mt2.layers.HyMT2Attention.forward(
x: torch.Tensor,
freqs_cis: torch.Tensor,
attention_mask: torch.Tensor | None = None,
attn_kwargs: typing.Any = {}
) -> torch.Tensor
nemo_automodel.components.models.hy_mt2.layers.HyMT2Attention.init_weights(
buffer_device: torch.device,
init_std: float = 0.02
)