> This page is for version Nightly (default).
> 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.

# Ergo

> Fine-tune Ergo with NeMo AutoModel using HellaSwag SFT and packed Tulu 3 sequences with context parallelism, including measured training loss curves.

NeMo AutoModel supports Ergo, a text-only Mixture-of-Experts model with approximately 1.106 trillion
stored parameters. It provides a native model implementation,
SentencePiece tokenizer, checkpoint adapter, and distributed fine-tuning recipes
for the full 64-layer Ergo checkpoint.

These recipes load a local copy of the published BF16 weights,
[Amazon-FMR/Ergo-bf16](https://huggingface.co/Amazon-FMR/Ergo-bf16) on Hugging Face.

> **Note**
>
> The complete model finished the HellaSwag and Tulu 3 training runs reported
> below. These short runs establish training execution for the listed settings.
> Full-model logits parity with SGLang and strict BF16 reference-gradient parity
> remain unresolved. The training curves do not establish those numerical gates
> or downstream model quality.

## Model Reference

### Model Architecture

| Property                | Value                                                                       |
| ----------------------- | --------------------------------------------------------------------------- |
| Architecture            | `ErgoForCausalLM`                                                           |
| Model type              | `ergo`                                                                      |
| Task                    | Text generation, no vision encoder                                          |
| Stored parameters       | Approximately 1.106T                                                        |
| Language backbone       | 64 layers, hidden size 8192                                                 |
| Attention               | GQA, with three local layers followed by one global layer                   |
| Local attention         | 512-token causal window, including the current token, with interleaved RoPE |
| Global attention        | Full causal attention, without RoPE                                         |
| Experts                 | 256 routed experts, top-8 sigmoid routing, plus a shared expert             |
| Feed-forward activation | ReLU squared, with one leading dense layer, then MoE layers                 |
| Source precision        | BF16 and FP32 tensors                                                       |
| Embedding and LM head   | Untied                                                                      |

Attention applies per-head Q/K normalization. Each expert applies its own
output RMSNorm before routing-weight multiplication and reduction. Correction
bias changes expert selection, while normalized unbiased sigmoid scores weight
the selected experts. Correction biases remain fixed during fine-tuning.
Residual arithmetic, learned normalization/residual scales, and router
arithmetic retain FP32. Branch compute can use BF16.

The model-owned tokenizer supports reasoning and tool turns. Chat boundaries
use explicit CONTROL IDs, and `NeMoAutoTokenizer` provides assistant masks for
the shared `ChatDataset` pipeline. Its chat method requires `tokenize=True`.

## Choose a Workflow

| Goal                                           | Base recipe                                                                                                                                                                  | Measured configuration                                                                                              |
| ---------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| Text SFT, packed 2K                            | [HellaSwag SFT](https://github.com/NVIDIA-NeMo/Automodel/blob/main/examples/llm_finetune/ergo/ergo_hellaswag_sft_pp2_ep64.yaml)                                              | 128 GB200 GPUs, EP64 / PP2 / CP1, compiled normalization, one epoch, 12 updates                                     |
| Text SFT, packed 128K with context parallelism | [Tulu 3 with MagiAttention context parallelism](https://github.com/NVIDIA-NeMo/Automodel/blob/main/examples/llm_finetune/ergo/ergo_tulu3_packed128k_ep64_pp2_cp16_magi.yaml) | 128 GB200 GPUs, EP64 / PP2 / CP16 / DP4, balanced routing from random initialization, 21.04% MFU, no training curve |
| LoRA qualification                             | [HellaSwag LoRA](https://github.com/NVIDIA-NeMo/Automodel/blob/main/examples/llm_finetune/ergo/ergo_hellaswag_lora_ep32.yaml)                                                | Template uses 32 GB200 GPUs, EP32 / DP32 without pipeline parallelism, no full-release LoRA run reported here       |
| Synthetic pretraining benchmark                | [Ergo EP64 / PP2 on GB200](https://github.com/NVIDIA-NeMo/Automodel/blob/main/examples/llm_pretrain/ergo/ergo_ep64_pp2_gb200.yaml)                                           | 128 GB200 GPUs, EP64 / PP2 / CP1, mock 4096-token rows, balanced routing, 22.44% MFU                                |

The two measured SFT runs train all 64 layers. Both use FSDP2, HybridEP,
`torch_mm` experts, activation checkpointing, and pipeline microbatch size 1.
EP overlaps the data/context mesh: EP64 / PP2 / CP64 uses 128 GPUs, not
64 times 2 times 64 GPUs. The measured Tulu 3 run used Transformer Engine
context parallelism at CP64 with an earlier recipe, which the MagiAttention
recipe replaces. Training Measurements records its configuration.

## Prepare the Checkpoint and Data

Follow the [installation instructions](/nemo/automodel/nightly/get-started/installation) and the
[Slurm cluster guide](/nemo/automodel/nightly/job-launchers/slurm-cluster). The measured environment
requires HybridEP, Transformer Engine for FusedAdam and Tulu attention, and
Cut Cross-Entropy for the fused loss. The packed Tulu 3 recipe uses
MagiAttention for context parallelism instead of Transformer Engine attention.

Download [Amazon-FMR/Ergo-bf16](https://huggingface.co/Amazon-FMR/Ergo-bf16)
(about 2.2 TB) to storage that every worker can read. The weights load as
downloaded, with no conversion step: each PP stage and EP rank reads its own
layers and experts through the standard weight index. Reuse the same download
when changing batch size, learning rate, or parallelism.

Keep runtime code, compiler caches, dataset caches, and logs on node-local
storage. The measured runs reused one shared checkpoint, with local
metadata/indexes and bounded staging of reusable runtime and dataset archives.
They did not copy the entire checkpoint to every node.

### HellaSwag

The HellaSwag preprocessor supervises the correct ending and masks context and
padding. NEAT packing preserves document boundaries in 2048-token rows. The
validation input uses the full validation split: a 1024-example subset packs
into too few rows for a complete DP64 batch. With `drop_last: true`, only
complete batches contribute to validation.

### Tulu 3: Packed Sequences with Context Parallelism

The Tulu recipe reads prebuilt packs saved to disk. It does not tokenize or pack
at startup. Packs made with another model's tokenizer
cannot be reused. Prepare them as follows:

1. Tokenize `allenai/tulu-3-sft-mixture` with the Ergo tokenizer through
   `ChatDataset`, without padding or truncation. Only assistant turns are
   supervised.
2. Shuffle the documents with seed 1234.
3. Pack them into 131,072-token THD rows with `pack_dataset`. A conversation
   longer than a row is dropped whole. The documents need no alignment
   (`pad_to_multiple_of=1`): MagiAttention dispatches fixed 512-token chunks.
4. Shuffle the packed rows with the same seed and save them at the recipe's
   `dataset.dataset_path`.

```python
import random

from torch.utils.data import Subset

from nemo_automodel import NeMoAutoTokenizer
from nemo_automodel.components.datasets.llm.chat_dataset import ChatDatasetConfig
from nemo_automodel.components.datasets.llm.packed_sequence import pack_dataset

seed = 1234
tokenizer = NeMoAutoTokenizer.from_pretrained("/path/to/Ergo-bf16")
dataset = ChatDatasetConfig(
    path_or_dataset_id="allenai/tulu-3-sft-mixture",
    split="train",
    padding=False,
    truncation=False,
    unshifted=False,
).build(tokenizer=tokenizer)
indices = list(range(len(dataset)))
random.Random(seed).shuffle(indices)
packs = pack_dataset(
    Subset(dataset, indices),
    split=None,
    packed_sequence_size=131072,
    max_packs=3216,  # 50 updates of 64 rows, plus 16 spare rows
    padding_idx=tokenizer.pad_token_id,
    drop_long_samples=True,
    cp_size=1,
    pad_to_multiple_of=1,
).shuffle(seed=seed)
packs.save_to_disk("data/ergo_tulu3_packed128k/train")
```

This step needs the tokenizer files only: no model weights and no GPU.

MagiAttention context parallelism distributes each 131,072-token pack across
16 ranks, 8192 tokens per rank. THD boundaries preserve causal attention
within each document, including the model's local-attention windows. Freeze
and reuse one packed dataset and row order for comparisons.

## Run HellaSwag SFT

Run from a checkout containing the Ergo implementation. Point the checkpoint
and dataset variables to locations visible to every worker, and choose a
node-local output directory on each node:

```bash
export ERGO_CHECKPOINT=/path/to/Ergo-bf16
export ERGO_HELLASWAG_DATASET=/path/to/hellaswag
export ERGO_OUTPUT_DIR=/raid/ergo-output
export WANDB_ENTITY=your-wandb-entity
export WANDB_PROJECT=ergo-finetuning
export WANDB_RUN_ID=ergo-hellaswag-001
export TORCHDYNAMO_DISABLE=0
mkdir -p "${ERGO_OUTPUT_DIR}"
```

Within a 32-node allocation with four GB200 GPUs per node, run one launcher
per node. Set `NODE_RANK` from 0 to 31 and `MASTER_ADDR` to the first node's
reachable hostname. Authenticate W\&B before launching:

```bash
torchrun --nnodes=32 --nproc-per-node=4 \
  --node-rank="${NODE_RANK}" \
  --rdzv-id="${WANDB_RUN_ID}" \
  --rdzv-backend=c10d --rdzv-endpoint="${MASTER_ADDR}:29500" \
  -m nemo_automodel.cli.app \
  examples/llm_finetune/ergo/ergo_hellaswag_sft_pp2_ep64.yaml \
  --model.pretrained_model_name_or_path "${ERGO_CHECKPOINT}" \
  --dataset.path_or_dataset="${ERGO_HELLASWAG_DATASET}" \
  --validation_dataset.path_or_dataset="${ERGO_HELLASWAG_DATASET}" \
  --checkpoint.checkpoint_dir="${ERGO_OUTPUT_DIR}/hellaswag" \
  --model.backend.compile_norm=true \
  --wandb.enable=true --wandb.mode=online \
  --wandb.entity="${WANDB_ENTITY}" --wandb.project="${WANDB_PROJECT}" \
  --wandb.id="${WANDB_RUN_ID}" --wandb.name="${WANDB_RUN_ID}" \
  --wandb.dir="${ERGO_OUTPUT_DIR}/wandb"
```

Compiled normalization reduces temporary activation memory in the expert and
shared-expert RMSNorm operations. It must run with Dynamo enabled. Both SFT
recipes disable checkpoint writing by default. Configure checkpoint retention
explicitly for training whose updated weights must be saved.

## Run Tulu 3 SFT with Packed Sequences and Context Parallelism

The recipe runs on 128 GPUs with EP64 / PP2 / CP16 / DP4 and reads the packs
described above. Keep Dynamo enabled: the compiled loss and the compiled
router-weight multiply need it. MagiAttention and its Blackwell
attention-kernel dependencies must be present in the training environment.

```bash
export ERGO_TULU_PACKS=/path/to/ergo-tulu3-128k/train
export WANDB_RUN_ID=ergo-tulu3-001
export TORCHDYNAMO_DISABLE=0
export MAGI_ATTENTION_FA4_BACKEND=1
export MAGI_ATTENTION_NATIVE_GRPCOLL=0

torchrun --nnodes=32 --nproc-per-node=4 \
  --node-rank="${NODE_RANK}" \
  --rdzv-id="${WANDB_RUN_ID}" \
  --rdzv-backend=c10d --rdzv-endpoint="${MASTER_ADDR}:29500" \
  -m nemo_automodel.cli.app \
  examples/llm_finetune/ergo/ergo_tulu3_packed128k_ep64_pp2_cp16_magi.yaml \
  --model.pretrained_model_name_or_path "${ERGO_CHECKPOINT}" \
  --dataset.dataset_path="${ERGO_TULU_PACKS}" \
  --checkpoint.checkpoint_dir="${ERGO_OUTPUT_DIR}/tulu" \
  --wandb.enable=true --wandb.mode=online \
  --wandb.entity="${WANDB_ENTITY}" --wandb.project="${WANDB_PROJECT}" \
  --wandb.id="${WANDB_RUN_ID}" --wandb.name="${WANDB_RUN_ID}" \
  --wandb.dir="${ERGO_OUTPUT_DIR}/wandb"
```

Request 16 nodes per NVLink domain (`--segment=16` on HSG) so that each EP64
group, which is one pipeline stage, stays inside one domain.

This recipe has a throughput measurement from random initialization only (refer to
Training Performance). It has not been run with the released weights. The
Tulu 3 loss curve below comes from the Transformer Engine recipe it replaces.

## Training Measurements

Both runs completed on OCI HSG using 32 nodes with four GB200 GPUs per node,
short QoS, and online W\&B logging. Completion reports from all 128 ranks
confirmed the expected optimizer updates. Model checkpoint writing was disabled,
so these measurements do not qualify full-release checkpoint save/resume.

The Tulu 3 run predates the MagiAttention recipe. It used the Transformer
Engine context-parallel recipe
[`ergo_tulu3_packed128k_ep32_pp2_cp32_te.yaml`](https://github.com/NVIDIA-NeMo/Automodel/blob/8e91fc2aff668700cebe01fb4b0ee0c5d6eee3f3/examples/llm_finetune/ergo/ergo_tulu3_packed128k_ep32_pp2_cp32_te.yaml),
since removed, with `TORCHDYNAMO_DISABLE=1` and the overrides
`--distributed.ep_size=64 --distributed.cp_size=64`,
`--model.backend.dispatcher_hybridep_max_tokens_per_rank=2048`,
`--model.backend.compile_norm=false`, and
`--packed_sequence.pad_to_multiple_of=128`. Its packs aligned every document
to 128 tokens (`2 * cp_size`, which TE context parallelism requires): 432
rows holding 63,347 documents.

| Setting                        | HellaSwag                                                              | Tulu 3                                                                 |
| ------------------------------ | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- |
| Job / W\&B                     | [9478845](https://wandb.ai/nvidia/automodel-ergo-sft/runs/hsg-9478845) | [9476973](https://wandb.ai/nvidia/automodel-ergo-sft/runs/hsg-9476973) |
| EP / PP / CP / DP              | 64 / 2 / 1 / 64                                                        | 64 / 2 / 64 / 1                                                        |
| Packing / sequence length      | NEAT / 2048                                                            | THD / 131,072                                                          |
| Global / local batch           | 128 / 2                                                                | 8 / 8                                                                  |
| Pipeline                       | 1F1B, 32 layers per stage                                              | Interleaved1F1B, VPP2, 16 layers per virtual stage                     |
| Attention                      | SDPA                                                                   | Transformer Engine                                                     |
| Model / compute dtype          | FP32 masters / BF16 compute                                            | BF16 model and compute, optimizer FP32 masters                         |
| Optimizer                      | AdamW, `foreach: false`                                                | TE FusedAdam, BF16 moments, parameter remainders                       |
| Learning rate                  | 1e-4 peak, cosine to 1e-5, 10 warmup steps                             | 5e-6, constant after 5 warmup steps                                    |
| Weight decay / betas / epsilon | 0.1 / (0.9, 0.95) / 1e-8                                               | 0.1 / (0.9, 0.95) / 1e-8                                               |
| Compiled normalization         | Enabled                                                                | Disabled                                                               |
| Completed updates              | 12, one packed-loader epoch                                            | 50                                                                     |
| First to last training loss    | 2.2435 to 1.7765                                                       | 0.7332 to 0.6113                                                       |
| Validation loss                | 1.8048 after update 10                                                 | Not measured                                                           |
| Allocation elapsed time        | 14m 49s                                                                | 46m 38s                                                                |

The HellaSwag run was measured with FP32 master weights in the model and AdamW.
The recipe has since moved to BF16 weights with TE FusedAdam, which keeps the
FP32 master weights in the optimizer, as the Tulu recipe does. That setting has
not been rerun on the full model.

Allocation times include preparation and cleanup. They are not training-only
benchmarks. HellaSwag supervises correct endings, while Tulu supervises assistant
turns. Their losses therefore measure different objectives and are not directly
comparable.

### HellaSwag Loss

![Ergo HellaSwag loss over 12 optimizer updates, with validation after update 10](/nemo/automodel/_fern-files/nemo-automodel.docs.buildwithfern.com/0626bfad7f85609a2616fc5199690fc11ac81b317cf5ce2bb3ccbdf6ce8bece7/_dot_dot_/model-coverage/llm/amazon/ergo-hellaswag-loss.png)

Every recorded training point is shown without smoothing. The diamond is the
single recorded validation result, taken from complete batches of the packed
validation split. It is a next-token loss, not HellaSwag multiple-choice accuracy.

### Tulu 3 Loss for Packed Sequences with CP64

![Ergo Tulu 3 packed-sequence training loss over 50 optimizer updates with TE context parallelism at CP64](/nemo/automodel/_fern-files/nemo-automodel.docs.buildwithfern.com/6a4de991549349d31c45e20b4aec09f6ebdaa40c4681e4e1460533721c9c9bbf/_dot_dot_/model-coverage/llm/amazon/ergo-tulu3-loss.png)

This is the completed eager-normalization baseline. It must not be interpreted
as a result for the later compiled-normalization rerun or the latest PR commit.
The fluctuations reflect different packed training batches. No validation curve
was collected.

### Measurement Provenance

Figures use the retained rank-zero `training.jsonl` records, with `loss` on the
y-axis and `step + 1` on the x-axis. HellaSwag's validation record has logged
`step: 9`, shown as completed update 10.

HellaSwag used the compiled-normalization implementation from `5f06b5ba` on its
retained runtime baseline. Tulu used the retained runtime based on `d8164538`.
These were packaged runtimes, not clean checkouts of the later PR head
`b21db815`. A Tulu rerun at that head with compiled normalization is separate
and is not included in these completed-run measurements.

## Training Performance

These are throughput measurements of the full model on 128 GB200 GPUs (OCI
HSG, four GPUs per node) from random initialization. They load no released
weights and are separate from the training runs above.

> **Note**
>
> Measure throughput with `--benchmark`, which routes with the balanced gate, or
> with the released weights. The router of a randomly initialized Ergo is heavily
> skewed, and the ranks with fewer expert rows then wait at every expert-parallel
> exchange.

| Recipe                                                                                                                                                        | Layout                                     | Time per step (s) | Tokens/s per GPU |    MFU | Peak memory per GPU |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ | ----------------: | ---------------: | -----: | ------------------: |
| [Synthetic pretraining](https://github.com/NVIDIA-NeMo/Automodel/blob/main/examples/llm_pretrain/ergo/ergo_ep64_pp2_gb200.yaml), 4096-token mock rows         | EP64 / PP2 / DP64, global batch 2048       |             39.02 |            1,679 | 22.44% |           116.2 GiB |
| [Packed 128K with MagiAttention](https://github.com/NVIDIA-NeMo/Automodel/blob/main/examples/llm_finetune/ergo/ergo_tulu3_packed128k_ep64_pp2_cp16_magi.yaml) | EP64 / PP2 / CP16 / DP4, 64 packs per step |             40.86 |            1,576 | 21.04% |           116.6 GiB |

Both rows use `--benchmark` (balanced gate, static routing, equal token
counts), activation checkpointing, FA4 or MagiAttention, the Triton RoPE
kernel, the fused elementwise kernels, `torch_mm` experts, and HybridEP. MFU divides the achieved
model FLOPs per GPU by the 2,500 TFLOPs/s GB200 dense BF16 peak. The packed row
counts real tokens and sums the FLOPs formula over the documents of every pack.
Padded tokens count as no work.

### Model FLOPs

`ErgoConfig.flops_formula` counts the useful matrix-multiply work of one
full-parameter optimizer step. Every counted product is trainable, so one
multiply-accumulate costs six FLOPs: forward, input gradient, and weight
gradient. For `B` sequences of `S` tokens:

```text
FLOPs = 6 * B * (S * P + A)

P = L * (H * (Nq + 2 * Nkv) * D + Nq * D * H)        attention projections
  + Ld * 2 * H * Fd                                  leading dense block
  + (L - Ld) * (H * E + K * 2 * H * Fe + 2 * H * Fs) router, top-K experts, shared expert
  + H * V                                            LM head

A = Nq * 2 * D * (Lg * S * (S + 1) / 2 + (L - Lg) * (W * (W + 1) / 2 + (S - W) * W))
```

`L` is the number of layers (64), `Ld` the leading dense blocks (1), `Lg` the
global-attention layers (16), `H` the hidden size (8192), `Nq` and `Nkv` the
query and key/value heads (64 and 8), `D` the head dimension (128), `Fd`, `Fe`
and `Fs` the dense, expert and shared intermediate sizes (32768, 4096 and
8192\), `E` the experts (256), `K` the experts per token (8), `V` the vocabulary
(262144), and `W` the local window (512). `A` counts the permitted query-key
pairs: all causal pairs in a global layer, and at most `W` keys per query in a
local layer (the form above holds for `S >= W`).

The released configuration costs 334.04 GFLOPs per token at 4096 tokens.
Normalization, RoPE, ReLU squared, the residual blends, activation
recomputation, padding, optimizer updates, and communication are excluded. A
packed row is the sum over its documents, not one sequence of the row length.

### Kernels

`model.config.elementwise_backend: fused` replaces the eager elementwise
chains with one kernel per chain. A chain uses a library kernel where one
computes it, and a Triton kernel of this model otherwise:

| Chain                                                         | Kernel                                                                                |
| ------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
| ReLU squared of the leading dense block and the shared expert | Transformer Engine `srelu` and `dsrelu`                                               |
| Per-head Q/K RMSNorm                                          | QuACK `rmsnorm`                                                                       |
| Per-expert output RMSNorm                                     | Triton: every row takes its expert's scale, and the row groups are read on the device |
| Shared expert's RMSNorm plus the routed output                | Triton: the addition is part of the kernel                                            |
| Branch RMSNorm plus the FP32 residual blend                   | Triton: the blend is part of the kernel                                               |

The routed experts keep the compiled ReLU squared of the shared MoE code.

The kernels follow the rounding sequence of the eager BF16 chains. Reductions,
such as the mean square of a row and the norm scale gradient, are accumulated
in another order, so results can differ in the last BF16 bit. The squared ReLU
is bit-identical. The default, `torch`, keeps the eager operators, and so does
a chain whose library is not installed.

The performance recipes combine these kernels with FlashAttention 4 for
unpadded rows (`attn: fa4`), the Triton RoPE kernel (`rope: triton`), the
compiled fused linear cross entropy (`loss_fn.impl: torch_compile`), the
compiled router-weight multiply, and the HybridEP recompute cache
(`dispatcher_recompute_cache: combine`). The normalization weights, residual
scales, and router of a block share one FSDP group, so a block issues one
all-gather and one reduce-scatter for them instead of one per module.

### Synthetic Pretraining Benchmark

[`ergo_ep64_pp2_gb200.yaml`](https://github.com/NVIDIA-NeMo/Automodel/blob/main/examples/llm_pretrain/ergo/ergo_ep64_pp2_gb200.yaml)
builds the released configuration without reading a checkpoint and trains on
fixed 4096-token mock rows, with 16 pipeline microbatches per step. Launch it
with the `torchrun` command of the HellaSwag recipe above, replacing the recipe
path and every override with `--benchmark`. Request 16 nodes per NVLink domain
(`--segment=16` on HSG) so that each EP64 group, which is one pipeline stage,
stays inside one domain, and check that the GPUs of each group report one
`ClusterUUID` and `CliqueId`.

### Packed 128K with MagiAttention Context Parallelism

[`ergo_tulu3_packed128k_ep64_pp2_cp16_magi.yaml`](https://github.com/NVIDIA-NeMo/Automodel/blob/main/examples/llm_finetune/ergo/ergo_tulu3_packed128k_ep64_pp2_cp16_magi.yaml)
trains the packed Tulu 3 rows with `attn: magi` on EP64 / PP2 / CP16 / DP4.
Launch it with the Tulu 3 command above. Add `--benchmark` to measure
throughput with the balanced gate.

MagiAttention dispatches fixed 512-token chunks, so the documents of a pack
need no alignment. Packs that pad every document to a multiple of 64 tokens
also run, but that padding takes about 3.5% of every row.

The measurement used MagiAttention's FA4 backend
(`MAGI_ATTENTION_FA4_BACKEND=1`) with the native group collective disabled
(`MAGI_ATTENTION_NATIVE_GRPCOLL=0`).

Each pack gets one MagiAttention dispatch in 512-token chunks, the size of the
local window. Two attention masks share that token ownership: full causal
attention within each document for the global layers, and the 512-token causal
window for the local layers. A rank receives only the keys and values its own
queries attend, where the TE path gathers every key and value of the pack in
every layer. Sixteen ranks hold 8192 tokens of a pack each, four packs run side
by side, and local batch size 16 gives sixteen pipeline microbatches per step.

With `--benchmark` the recipe routes with the balanced gate. Static routing
replays one dispatch for every microbatch, so it also dispatches the padded
tokens of a pack. The loss mask still excludes them.

The measurement used random initialization and 128K Tulu 3 packs made with
another tokenizer, because the released weights and Ergo-tokenized packs were
not available on the cluster. It measures throughput only.

### LoRA

LoRA keeps the BF16 base frozen, so it needs neither the optimizer state of
full fine-tuning nor pipeline stages to fit.
[`ergo_hellaswag_lora_ep32.yaml`](https://github.com/NVIDIA-NeMo/Automodel/blob/main/examples/llm_finetune/ergo/ergo_hellaswag_lora_ep32.yaml)
uses EP32 / DP32 on 32 GB200 GPUs, a quarter of the full fine-tuning
allocation. This layout has not been run on 8 nodes or with the released
weights.

## Distributed and Kernel Support

The measured paths combine FSDP2, HybridEP, `torch_mm` experts, pipeline
parallelism, activation checkpointing, and fused linear cross entropy. Tulu
additionally exercises packed TE context parallelism at CP64. Keep dense and
MoE `reshard_after_forward` enabled for these capacity points, and preserve the
recipe's batch, microbatch, and parallelism relationships.

Packed context parallelism accepts `attn: sdpa`, `te`, or `magi`. The
performance recipes add FlashAttention 4 for unpadded rows, the fused
elementwise kernels, and packed MagiAttention context parallelism at CP16.
Those paths have throughput measurements from random initialization only.

Tensor parallelism greater than one is rejected. Full-release LoRA, other
parallel layouts, the advertised 1M context limit, and quantized training are
not established by these runs. Reduced-fixture loading, optimizer continuation,
and LoRA tests are distinct from full-release qualification.

HybridEP's BF16 combine and the fused BF16 loss path differ from strict FP32
reference reductions and head backward. Some strict BF16 gradient and
attention-reference numerical gates remain failing. Decreasing training loss
does not replace those checks. The architecture and protocol reference is
SGLang revision `bd598c4f927288ea5c2bb9e84359f51d9c0b5aaf` (Apache-2.0).
Full-model serving-logit parity remains unresolved.

Refer to the [LLM fine-tuning guide](/nemo/automodel/nightly/recipes-e2e-examples/sft-peft) for shared
training options.