> 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.training.benchmark_summary

End-of-run summary of a training recipe run as its performance benchmark.

`benchmark: true` (or `--benchmark`) runs a training recipe as its performance benchmark. Its summary averages
the optimizer steps after `ci.perf_testing.warmup_steps` the way Core Models averages a performance run and the
legacy benchmarking recipe averaged its timed iterations: the tokens of those steps over their time, and MFU
weighted by step time. A step's time is its token count over its tokens per second, two fields of its step line.

## Module Contents

### Classes

| Name                                                                                                     | Description                                                                  |
| -------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| [`BenchmarkSummary`](#nemo_automodel-components-training-benchmark_summary-BenchmarkSummary)             | Steady-state throughput of a benchmark run, over the steps after its warmup. |
| [`BenchmarkSummaryConfig`](#nemo_automodel-components-training-benchmark_summary-BenchmarkSummaryConfig) | Typed view over the summary of a benchmark run.                              |
| [`_Step`](#nemo_automodel-components-training-benchmark_summary-_Step)                                   | -                                                                            |

### Functions

| Name                                                                                                         | Description                                                  |
| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------ |
| [`format_benchmark_summary`](#nemo_automodel-components-training-benchmark_summary-format_benchmark_summary) | The log line of a summary from `BenchmarkSummary.summarize`. |
| [`write_benchmark_summary`](#nemo_automodel-components-training-benchmark_summary-write_benchmark_summary)   | Write a summary as JSON, creating the parent directory.      |

### Data

[`logger`](#nemo_automodel-components-training-benchmark_summary-logger)

### API

```python
class nemo_automodel.components.training.benchmark_summary.BenchmarkSummary(
    config: nemo_automodel.components.training.benchmark_summary.BenchmarkSummaryConfig
)
```

Steady-state throughput of a benchmark run, over the steps after its warmup.

**`_steps`** `list[_Step] = []`

---

```python
nemo_automodel.components.training.benchmark_summary.BenchmarkSummary.record(
    step: int,
    tokens: float,
    tokens_per_second: float,
    mfu: float | None
) -> None
```

Add one optimizer step. A step without tokens has no time and is left out.

**Parameters:**

**`step`** `int`

The step number of its step line.

---

**`tokens`** `float`

Tokens of the step (`num_tokens_per_step`), the numerator of its tokens per second.

---

**`tokens_per_second`** `float`

Global tokens per second of the step (`tps`).

---

**`mfu`** `float | None`

MFU of the step in percent, or None when the model has no FLOPs formula.

---

```python
nemo_automodel.components.training.benchmark_summary.BenchmarkSummary.report(
    world_size: int
) -> dict[str, typing.Any]
```

Log the summary, and write it as JSON when the config names a path. Call it on one rank.

**Parameters:**

**`world_size`** `int`

Number of GPUs.

---

**Returns:** `dict[str, Any]`

The summary, as `summarize` returns it.

```python
nemo_automodel.components.training.benchmark_summary.BenchmarkSummary.summarize(
    world_size: int
) -> dict[str, typing.Any]
```

Average the steps after the warmup, under the field names of the legacy benchmark summary.

**Parameters:**

**`world_size`** `int`

Number of GPUs. The per-GPU throughput divides by it, as the step line does.

---

**Returns:** `dict[str, Any]`

`total_steps`, `warmup_steps`, `training_steps`, `first_training_step`,

```python
class nemo_automodel.components.training.benchmark_summary.BenchmarkSummaryConfig(
    warmup_steps: int = 0,
    json_output_path: str | None = None,
    global_batch_size: int | None = None,
    local_batch_size: int | None = None
)
```

Dataclass

Typed view over the summary of a benchmark run.

**`global_batch_size`** `int | None = None`

The run's global batch size, reported next to the averages.

---

**`json_output_path`** `str | None = None`

Where the summary is also written as JSON (`ci.perf_testing.json_output_path`), or
None for the log line alone.

---

**`local_batch_size`** `int | None = None`

The run's local batch size, reported next to the averages.

---

**`warmup_steps`** `int = 0`

Leading optimizer steps that the averages leave out (`ci.perf_testing.warmup_steps`).

---

```python
nemo_automodel.components.training.benchmark_summary.BenchmarkSummaryConfig.build() -> nemo_automodel.components.training.benchmark_summary.BenchmarkSummary
```

An empty summary that the training loop records its steps into.

```python
class nemo_automodel.components.training.benchmark_summary._Step(
    step: int,
    tokens: float,
    seconds: float,
    mfu: float | None
)
```

Dataclass

**`mfu`** `float | None`

---

**`seconds`** `float`

---

**`step`** `int`

---

**`tokens`** `float`

---

```python
nemo_automodel.components.training.benchmark_summary.format_benchmark_summary(
    summary: dict[str, typing.Any]
) -> str
```

The log line of a summary from `BenchmarkSummary.summarize`.

**Parameters:**

**`summary`** `dict[str, Any]`

The summary to print.

---

**Returns:** `str`

`benchmark summary: &lt;n&gt; steps after &lt;w&gt; warmup steps | avg step time &lt;s&gt; s | tps &lt;x&gt;(&lt;y&gt;/gpu) | mfu &lt;z&gt;`,

```python
nemo_automodel.components.training.benchmark_summary.write_benchmark_summary(
    summary: dict[str, typing.Any],
    path: str | pathlib.Path
) -> pathlib.Path
```

Write a summary as JSON, creating the parent directory.

**Parameters:**

**`summary`** `dict[str, Any]`

The summary to write.

---

**`path`** `str | Path`

The JSON file.

---

**Returns:** `Path`

The path written.

```python
nemo_automodel.components.training.benchmark_summary.logger = logging.getLogger(__name__)
```