nemo_automodel.components.models.muse_spark.flops
nemo_automodel.components.models.muse_spark.flops
Useful model FLOPs for Muse Spark Open text training.
Module Contents
Functions
API
Count useful GEMM FLOPs for one optimizer step of text-only full-parameter Muse Spark Open training.
A multiply-accumulate (MAC) is two FLOPs. Every counted product is trainable, so it counts the forward pass, the input gradient and the weight gradient (six FLOPs per MAC); attention counts the same three passes over its two operands. Per layer and token:
q_proj,o_gate_projando_proj:hidden * heads * head_dimeach.k_projandv_proj:hidden * kv_heads * head_dimeach.- Attention:
heads * 2 * head_dimper permitted query-key pair (QK^TandPV; grouped keys and values are repeated to every query head). A full layer permits theS * (S + 1) / 2causal pairs. A sliding window includes the query itself, so the query at one-based positionpattendsmin(p, window)keys. - MoE: the pooler and the unpooler,
hidden * expert_hiddeneach; the router,hidden * experts; andtop-krouted SwiGLU experts of3 * expert_hidden * moe_intermediate. There is no shared expert.
The LM head adds hidden * vocab per token; the embedding lookup has no GEMM.
Counted work is the algorithmic model FLOPs (MFU), independent of the backend: a
dense attention kernel also executes the masked pairs, and a benchmark that sets
fake_balanced_gate skips the router GEMM, which a config cannot see. Elementwise
operations (RMS norms, RoPE and its angle table, the sigmoid output gate, residual
gates, SwiGLU, the logit soft cap, softmax, top-k), activation recomputation,
padding, optimizer updates and communication are excluded. The vision and audio
towers do no work for text input 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 Muse Spark Open configuration, in the native or the release schema.
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.