> This page is for version Latest.
> 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.glm5_next.flops

Backend-independent training FLOPs for the GLM-5.3 text backbone.

## Module Contents

### Functions

| Name                                                                                   | Description                                                              |
| -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
| [`glm5_next_flops`](#nemo_automodel-components-models-glm5_next-flops-glm5_next_flops) | Count useful forward/backward FLOPs for unpadded, independent sequences. |

### API

```python
nemo_automodel.components.models.glm5_next.flops.glm5_next_flops(
    config: nemo_automodel.components.models.glm5_next.config.Glm5NextTextConfig,
    gbs: int = 1,
    seq_len: int | None = None
) -> float
```

Count useful forward/backward FLOPs for unpadded, independent sequences.

Trainable matrix products cost six FLOPs per MAC (forward, input gradient,
weight gradient). KDA uses the recurrent equation's three contractions per
head, or `18 * heads * head_dim**2` training FLOPs per token. Extra chunk
algorithm work is excluded, as are activation recomputation and CP replicas.
DSA uses expanded QK/value widths, independent of the backend's equivalent
latent absorption. Its KPool indexer runs without gradients, so projections
and causal pool scoring cost two FLOPs per MAC; masked future pools and
padded sparse slots are excluded.

Includes dense/MoE SwiGLU, selected and shared experts, router, language-model
head, mHC coefficient projections and stream contractions, and causal short
convolutions. Norms, activations, softmax, top-k, communication and optimizer
work are excluded. The checkpoint's unused MTP head and vision tower are not
counted. Use `benchmark.flops_scope: text` for the composite model.

For the released 45-layer configuration with `index_kpool=4`, this fixed
convention gives 104.177535648 GFLOPs/token at 4096 tokens. A packed batch
requires summing this formula over its actual document lengths; treating a
pack of short documents as one long sequence overcounts sparse/indexer work.

**Parameters:**

**`config`** `Glm5NextTextConfig`

Native text configuration, including effective layer patterns.

---

**`gbs`** `int` — default: 1

Number of independent sequences in the global optimizer step.

---

**`seq_len`** `int | None` — default: None

Valid tokens in each sequence; defaults to the context limit.

---

**Returns:** `float`

Global training FLOPs, before division by device count or elapsed time.

**Raises:**

* `ValueError`: If the global batch size or sequence length is not positive.