Skip to navigation

nemo_automodel.components.models.muse_spark.flops

View as MarkdownOpen in Claude

Useful model FLOPs for Muse Spark Open text training.

Module Contents

Functions

NameDescription
model_flopsCount useful GEMM FLOPs for one optimizer step of text-only full-parameter Muse Spark Open training.

API

nemo_automodel.components.models.muse_spark.flops.model_flops(
gbs: int = 1,
seq_len: int | None = None
) -> float

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_proj and o_proj: hidden * heads * head_dim each.
  • k_proj and v_proj: hidden * kv_heads * head_dim each.
  • Attention: heads * 2 * head_dim per permitted query-key pair (QK^T and PV; grouped keys and values are repeated to every query head). A full layer permits the S * (S + 1) / 2 causal pairs. A sliding window includes the query itself, so the query at one-based position p attends min(p, window) keys.
  • MoE: the pooler and the unpooler, hidden * expert_hidden each; the router, hidden * experts; and top-k routed SwiGLU experts of 3 * 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:

config
MuseSpark1xOmniConfig

Effective Muse Spark Open configuration, in the native or the release schema.

gbs
intDefaults to 1

Number of full-length sequences in the global optimizer step.

seq_len
int | NoneDefaults to None

Tokens in each sequence; defaults to max_position_embeddings.

Returns: float

Useful model FLOPs over all devices for one optimizer step.

Raises:

  • ValueError: gbs or seq_len is not positive.