nemo_automodel.components.models.glm_moe_dsa.flops
nemo_automodel.components.models.glm_moe_dsa.flops
Useful model FLOPs for GLM MoE DSA (GLM-5.x) training.
Module Contents
Functions
API
Sum over one-based query positions of min(position, cap).
Mirror Block.__init__: only IndexShare "shared" layers own no indexer.
Mirror Block.__init__: mlp_layer_types wins, else the first first_k_dense_replace layers are dense.
Count useful GEMM FLOPs for one optimizer step of full-parameter GLM MoE DSA training.
The MLA projections, the dense MLPs, the active routed and shared experts, the router
and the LM head count forward and backward (6 FLOPs per MAC). Sparse attention counts
the unabsorbed MLA form over the keys a causal query can select: one-based position
i attends to min(i, index_topk) keys. The indexer exists only on
indexer_types == "full" layers and receives no gradient (its top-k selection is
discrete and its scores feed nothing else), so its projections and causal score GEMM
count forward only (2 FLOPs per MAC); IndexShare "shared" layers reuse the previous
selection at no indexer cost. The AutoModel GLM model has no MTP module, so
num_nextn_predict_layers adds nothing.
Counts assume one unpadded document per sequence. Activation recomputation, the extra latent-width work of the absorbed sparse kernels, norms, RoPE, softmax, the top-k selection, communication and optimizer updates are excluded, as in the other MFU formulas.
Parameters:
GLM MoE DSA configuration.
Sequences per global optimizer step.
Tokens per sequence; defaults to max_position_embeddings.
Returns: float
Model FLOPs across all devices for one optimizer step.
Raises:
ValueError:gbs, the sequence length orindex_topkis not positive.