nemo_automodel.components.models.mistral_large4.flops
nemo_automodel.components.models.mistral_large4.flops
Module Contents
Functions
API
Count useful GEMM FLOPs for text-only full-parameter training of Mistral Large 4.
Trainable projections and attention count forward, input gradients and weight
gradients (six FLOPs per MAC). The DSA indexer is a frozen hard selector, so it
runs only on full layers and counts forward only (two FLOPs per MAC):
its projections plus scores over the causal keys. Per layer:
q_proj:hidden * heads * head_dim(no Q low-rank path).kv_a:hidden * (kv_lora_rank + rope_dim)on layers that own their KV only; NoPE layers have no rope part and layers that share KV have nokv_a.kv_b:kv_lora_rank * heads * (nope_dim + v_head_dim)on every layer, withnope_dim = head_dimon NoPE layers andqk_nope_head_dimotherwise.o_proj:heads * v_head_dim * hidden.- Attention:
pairs * heads * (head_dim + v_head_dim)MACs, where a query at positionpattendsmin(p + 1, index_topk)keys (exact, notS * topk). - FFN: layers below
first_k_dense_replaceare dense SwiGLU; the others runnum_experts_per_tokrouted experts andn_shared_expertsshared experts ofmoe_intermediate_sizeplus the router. - LM head:
hidden * vocab(the embedding lookup has no GEMM).
Counted work is the algorithmic model FLOPs (MFU), independent of the attention backend: the absorbed TileLang kernel and dense SDPA execute different amounts of work. Activation recomputation, padding, elementwise operations (norms, SSMax, LeRoPE, softcap, softmax, top-k), optimizer updates and communication are excluded. Vision and the draft head are not executed by the causal LM and are excluded.
Each sequence is one document without padding. Packed-document FLOPs need the individual document lengths and cannot be inferred from a packed row length.
Parameters:
Effective Mistral Large 4 configuration.
Number of full-length sequences in the global optimizer step.
Tokens in each sequence; defaults to max_position_embeddings.
Returns: float
Useful model FLOPs over all devices for one optimizer step.
Raises:
ValueError:gbsorseq_lenis not positive.