nemo_automodel.components.models.glm4_moe.layers

View as Markdown

Module Contents

Classes

NameDescription
Glm4MoeAttentionGLM4 MoE attention with optional query/key per-head RMSNorm + partial RoPE.

API

class nemo_automodel.components.models.glm4_moe.layers.Glm4MoeAttention(
config: transformers.models.glm4_moe.configuration_glm4_moe.Glm4MoeConfig,
backend: nemo_automodel.components.models.common.BackendConfig
)

Bases: Module

GLM4 MoE attention with optional query/key per-head RMSNorm + partial RoPE.

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