> This page is for version 0.7.0 · 26.10.
> For other versions, use one of these documentation indexes:
> - Nightly (default): https://docs.nvidia.com/nemo/automodel/nightly/llms.txt
> - Latest: https://docs.nvidia.com/nemo/automodel/latest/llms.txt
> - 0.7.0 · 26.10: https://docs.nvidia.com/nemo/automodel/v0.7/llms.txt
> - 0.5.0 · 26.06: https://docs.nvidia.com/nemo/automodel/v0.5/llms.txt
> - 0.4.0 · 26.04: https://docs.nvidia.com/nemo/automodel/v0.4/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/automodel/llms.txt.

# nemo_automodel.components.models.muse_spark.flops

Useful model FLOPs for Muse Spark Open text training.

## Module Contents

### Functions

| Name                                                                            | Description                                                                                          |
| ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| [`model_flops`](#nemo_automodel-components-models-muse_spark-flops-model_flops) | Count useful GEMM FLOPs for one optimizer step of text-only full-parameter Muse Spark Open training. |

### API

```python
nemo_automodel.components.models.muse_spark.flops.model_flops(
    config: nemo_automodel.components.models.muse_spark.config.MuseSpark1xOmniConfig,
    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`** `int` — default: 1

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

---

**`seq_len`** `int | None` — default: 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.