Repository navigation
Conversation
fegin
added a commit
that referenced
this pull request
Nov 19, 2026
…ctivation offload
## Summary (human-written)
<!-- Write this yourself, not with an AI tool. 2-5 sentences: the problem, why
this approach, and what you checked yourself. -->
## Why
Our fastest Muse Spark 816B runs on 64 GPUs cannot be reproduced from the repo. They start from the 64-GPU recipe and change it in an out-of-tree launcher: layout, forced routing, Dist-MoE budgets, remat and offload policy, Adam moment placement, the optimizer CUDA graph, and FSDP symmetric memory. The launch environment and the dependency versions are not written down anywhere either.
The 64-GPU recipe also all-gathers the K/V of the full 32K sequence in every layer. The sliding-window varlen layers (46 of 62 layers, 2048-token window) read only the blocks inside their window, so most of that K/V is never used.
**Example.**
```text
before: muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64, then the launcher sets
DP32/CP2, forced routing, scratch 2, slot factor 0, remat p3,
offload attention + MoE projections, moments on GPU, optimizer graph,
FSDP symmetric memory, c4_test, 100 steps
after: --module torchtitan_recipes.models.muse_spark \
--config muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark
```
## What changed
- The Muse K/V-gather CP transform maps `SlidingWindowVarlenInnerAttention` to `SelectiveGatherKVSlidingWindowVarlenInnerAttention`. Global layers keep `AllGatherKVVarlenInnerAttention`. This applies to every 64-GPU recipe.
- The Muse save region becomes `attention.inner_attention*`, so the selective-gather assembly region nested in attention is saved with it. torch_remat rejects a recomputed region inside a saved one. The 256- and 512-GPU and UltraData recipes have no region nested in attention, so the wildcard does not change them.
- `_muse_spark_816b_dist_moe_spmd_64` takes `context_parallel_degree`; FSDP gets the other 64 / CP ranks. The existing 64-GPU recipes pass 8, as before.
- New `muse_spark_816b_a42b_dist_moe_{bf16,mxfp8}_spmd_64_benchmark` recipes and their `_fake` variants. They are benchmark only: forced balanced routing does not train a usable model.
| Setting | BF16 | MXFP8 |
| --- | --- | --- |
| layout | DP32, CP2, EP64, 2 microbatches per step | same |
| routing | forced balanced (round robin) | same |
| Dist-MoE | scratch_capacity_factor 2, activation_slot_capacity_factor 0 | same |
| remat save regions | Dist-MoE defaults + `attention.*` | + pooler, unpooler, router |
| activation offload | block input + `attention.*` | + pooler, unpooler, router |
| Adam moments | GPU (pinned_host_moment_fraction 0.0) | same |
| CUDA graphs | per microbatch group + optimizer graph | same |
| FSDP symmetric memory | scope all (off in `_fake`) | same |
| data | c4_test, random init, 100 steps (10 in `_fake`) | same |
- The benchmark docstring lists the launch environment (`NCCL_NVLS_ENABLE=1`, `PYTORCH_ALLOC_CONF=pinned_max_round_threshold_mb:1`, one NVLink domain per CP group, skipping `destroy_process_group`) and the dependency versions.
## Dependencies
- Do not land before #6020. Until then, pyrefly flags the `offload_block_input` / `offload_regions` keywords in `muse_spark.py`.
- Depends on #6020 (activation offload) and lands after it. Without #6020, `ActivationRematConfig` has no `offload_block_input` / `offload_regions`, so the four benchmark recipes raise `TypeError` when built. The module still imports, and the other recipes build.
- Depends on meta-pytorch/attention-gym#651 (selective gather); the attention-gym pin bump lands separately.
## How to reproduce
Stage the Muse Spark Open tokenizer files at `./assets/hf/Muse-Spark-Open-816B-A42B`, then on each of 16 hosts (4 GPUs each, all in one NVLink domain):
```bash
git fetch https://github.com/pytorch/torchtitan.git pull/6020/head
git cherry-pick FETCH_HEAD
NCCL_NVLS_ENABLE=1 PYTORCH_ALLOC_CONF=pinned_max_round_threshold_mb:1 \
torchrun --nnodes 16 --nproc-per-node 4 --node-rank <i> \
--master-addr <host 0> --master-port 29500 -m torchtitan.train \
--module torchtitan_recipes.models.muse_spark \
--config muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark
```
Use `..._bf16_spmd_64_benchmark` for BF16. Measure tps as the mean of steps 71-90.
## Numerics
No model or kernel change. Forced routing makes the loss meaningless for training quality; it is only a run-to-run check.
The benchmark recipes build the same effective config as the launcher-built reference runs, field by field, except: `offload_last_block` moved from the old `ActivationOffloadConfig` into `ActivationRematConfig` in #6020 (False in both), the new `per_sample_pad_multiple=1` dataloader default from main, main's RoPE `scaling='none'` -> `scaling=None` refactor, the launcher's profiler settings, and the tokenizer path.
100-step runs on 64 GPUs vs the reference runs of the same precision:
| Recipe | Mean / max abs loss diff | Loss at step 100 (new / reference) |
| --- | --- | --- |
| BF16 | 0.0017 / 0.0057 | 6.92717 / 6.92149 |
| MXFP8, run 1 | 0.0034 / 0.0086 | 6.94351 / 6.95157 |
| MXFP8, run 2 | 0.00025 / 0.0012 | 6.95231 / 6.95157 |
The two MXFP8 runs of this recipe differ from each other by 0.0035, so the run 1 gap is run-to-run noise. Step 1 matches the references exactly, and step-1 and step-2 peak memory match to 0.01 GiB.
## Performance
64 GB300 GPUs (16 nodes x 4), 100 steps. tps and TFLOPs are per GPU as logged by torchtitan, mean of steps 71-90. These runs used the launcher-built reference config, which matches these recipes field by field (see Numerics), on an earlier revision of this stack and #6020.
| Recipe | tps | TFLOPs |
| --- | ---: | ---: |
| `muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark` | 5,166 | 1,691 |
| `muse_spark_816b_a42b_dist_moe_bf16_spmd_64_benchmark` | 3,869 | 1,267 |
Forced balanced routing makes these benchmark numbers, not real-training numbers.
## Testing
- `pytest tests/unit_tests/cpu/recipes`: the new recipes build; the MLA override tests also pass when run alone.
- Config build of all four benchmark recipes, diffed field by field as above.
- FakePG, logical 64 GPUs, rank 0, 10 steps, both `_fake` recipes: MXFP8 step-2 peak 239.52 allocated / 252.68 reserved GiB, the same as an earlier FakePG run of this config. Activation offload moves 124.73 GiB (MXFP8) and 100.90 GiB (BF16) per forward, the same as the reference real runs.
- 64 GPUs, 100 steps, both precisions (MXFP8 twice): all ranks exit 0; numerics above.
## Known issues / follow-ups
- torchtitan does not check that a CP group sits in one NVLink domain.
- With FSDP symmetric memory and EP, `destroy_process_group` can hang after training. The recipe cannot skip it; the launcher must.
- `pytorch/pytorch#204942` is required: without it step 1 runs out of memory. This was measured with DP8/CP8, not rechecked with DP32/CP2.
stack-info: PR: #6252, branch: fegin/stack/45
fegin
force-pushed
the
fegin/stack/45
branch
from
November 19, 2026 21:13
9f1e9fb to
973cfb9
Compare
This was referenced Nov 19, 2026
fegin
force-pushed
the
fegin/stack/45
branch
from
November 19, 2026 22:17
973cfb9 to
814df1c
Compare
fegin
added a commit
that referenced
this pull request
Nov 19, 2026
…ctivation offload
## Summary (human-written)
<!-- Write this yourself, not with an AI tool. 2-5 sentences: the problem, why
this approach, and what you checked yourself. -->
## Why
Our fastest Muse Spark 816B runs on 64 GPUs cannot be reproduced from the repo. They start from the 64-GPU recipe and change it in an out-of-tree launcher: layout, forced routing, Dist-MoE budgets, remat and offload policy, Adam moment placement, the optimizer CUDA graph, and FSDP symmetric memory. The launch environment and the dependency versions are not written down anywhere either.
The 64-GPU recipe also all-gathers the K/V of the full 32K sequence in every layer. The sliding-window varlen layers (46 of 62 layers, 2048-token window) read only the blocks inside their window, so most of that K/V is never used.
**Example.**
```text
before: muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64, then the launcher sets
DP32/CP2, forced routing, scratch 2, slot factor 0, remat p3,
offload attention + MoE projections, moments on GPU, optimizer graph,
FSDP symmetric memory, c4_test, 100 steps
after: --module torchtitan_recipes.models.muse_spark \
--config muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark
```
## What changed
- The Muse K/V-gather CP transform maps `SlidingWindowVarlenInnerAttention` to `SelectiveGatherKVSlidingWindowVarlenInnerAttention`. Global layers keep `AllGatherKVVarlenInnerAttention`. This applies to every 64-GPU recipe.
- The Muse save region becomes `attention.inner_attention*`, so the selective-gather assembly region nested in attention is saved with it. torch_remat rejects a recomputed region inside a saved one. The 256- and 512-GPU and UltraData recipes have no region nested in attention, so the wildcard does not change them.
- `_muse_spark_816b_dist_moe_spmd_64` takes `context_parallel_degree`; FSDP gets the other 64 / CP ranks. The existing 64-GPU recipes pass 8, as before.
- New `muse_spark_816b_a42b_dist_moe_{bf16,mxfp8}_spmd_64_benchmark` recipes and their `_fake` variants. They are benchmark only: forced balanced routing does not train a usable model.
| Setting | BF16 | MXFP8 |
| --- | --- | --- |
| layout | DP32, CP2, EP64, 2 microbatches per step | same |
| routing | forced balanced (round robin) | same |
| Dist-MoE | scratch_capacity_factor 2, activation_slot_capacity_factor 0 | same |
| remat save regions | Dist-MoE defaults + `attention.*` | + pooler, unpooler, router |
| activation offload | block input + `attention.*`, not in the last block | + pooler, unpooler, router |
| Adam moments | GPU (pinned_host_moment_fraction 0.0) | same |
| CUDA graphs | per microbatch group + optimizer graph | same |
| FSDP symmetric memory | scope all (off in `_fake`) | same |
| data | c4_test, random init, 100 steps (10 in `_fake`) | same |
- The benchmark docstring lists the launch environment (`NCCL_NVLS_ENABLE=1`, `PYTORCH_ALLOC_CONF=pinned_max_round_threshold_mb:1`, one NVLink domain per CP group, skipping `destroy_process_group`) and the dependency versions.
## Dependencies
- Do not land before #6020. Until then, pyrefly flags the `offload_block_input` / `offload_regions` keywords in `muse_spark.py`.
- Depends on #6020 (activation offload) and lands after it. Without #6020, `ActivationRematConfig` has no `offload_block_input` / `offload_regions`, so the four benchmark recipes raise `TypeError` when built. The module still imports, and the other recipes build.
- Depends on meta-pytorch/attention-gym#651 (selective gather); the attention-gym pin bump lands separately.
## How to reproduce
Stage the Muse Spark Open tokenizer files at `./assets/hf/Muse-Spark-Open-816B-A42B`, then on each of 16 hosts (4 GPUs each, all in one NVLink domain):
```bash
git fetch https://github.com/pytorch/torchtitan.git pull/6020/head
git cherry-pick FETCH_HEAD
NCCL_NVLS_ENABLE=1 PYTORCH_ALLOC_CONF=pinned_max_round_threshold_mb:1 \
torchrun --nnodes 16 --nproc-per-node 4 --node-rank <i> \
--master-addr <host 0> --master-port 29500 -m torchtitan.train \
--module torchtitan_recipes.models.muse_spark \
--config muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark
```
Use `..._bf16_spmd_64_benchmark` for BF16. Measure tps as the mean of steps 71-90.
## Numerics
No model or kernel change. Forced routing makes the loss meaningless for training quality; it is only a run-to-run check.
The benchmark recipes build the same effective config as the launcher-built reference runs, field by field, except: `offload_last_block=False` in the reference runs, which #6020 removed (the recipes keep the last block on GPU with a `BlockRematOverride`, the same per-block offload plan), the new `per_sample_pad_multiple=1` dataloader default from main, main's RoPE `scaling='none'` -> `scaling=None` refactor, the launcher's profiler settings, and the tokenizer path.
100-step runs on 64 GPUs vs the reference runs of the same precision:
| Recipe | Mean / max abs loss diff | Loss at step 100 (new / reference) |
| --- | --- | --- |
| BF16 | 0.0017 / 0.0057 | 6.92717 / 6.92149 |
| MXFP8, run 1 | 0.0034 / 0.0086 | 6.94351 / 6.95157 |
| MXFP8, run 2 | 0.00025 / 0.0012 | 6.95231 / 6.95157 |
The two MXFP8 runs of this recipe differ from each other by 0.0035, so the run 1 gap is run-to-run noise. Step 1 matches the references exactly, and step-1 and step-2 peak memory match to 0.01 GiB.
## Performance
64 GB300 GPUs (16 nodes x 4), 100 steps. tps and TFLOPs are per GPU as logged by torchtitan, mean of steps 71-90. These runs used the launcher-built reference config, which matches these recipes field by field (see Numerics), on an earlier revision of this stack and #6020.
| Recipe | tps | TFLOPs |
| --- | ---: | ---: |
| `muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark` | 5,166 | 1,691 |
| `muse_spark_816b_a42b_dist_moe_bf16_spmd_64_benchmark` | 3,869 | 1,267 |
Forced balanced routing makes these benchmark numbers, not real-training numbers.
## Testing
- `pytest tests/unit_tests/cpu/recipes`: the new recipes build; the MLA override tests also pass when run alone.
- Config build of all four benchmark recipes, diffed field by field as above.
- FakePG, logical 64 GPUs, rank 0, 10 steps, both `_fake` recipes: MXFP8 step-2 peak 239.52 allocated / 252.68 reserved GiB, the same as an earlier FakePG run of this config. Activation offload moves 124.73 GiB (MXFP8) and 100.90 GiB (BF16) per forward, the same as the reference real runs.
- 64 GPUs, 100 steps, both precisions (MXFP8 twice): all ranks exit 0; numerics above.
## Known issues / follow-ups
- torchtitan does not check that a CP group sits in one NVLink domain.
- With FSDP symmetric memory and EP, `destroy_process_group` can hang after training. The recipe cannot skip it; the launcher must.
- `pytorch/pytorch#204942` is required: without it step 1 runs out of memory. This was measured with DP8/CP8, not rechecked with DP32/CP2.
stack-info: PR: #6252, branch: fegin/stack/45
fegin
force-pushed
the
fegin/stack/45
branch
from
November 20, 2026 00:20
814df1c to
388a875
Compare
fegin
added a commit
that referenced
this pull request
Nov 20, 2026
…ctivation offload
## Summary (human-written)
<!-- Write this yourself, not with an AI tool. 2-5 sentences: the problem, why
this approach, and what you checked yourself. -->
## Why
Our fastest Muse Spark 816B runs on 64 GPUs cannot be reproduced from the repo. They start from the 64-GPU recipe and change it in an out-of-tree launcher: layout, forced routing, Dist-MoE budgets, remat and offload policy, Adam moment placement, the optimizer CUDA graph, and FSDP symmetric memory. The launch environment and the dependency versions are not written down anywhere either.
The 64-GPU recipe also all-gathers the K/V of the full 32K sequence in every layer. The sliding-window varlen layers (46 of 62 layers, 2048-token window) read only the blocks inside their window, so most of that K/V is never used.
**Example.**
```text
before: muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64, then the launcher sets
DP32/CP2, forced routing, scratch 2, slot factor 0, remat p3,
offload attention + MoE projections, moments on GPU, optimizer graph,
FSDP symmetric memory, c4_test, 100 steps
after: --module torchtitan_recipes.models.muse_spark \
--config muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark
```
## What changed
- The Muse K/V-gather CP transform maps `SlidingWindowVarlenInnerAttention` to `SelectiveGatherKVSlidingWindowVarlenInnerAttention`. Global layers keep `AllGatherKVVarlenInnerAttention`. This applies to every 64-GPU recipe.
- The Muse save region becomes `attention.inner_attention*`, so the selective-gather assembly region nested in attention is saved with it. torch_remat rejects a recomputed region inside a saved one. The 256- and 512-GPU and UltraData recipes have no region nested in attention, so the wildcard does not change them.
- `_muse_spark_816b_dist_moe_spmd_64` takes `context_parallel_degree`; FSDP gets the other 64 / CP ranks. The existing 64-GPU recipes pass 8, as before.
- New `muse_spark_816b_a42b_dist_moe_{bf16,mxfp8}_spmd_64_benchmark` recipes and their `_fake` variants. They are benchmark only: forced balanced routing does not train a usable model.
| Setting | BF16 | MXFP8 |
| --- | --- | --- |
| layout | DP32, CP2, EP64, 2 microbatches per step | same |
| routing | forced balanced (round robin) | same |
| Dist-MoE | scratch_capacity_factor 2, activation_slot_capacity_factor 0 | same |
| remat save regions | Dist-MoE defaults + `attention.*` | + pooler, unpooler, router |
| activation offload | block input + `attention.*`, not in the last block | + pooler, unpooler, router |
| Adam moments | GPU (pinned_host_moment_fraction 0.0) | same |
| CUDA graphs | per microbatch group + optimizer graph | same |
| FSDP symmetric memory | scope all (off in `_fake`) | same |
| data | c4_test, random init, 100 steps (10 in `_fake`) | same |
- The benchmark docstring lists the launch environment (`NCCL_NVLS_ENABLE=1`, `PYTORCH_ALLOC_CONF=pinned_max_round_threshold_mb:1`, one NVLink domain per CP group, skipping `destroy_process_group`) and the dependency versions.
## Dependencies
- PyTorch nightly from 2026-11-20 or later. Activation offload on main calls `FSDPModule.get_all_gather_copy_in_stream` (pytorch/pytorch#205180).
- Depends on meta-pytorch/attention-gym#651 (selective gather); the attention-gym pin bump lands separately.
## How to reproduce
Stage the Muse Spark Open tokenizer files at `./assets/hf/Muse-Spark-Open-816B-A42B`, then on each of 16 hosts (4 GPUs each, all in one NVLink domain):
```bash
NCCL_NVLS_ENABLE=1 PYTORCH_ALLOC_CONF=pinned_max_round_threshold_mb:1 \
torchrun --nnodes 16 --nproc-per-node 4 --node-rank <i> \
--master-addr <host 0> --master-port 29500 -m torchtitan.train \
--module torchtitan_recipes.models.muse_spark \
--config muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark
```
Use `..._bf16_spmd_64_benchmark` for BF16. Measure tps as the mean of steps 71-90.
## Numerics
No model or kernel change. Forced routing makes the loss meaningless for training quality; it is only a run-to-run check.
The benchmark recipes build the same effective config as the launcher-built reference runs, field by field, except: `offload_last_block=False` in the reference runs, which #6020 removed (the recipes keep the last block on GPU with a `BlockRematOverride`, the same per-block offload plan), the new `per_sample_pad_multiple=1` dataloader default from main, main's RoPE `scaling='none'` -> `scaling=None` refactor, the launcher's profiler settings, and the tokenizer path.
100-step runs on 64 GPUs vs the reference runs of the same precision:
| Recipe | Mean / max abs loss diff | Loss at step 100 (new / reference) |
| --- | --- | --- |
| BF16 | 0.0017 / 0.0057 | 6.92717 / 6.92149 |
| MXFP8, run 1 | 0.0034 / 0.0086 | 6.94351 / 6.95157 |
| MXFP8, run 2 | 0.00025 / 0.0012 | 6.95231 / 6.95157 |
The two MXFP8 runs of this recipe differ from each other by 0.0035, so the run 1 gap is run-to-run noise. Step 1 matches the references exactly, and step-1 and step-2 peak memory match to 0.01 GiB.
## Performance
64 GB300 GPUs (16 nodes x 4), 100 steps. tps and TFLOPs are per GPU as logged by torchtitan, mean of steps 71-90. These runs used the launcher-built reference config, which matches these recipes field by field (see Numerics), on an earlier revision of this stack and of activation offload (#6020).
| Recipe | tps | TFLOPs |
| --- | ---: | ---: |
| `muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark` | 5,166 | 1,691 |
| `muse_spark_816b_a42b_dist_moe_bf16_spmd_64_benchmark` | 3,869 | 1,267 |
Forced balanced routing makes these benchmark numbers, not real-training numbers.
## Testing
- `pytest tests/unit_tests/cpu/recipes`: the new recipes build; the MLA override tests also pass when run alone.
- Config build of all four benchmark recipes, diffed field by field as above.
- FakePG, logical 64 GPUs, rank 0, 10 steps, both `_fake` recipes: MXFP8 step-2 peak 239.52 allocated / 252.68 reserved GiB, the same as an earlier FakePG run of this config. Activation offload moves 124.73 GiB (MXFP8) and 100.90 GiB (BF16) per forward, the same as the reference real runs.
- 64 GPUs, 100 steps, both precisions (MXFP8 twice): all ranks exit 0; numerics above.
## Known issues / follow-ups
- The numbers predate #6137 (activation reloads wait on FSDP2's copy-in stream). Its effect on these recipes is not measured.
- torchtitan does not check that a CP group sits in one NVLink domain.
- With FSDP symmetric memory and EP, `destroy_process_group` can hang after training. The recipe cannot skip it; the launcher must.
- `pytorch/pytorch#204942` is required: without it step 1 runs out of memory. This was measured with DP8/CP8, not rechecked with DP32/CP2.
stack-info: PR: #6252, branch: fegin/stack/45
fegin
force-pushed
the
fegin/stack/45
branch
from
November 20, 2026 18:02
388a875 to
e20d0e6
Compare
fegin
added a commit
that referenced
this pull request
Nov 20, 2026
…ctivation offload
## Summary (human-written)
<!-- Write this yourself, not with an AI tool. 2-5 sentences: the problem, why
this approach, and what you checked yourself. -->
## Why
Our fastest Muse Spark 816B runs on 64 GPUs cannot be reproduced from the repo. They start from the 64-GPU recipe and change it in an out-of-tree launcher: layout, forced routing, Dist-MoE budgets, remat and offload policy, Adam moment placement, the optimizer CUDA graph, and FSDP symmetric memory. The launch environment and the dependency versions are not written down anywhere either.
The 64-GPU recipe also all-gathers the K/V of the full 32K sequence in every layer. The sliding-window varlen layers (46 of 62 layers, 2048-token window) read only the blocks inside their window, so most of that K/V is never used.
**Example.**
```text
before: muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64, then the launcher sets
DP32/CP2, forced routing, scratch 2, slot factor 0, remat p3,
offload attention + MoE projections, moments on GPU, optimizer graph,
FSDP symmetric memory, c4_test, 100 steps
after: --module torchtitan_recipes.models.muse_spark \
--config muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark
```
## What changed
- The Muse K/V-gather CP transform maps `SlidingWindowVarlenInnerAttention` to `SelectiveGatherKVSlidingWindowVarlenInnerAttention`. Global layers keep `AllGatherKVVarlenInnerAttention`. This applies to every 64-GPU recipe.
- The Muse save region becomes `attention.inner_attention*`, so the selective-gather assembly region nested in attention is saved with it. torch_remat rejects a recomputed region inside a saved one. The 256- and 512-GPU and UltraData recipes have no region nested in attention, so the wildcard does not change them.
- `_muse_spark_816b_dist_moe_spmd_64` takes `context_parallel_degree`; FSDP gets the other 64 / CP ranks. The existing 64-GPU recipes pass 8, as before.
- New `muse_spark_816b_a42b_dist_moe_{bf16,mxfp8}_spmd_64_benchmark` recipes and their `_fake` variants. They are benchmark only: forced balanced routing does not train a usable model.
| Setting | BF16 | MXFP8 |
| --- | --- | --- |
| layout | DP32, CP2, EP64, 2 microbatches per step | same |
| routing | forced balanced (round robin) | same |
| Dist-MoE | scratch_capacity_factor 2, activation_slot_capacity_factor 0 | same |
| remat save regions | Dist-MoE defaults + `attention.*` | + pooler, unpooler, router |
| activation offload | block input + `attention.*`, not in the last block | + pooler, unpooler, router |
| Adam moments | GPU (pinned_host_moment_fraction 0.0) | same |
| CUDA graphs | per microbatch group + optimizer graph | same |
| FSDP symmetric memory | scope all (off in `_fake`) | same |
| data | c4_test, random init, 100 steps (10 in `_fake`) | same |
- The benchmark docstring lists the launch environment (`NCCL_NVLS_ENABLE=1`, `PYTORCH_ALLOC_CONF=pinned_max_round_threshold_mb:1`, one NVLink domain per CP group, skipping `destroy_process_group`) and the dependency versions.
## Dependencies
- PyTorch nightly from 2026-11-20 or later. Activation offload on main calls `FSDPModule.get_all_gather_copy_in_stream` (pytorch/pytorch#205180).
- Depends on meta-pytorch/attention-gym#651 (selective gather); the attention-gym pin bump lands separately.
## How to reproduce
Stage the Muse Spark Open tokenizer files at `./assets/hf/Muse-Spark-Open-816B-A42B`, then on each of 16 hosts (4 GPUs each, all in one NVLink domain):
```bash
NCCL_NVLS_ENABLE=1 PYTORCH_ALLOC_CONF=pinned_max_round_threshold_mb:1 \
torchrun --nnodes 16 --nproc-per-node 4 --node-rank <i> \
--master-addr <host 0> --master-port 29500 -m torchtitan.train \
--module torchtitan_recipes.models.muse_spark \
--config muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark
```
Use `..._bf16_spmd_64_benchmark` for BF16. Measure tps as the mean of steps 71-90.
## Numerics
No model or kernel change. Forced routing makes the loss meaningless for training quality; it is only a run-to-run check.
The benchmark recipes build the same effective config as the launcher-built reference runs, field by field, except: `offload_last_block=False` in the reference runs, which #6020 removed (the recipes keep the last block on GPU with a `BlockRematOverride`, the same per-block offload plan), the new `per_sample_pad_multiple=1` dataloader default from main, main's RoPE `scaling='none'` -> `scaling=None` refactor, the launcher's profiler settings, and the tokenizer path.
100-step runs on 64 GPUs vs the reference runs of the same precision:
| Recipe | Mean / max abs loss diff | Loss at step 100 (new / reference) |
| --- | --- | --- |
| BF16 | 0.0017 / 0.0057 | 6.92717 / 6.92149 |
| MXFP8, run 1 | 0.0034 / 0.0086 | 6.94351 / 6.95157 |
| MXFP8, run 2 | 0.00025 / 0.0012 | 6.95231 / 6.95157 |
The two MXFP8 runs of this recipe differ from each other by 0.0035, so the run 1 gap is run-to-run noise. Step 1 matches the references exactly, and step-1 and step-2 peak memory match to 0.01 GiB.
## Performance
64 GB300 GPUs (16 nodes x 4), 100 steps. tps and TFLOPs are per GPU as logged by torchtitan, mean of steps 71-90. These runs used the launcher-built reference config, which matches these recipes field by field (see Numerics), on an earlier revision of this stack and of activation offload (#6020).
| Recipe | tps | TFLOPs |
| --- | ---: | ---: |
| `muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark` | 5,166 | 1,691 |
| `muse_spark_816b_a42b_dist_moe_bf16_spmd_64_benchmark` | 3,869 | 1,267 |
Forced balanced routing makes these benchmark numbers, not real-training numbers.
## Testing
- `pytest tests/unit_tests/cpu/recipes`: the new recipes build; the MLA override tests also pass when run alone.
- Config build of all four benchmark recipes, diffed field by field as above.
- FakePG, logical 64 GPUs, rank 0, 10 steps, both `_fake` recipes: MXFP8 step-2 peak 239.52 allocated / 252.68 reserved GiB, the same as an earlier FakePG run of this config. Activation offload moves 124.73 GiB (MXFP8) and 100.90 GiB (BF16) per forward, the same as the reference real runs.
- 64 GPUs, 100 steps, both precisions (MXFP8 twice): all ranks exit 0; numerics above.
## Known issues / follow-ups
- The numbers predate #6137 (activation reloads wait on FSDP2's copy-in stream). Its effect on these recipes is not measured.
- torchtitan does not check that a CP group sits in one NVLink domain.
- With FSDP symmetric memory and EP, `destroy_process_group` can hang after training. The recipe cannot skip it; the launcher must.
- `pytorch/pytorch#204942` is required: without it step 1 runs out of memory. This was measured with DP8/CP8, not rechecked with DP32/CP2.
stack-info: PR: #6252, branch: fegin/stack/45
fegin
force-pushed
the
fegin/stack/45
branch
from
November 23, 2026 08:13
e20d0e6 to
76ca948
Compare
fegin
added a commit
that referenced
this pull request
Nov 23, 2026
…ctivation offload
## Summary (human-written)
<!-- Write this yourself, not with an AI tool. 2-5 sentences: the problem, why
this approach, and what you checked yourself. -->
## Why
Our fastest Muse Spark 816B runs on 64 GPUs cannot be reproduced from the repo. They start from the 64-GPU recipe and change it in an out-of-tree launcher: layout, forced routing, Dist-MoE budgets, remat and offload policy, Adam moment placement, the optimizer CUDA graph, and FSDP symmetric memory. The launch environment and the dependency versions are not written down anywhere either.
The 64-GPU recipe also all-gathers the K/V of the full 32K sequence in every layer. The sliding-window varlen layers (46 of 62 layers, 2048-token window) read only the blocks inside their window, so most of that K/V is never used.
**Example.**
```text
before: muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64, then the launcher sets
DP32/CP2, forced routing, scratch 2, slot factor 0, remat p3,
offload attention + MoE projections, moments on GPU, optimizer graph,
FSDP symmetric memory, c4_test, 100 steps
after: --module torchtitan_recipes.models.muse_spark \
--config muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark
```
## What changed
- The Muse K/V-gather CP transform maps `SlidingWindowVarlenInnerAttention` to `SelectiveGatherKVSlidingWindowVarlenInnerAttention`. Global layers keep `AllGatherKVVarlenInnerAttention`. This applies to every 64-GPU recipe.
- The Muse save region becomes `attention.inner_attention*`, so the selective-gather assembly region nested in attention is saved with it. torch_remat rejects a recomputed region inside a saved one. The 256- and 512-GPU and UltraData recipes have no region nested in attention, so the wildcard does not change them.
- `_muse_spark_816b_dist_moe_spmd_64` takes `context_parallel_degree`; FSDP gets the other 64 / CP ranks. The existing 64-GPU recipes pass 8, as before.
- New `muse_spark_816b_a42b_dist_moe_{bf16,mxfp8}_spmd_64_benchmark` recipes and their `_fake` variants. They are benchmark only: forced balanced routing does not train a usable model.
| Setting | BF16 | MXFP8 |
| --- | --- | --- |
| layout | DP32, CP2, EP64, 2 microbatches per step | same |
| routing | forced balanced (round robin) | same |
| Dist-MoE | scratch_capacity_factor 2, activation_slot_capacity_factor 0 | same |
| remat save regions | Dist-MoE defaults + `attention.*` | + pooler, unpooler, router |
| activation offload | block input + `attention.*`, not in the last block | + pooler, unpooler, router |
| Adam moments | GPU (moment_cpu_offload_fraction 0.0) | same |
| CUDA graphs | per microbatch group + optimizer graph | same |
| FSDP symmetric memory | scope all (off in `_fake`) | same |
| data | c4_test, random init, 100 steps (10 in `_fake`) | same |
- The benchmark docstring lists the launch environment (`NCCL_NVLS_ENABLE=1`, `PYTORCH_ALLOC_CONF=pinned_max_round_threshold_mb:1`, one NVLink domain per CP group, skipping `destroy_process_group`) and the dependency versions.
## Dependencies
- PyTorch nightly from 2026-11-20 or later. Activation offload on main calls `FSDPModule.get_all_gather_copy_in_stream` (pytorch/pytorch#205180).
- Depends on meta-pytorch/attention-gym#651 (selective gather); the attention-gym pin bump lands separately.
## How to reproduce
Stage the Muse Spark Open tokenizer files at `./assets/hf/Muse-Spark-Open-816B-A42B`, then on each of 16 hosts (4 GPUs each, all in one NVLink domain):
```bash
NCCL_NVLS_ENABLE=1 PYTORCH_ALLOC_CONF=pinned_max_round_threshold_mb:1 \
torchrun --nnodes 16 --nproc-per-node 4 --node-rank <i> \
--master-addr <host 0> --master-port 29500 -m torchtitan.train \
--module torchtitan_recipes.models.muse_spark \
--config muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark
```
Use `..._bf16_spmd_64_benchmark` for BF16. Measure tps as the mean of steps 71-90.
## Numerics
No model or kernel change. Forced routing makes the loss meaningless for training quality; it is only a run-to-run check.
The benchmark recipes build the same effective config as the launcher-built reference runs, field by field, except: `offload_last_block=False` in the reference runs, which #6020 removed (the recipes keep the last block on GPU with a `BlockRematOverride`, the same per-block offload plan), the new `per_sample_pad_multiple=1` dataloader default from main, main's RoPE `scaling='none'` -> `scaling=None` refactor, the launcher's profiler settings, and the tokenizer path.
100-step runs on 64 GPUs vs the reference runs of the same precision:
| Recipe | Mean / max abs loss diff | Loss at step 100 (new / reference) |
| --- | --- | --- |
| BF16 | 0.0017 / 0.0057 | 6.92717 / 6.92149 |
| MXFP8, run 1 | 0.0034 / 0.0086 | 6.94351 / 6.95157 |
| MXFP8, run 2 | 0.00025 / 0.0012 | 6.95231 / 6.95157 |
The two MXFP8 runs of this recipe differ from each other by 0.0035, so the run 1 gap is run-to-run noise. Step 1 matches the references exactly, and step-1 and step-2 peak memory match to 0.01 GiB.
## Performance
64 GB300 GPUs (16 nodes x 4), 100 steps. tps and TFLOPs are per GPU as logged by torchtitan, mean of steps 71-90. These runs used the launcher-built reference config, which matches these recipes field by field (see Numerics), on an earlier revision of this stack and of activation offload (#6020).
| Recipe | tps | TFLOPs |
| --- | ---: | ---: |
| `muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark` | 5,166 | 1,691 |
| `muse_spark_816b_a42b_dist_moe_bf16_spmd_64_benchmark` | 3,869 | 1,267 |
Forced balanced routing makes these benchmark numbers, not real-training numbers.
## Testing
- `pytest tests/unit_tests/cpu/recipes`: the new recipes build; the MLA override tests also pass when run alone.
- Config build of all four benchmark recipes, diffed field by field as above.
- FakePG, logical 64 GPUs, rank 0, 10 steps, both `_fake` recipes: MXFP8 step-2 peak 239.52 allocated / 252.68 reserved GiB, the same as an earlier FakePG run of this config. Activation offload moves 124.73 GiB (MXFP8) and 100.90 GiB (BF16) per forward, the same as the reference real runs.
- 64 GPUs, 100 steps, both precisions (MXFP8 twice): all ranks exit 0; numerics above.
## Known issues / follow-ups
- The numbers predate #6137 (activation reloads wait on FSDP2's copy-in stream). Its effect on these recipes is not measured.
- torchtitan does not check that a CP group sits in one NVLink domain.
- With FSDP symmetric memory and EP, `destroy_process_group` can hang after training. The recipe cannot skip it; the launcher must.
- `pytorch/pytorch#204942` is required: without it step 1 runs out of memory. This was measured with DP8/CP8, not rechecked with DP32/CP2.
stack-info: PR: #6252, branch: fegin/stack/45
fegin
marked this pull request as ready for review
November 30, 2026 22:55
fegin
requested review from
acisseJZhong,
felipemello1,
shuhuayu,
tianyu-l and
wwwjn
as code owners
November 30, 2026 22:55
fegin
added a commit
that referenced
this pull request
Nov 30, 2026
…ctivation offload
## Summary (human-written)
<!-- Write this yourself, not with an AI tool. 2-5 sentences: the problem, why
this approach, and what you checked yourself. -->
## Why
Our fastest Muse Spark 816B runs on 64 GPUs cannot be reproduced from the repo. They start from the 64-GPU recipe and change it in an out-of-tree launcher: layout, forced routing, Dist-MoE budgets, remat and offload policy, Adam moment placement, the optimizer CUDA graph, and FSDP symmetric memory. The launch environment and the dependency versions are not written down anywhere either.
The 64-GPU recipe also all-gathers the K/V of the full 32K sequence in every layer. The sliding-window varlen layers (46 of 62 layers, 2048-token window) read only the blocks inside their window, so most of that K/V is never used.
**Example.**
```text
before: muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64, then the launcher sets
DP32/CP2, forced routing, scratch 2, slot factor 0, remat p3,
offload attention + MoE projections, moments on GPU, optimizer graph,
FSDP symmetric memory, c4_test, 100 steps
after: --module torchtitan_recipes.models.muse_spark \
--config muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark
```
## What changed
- The Muse K/V-gather CP transform maps `SlidingWindowVarlenInnerAttention` to `SelectiveGatherKVSlidingWindowVarlenInnerAttention`. Global layers keep `AllGatherKVVarlenInnerAttention`. This applies to every 64-GPU recipe.
- The Muse save region becomes `attention.inner_attention*`, so the selective-gather assembly region nested in attention is saved with it. torch_remat rejects a recomputed region inside a saved one. The 256- and 512-GPU and UltraData recipes have no region nested in attention, so the wildcard does not change them.
- `_muse_spark_816b_dist_moe_spmd_64` takes `context_parallel_degree`; FSDP gets the other 64 / CP ranks. The existing 64-GPU recipes pass 8, as before.
- New `muse_spark_816b_a42b_dist_moe_{bf16,mxfp8}_spmd_64_benchmark` recipes and their `_fake` variants. They are benchmark only: forced balanced routing does not train a usable model.
| Setting | BF16 | MXFP8 |
| --- | --- | --- |
| layout | DP32, CP2, EP64, 2 microbatches per step | same |
| routing | forced balanced (round robin) | same |
| Dist-MoE | scratch_capacity_factor 2, activation_slot_capacity_factor 0 | same |
| remat save regions | Dist-MoE defaults + `attention.*` | + pooler, unpooler, router |
| activation offload | block input + `attention.*`, not in the last block | + pooler, unpooler, router |
| Adam moments | GPU (moment_cpu_offload_fraction 0.0) | same |
| CUDA graphs | per microbatch group + optimizer graph | same |
| FSDP symmetric memory | scope all (off in `_fake`) | same |
| data | c4_test, random init, 100 steps (10 in `_fake`) | same |
- The benchmark docstring lists the launch environment (`NCCL_NVLS_ENABLE=1`, `PYTORCH_ALLOC_CONF=pinned_max_round_threshold_mb:1`, one NVLink domain per CP group, skipping `destroy_process_group`) and the dependency versions.
## Dependencies
- PyTorch nightly from 2026-11-20 or later. Activation offload on main calls `FSDPModule.get_all_gather_copy_in_stream` (pytorch/pytorch#205180).
- Depends on meta-pytorch/attention-gym#651 (selective gather); the attention-gym pin bump lands separately.
## How to reproduce
Stage the Muse Spark Open tokenizer files at `./assets/hf/Muse-Spark-Open-816B-A42B`, then on each of 16 hosts (4 GPUs each, all in one NVLink domain):
```bash
NCCL_NVLS_ENABLE=1 PYTORCH_ALLOC_CONF=pinned_max_round_threshold_mb:1 \
torchrun --nnodes 16 --nproc-per-node 4 --node-rank <i> \
--master-addr <host 0> --master-port 29500 -m torchtitan.train \
--module torchtitan_recipes.models.muse_spark \
--config muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark
```
Use `..._bf16_spmd_64_benchmark` for BF16. Measure tps as the mean of steps 71-90.
## Numerics
No model or kernel change. Forced routing makes the loss meaningless for training quality; it is only a run-to-run check.
The benchmark recipes build the same effective config as the launcher-built reference runs, field by field, except: `offload_last_block=False` in the reference runs, which #6020 removed (the recipes keep the last block on GPU with a `BlockRematOverride`, the same per-block offload plan), the new `per_sample_pad_multiple=1` dataloader default from main, main's RoPE `scaling='none'` -> `scaling=None` refactor, the launcher's profiler settings, and the tokenizer path.
100-step runs on 64 GPUs vs the reference runs of the same precision:
| Recipe | Mean / max abs loss diff | Loss at step 100 (new / reference) |
| --- | --- | --- |
| BF16 | 0.0017 / 0.0057 | 6.92717 / 6.92149 |
| MXFP8, run 1 | 0.0034 / 0.0086 | 6.94351 / 6.95157 |
| MXFP8, run 2 | 0.00025 / 0.0012 | 6.95231 / 6.95157 |
The two MXFP8 runs of this recipe differ from each other by 0.0035, so the run 1 gap is run-to-run noise. Step 1 matches the references exactly, and step-1 and step-2 peak memory match to 0.01 GiB.
## Performance
64 GB300 GPUs (16 nodes x 4), 100 steps. tps and TFLOPs are per GPU as logged by torchtitan, mean of steps 71-90. These runs used the launcher-built reference config, which matches these recipes field by field (see Numerics), on an earlier revision of this stack and of activation offload (#6020). These runs used `max_num_documents=64`. #5882 raises it to 128, which removes the padding (10.7% of the tokens on C4) and lowers the reported tps, because tps counts padding tokens.
| Recipe | tps | TFLOPs |
| --- | ---: | ---: |
| `muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark` | 5,166 | 1,691 |
| `muse_spark_816b_a42b_dist_moe_bf16_spmd_64_benchmark` | 3,869 | 1,267 |
Forced balanced routing makes these benchmark numbers, not real-training numbers.
## Testing
- `pytest tests/unit_tests/cpu/recipes`: the new recipes build; the MLA override tests also pass when run alone.
- Config build of all four benchmark recipes, diffed field by field as above.
- FakePG, logical 64 GPUs, rank 0, 10 steps, both `_fake` recipes: MXFP8 step-2 peak 239.52 allocated / 252.68 reserved GiB, the same as an earlier FakePG run of this config. Activation offload moves 124.73 GiB (MXFP8) and 100.90 GiB (BF16) per forward, the same as the reference real runs.
- 64 GPUs, 100 steps, both precisions (MXFP8 twice): all ranks exit 0; numerics above.
## Known issues / follow-ups
- The numbers predate #6137 (activation reloads wait on FSDP2's copy-in stream). Its effect on these recipes is not measured.
- torchtitan does not check that a CP group sits in one NVLink domain.
- With FSDP symmetric memory and EP, `destroy_process_group` can hang after training. The recipe cannot skip it; the launcher must.
- `pytorch/pytorch#204942` is required: without it step 1 runs out of memory. This was measured with DP8/CP8, not rechecked with DP32/CP2.
stack-info: PR: #6252, branch: fegin/stack/45
fegin
force-pushed
the
fegin/stack/45
branch
from
November 30, 2026 23:00
f63f3a9 to
9ea656e
Compare
fegin
marked this pull request as draft
November 30, 2026 23:07
fegin
added a commit
that referenced
this pull request
Dec 1, 2026
Stacked PRs: * #6252 * #5746 * #6135 * #6134 * #6133 * #6132 * __->__#5882 * #5881 (landed) --- --- --- ### [muse_spark] Add a 64-GPU Dist-MoE recipe with varlen attention ## Summary (human-written) With the CPU-offloading optimizer, we can run Muse Spark with 64 GPUs. This PR adds a recipe to demonstrate it. ## Why The Dist-MoE scale recipes run only on 256 or 512 GPUs, and they use FlexAttention only. #5706 added `attn_backend` to `muse_spark_816b_a42b` and listed three blockers for varlen in these recipes: their loader sets no `max_num_documents`, varlen K/V all-gather is untested on Muse, and `use_flex_flash_attention` raises on non-flex layers. This change removes those blockers and adds a 64-GPU recipe. It covers the #5706 follow-up "Varlen K/V all-gather CP for the Dist-MoE scale recipes". **Example.** ```text before: muse_spark_816b_a42b_dist_moe_bf16_spmd_256 / _512 only, FlexAttention after: muse_spark_816b_a42b_dist_moe_bf16_spmd_64 (and _64_fake): Muse Spark 816B, BF16 Dist-MoE, DP8 / CP8 (K/V all-gather) / EP64, TP1, 32K sequence length, global batch 64, varlen attention with max_num_documents=128, Adam moments in pinned host memory ``` ## What changed **Recipe helpers** - `_muse_spark_816b_dist_moe_bf16_spmd` takes `attn_backend: Literal["flex", "varlen"]` and `max_num_documents`. It passes `attn_backend` to `muse_spark_816b_a42b`. - It sets the data loader's `max_num_documents` before `_with_dist_moe` enables CUDA graphs, because `Trainer.Config` validation checks varlen against CUDA graphs. - The FakePG data loader keeps `max_num_documents`. It replaces only the dataset and shuffle fields of the data loader config. - The K/V all-gather CP transform also maps `VarlenInnerAttention` and `SlidingWindowVarlenInnerAttention`. - Flex-Flash block-mask tuning applies only with FlexAttention. **New recipes** - `muse_spark_816b_a42b_dist_moe_bf16_spmd_64` and `muse_spark_816b_a42b_dist_moe_bf16_spmd_64_fake`. Remat also saves all attention regions (`attention.*`). - The 64-GPU recipe sets `fsdp_reshard_after_forward = "default"` instead of the helper's `"always"`. With PP off, only the last [norm, lm_head] FSDP unit changes: it stays unsharded after forward, so the loss does not all-gather the 3 GiB lm_head weight again. - `max_num_documents=128` is one slot per 256 tokens. The packer never drops documents: a row that reaches the cap ends early and is padded, and the rest of the document starts the next row. On C4 with the Muse Spark tokenizer (600 rows on each of 8 DP ranks), documents average 460 tokens. 64 slots pad 10.7% of the tokens, and 80% of the rows reach the cap. 128 slots pad none. - The data loader and AdamW configs are updated with `dataclasses.replace`, so their `__post_init__` checks run (`max_num_documents > 0`; `moment_cpu_offload_fraction > 0` needs `fused=True` and rejects accelerators other than CUDA, including ROCm). **README** (`torchtitan/models/muse_spark/README.md`) - Context parallelism: varlen attention supports both Ulysses and K/V all-gather. - CP load balancing: head-tail works with K/V all-gather varlen. - K/V all-gather CP needs tokens per microbatch divisible by the CP degree, or by 2 x the CP degree with head-tail. The query block size rule applies only with FlexAttention. - Varlen attention with CUDA graphs requires `dataloader.max_num_documents`. Without it, set `training.disable_accelerator_graphs`. - A table lists the Dist-MoE scale recipes. ## Numerics The 256- and 512-GPU and UltraData recipe configs are unchanged (0 field diffs). ## Testing - `muse_spark_816b_a42b_dist_moe_bf16_spmd_64_fake` (NGPU=64, NUMA-bound) runs and fits on one GPU of the fake-PG layout for 10 steps. - Varlen K/V all-gather also runs with head-tail load balancing on the same layout. - Muse Spark recipe and model CPU unit tests. - Both 64-GPU recipes build and pass `Trainer.Config` validation. - `test_fake_scale_recipe_tokenizer[muse_spark_816b_a42b_dist_moe_bf16_spmd_64_fake]` builds the 64-GPU fake recipe. It catches a broken build, including a varlen layer type that the K/V all-gather CP map misses (the build raises "No CP inner attention configured"). ## Known issues / follow-ups - The real recipe ran on 64 GPUs for 20 steps at an earlier rebase of this stack, with the same save regions, real routing, and `max_num_documents=64`. Peak memory was 267.4 GiB (trainer) and 272.7 GiB (NVML) of 276.6 GiB, so only about 4 GiB is free. tps was about 2% higher than with the default save regions (1,716 vs 1,683). - On 64 real GPUs with the same setup, `fsdp_reshard_after_forward = "default"` lowered peak memory by 1.9 GiB (265.5 vs 267.4 GiB trainer, 270.8 vs 272.7 GiB NVML), and tps did not change (1,725 vs 1,716). The 256- and 512-GPU recipes keep `"always"`. - `max_num_documents=128` was run on 64 real GPUs only with the whole recipe stack, which also shards the vocab over CP and frees memory. There, peak allocated memory was the same as with 64 slots. It is not run at this commit alone, where only about 4 GiB is free. - tps counts padding tokens, and padding rows skip the routed experts. So 128 slots lower the reported tps but raise the real tokens trained per second. - `test_debug_recipe_tokenizer[muse_spark_debugmodel_mm]` also fails on main.
fegin
added a commit
that referenced
this pull request
Dec 1, 2026
…ctivation offload
## Summary (human-written)
<!-- Write this yourself, not with an AI tool. 2-5 sentences: the problem, why
this approach, and what you checked yourself. -->
## Why
Our fastest Muse Spark 816B runs on 64 GPUs cannot be reproduced from the repo. They start from the 64-GPU recipe and change it in an out-of-tree launcher: layout, forced routing, Dist-MoE budgets, remat and offload policy, Adam moment placement, the optimizer CUDA graph, and FSDP symmetric memory. The launch environment and the dependency versions are not written down anywhere either.
The 64-GPU recipe also all-gathers the K/V of the full 32K sequence in every layer. The sliding-window varlen layers (46 of 62 layers, 2048-token window) read only the blocks inside their window, so most of that K/V is never used.
**Example.**
```text
before: muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64, then the launcher sets
DP32/CP2, forced routing, scratch 2, slot factor 0, remat p3,
offload attention + MoE projections, moments on GPU, optimizer graph,
FSDP symmetric memory, c4_test, 100 steps
after: --module torchtitan_recipes.models.muse_spark \
--config muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark
```
## What changed
- The Muse K/V-gather CP transform maps `SlidingWindowVarlenInnerAttention` to `SelectiveGatherKVSlidingWindowVarlenInnerAttention`. Global layers keep `AllGatherKVVarlenInnerAttention`. This applies to every 64-GPU recipe.
- The Muse save region becomes `attention.inner_attention*`, so the selective-gather assembly region nested in attention is saved with it. torch_remat rejects a recomputed region inside a saved one. The 256- and 512-GPU and UltraData recipes have no region nested in attention, so the wildcard does not change them.
- `_muse_spark_816b_dist_moe_spmd_64` takes `context_parallel_degree`; FSDP gets the other 64 / CP ranks. The existing 64-GPU recipes pass 8, as before.
- New `muse_spark_816b_a42b_dist_moe_{bf16,mxfp8}_spmd_64_benchmark` recipes and their `_fake` variants. They are benchmark only: forced balanced routing does not train a usable model.
| Setting | BF16 | MXFP8 |
| --- | --- | --- |
| layout | DP32, CP2, EP64, 2 microbatches per step | same |
| routing | forced balanced (round robin) | same |
| Dist-MoE | scratch_capacity_factor 2, activation_slot_capacity_factor 0 | same |
| remat save regions | Dist-MoE defaults + `attention.*` | + pooler, unpooler, router |
| activation offload | block input + `attention.*`, not in the last block | + pooler, unpooler, router |
| Adam moments | GPU (moment_cpu_offload_fraction 0.0) | same |
| CUDA graphs | per microbatch group + optimizer graph | same |
| FSDP symmetric memory | scope all (off in `_fake`) | same |
| data | c4_test, random init, 100 steps (10 in `_fake`) | same |
- The benchmark docstring lists the launch environment (`NCCL_NVLS_ENABLE=1`, `PYTORCH_ALLOC_CONF=pinned_max_round_threshold_mb:1`, one NVLink domain per CP group, skipping `destroy_process_group`) and the dependency versions.
## Dependencies
- PyTorch nightly from 2026-11-20 or later. Activation offload on main calls `FSDPModule.get_all_gather_copy_in_stream` (pytorch/pytorch#205180).
- Depends on meta-pytorch/attention-gym#651 (selective gather); the attention-gym pin bump lands separately.
## How to reproduce
Stage the Muse Spark Open tokenizer files at `./assets/hf/Muse-Spark-Open-816B-A42B`, then on each of 16 hosts (4 GPUs each, all in one NVLink domain):
```bash
NCCL_NVLS_ENABLE=1 PYTORCH_ALLOC_CONF=pinned_max_round_threshold_mb:1 \
torchrun --nnodes 16 --nproc-per-node 4 --node-rank <i> \
--master-addr <host 0> --master-port 29500 -m torchtitan.train \
--module torchtitan_recipes.models.muse_spark \
--config muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark
```
Use `..._bf16_spmd_64_benchmark` for BF16. Measure tps as the mean of steps 71-90.
## Numerics
No model or kernel change. Forced routing makes the loss meaningless for training quality; it is only a run-to-run check.
The benchmark recipes build the same effective config as the launcher-built reference runs, field by field, except: `offload_last_block=False` in the reference runs, which #6020 removed (the recipes keep the last block on GPU with a `BlockRematOverride`, the same per-block offload plan), the new `per_sample_pad_multiple=1` dataloader default from main, main's RoPE `scaling='none'` -> `scaling=None` refactor, the launcher's profiler settings, and the tokenizer path.
100-step runs on 64 GPUs vs the reference runs of the same precision:
| Recipe | Mean / max abs loss diff | Loss at step 100 (new / reference) |
| --- | --- | --- |
| BF16 | 0.0017 / 0.0057 | 6.92717 / 6.92149 |
| MXFP8, run 1 | 0.0034 / 0.0086 | 6.94351 / 6.95157 |
| MXFP8, run 2 | 0.00025 / 0.0012 | 6.95231 / 6.95157 |
The two MXFP8 runs of this recipe differ from each other by 0.0035, so the run 1 gap is run-to-run noise. Step 1 matches the references exactly, and step-1 and step-2 peak memory match to 0.01 GiB.
## Performance
64 GB300 GPUs (16 nodes x 4), 100 steps. tps and TFLOPs are per GPU as logged by torchtitan, mean of steps 71-90. These runs used the launcher-built reference config, which matches these recipes field by field (see Numerics), on an earlier revision of this stack and of activation offload (#6020). These runs used `max_num_documents=64`. #5882 raises it to 128, which removes the padding (10.7% of the tokens on C4) and lowers the reported tps, because tps counts padding tokens.
| Recipe | tps | TFLOPs |
| --- | ---: | ---: |
| `muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark` | 5,166 | 1,691 |
| `muse_spark_816b_a42b_dist_moe_bf16_spmd_64_benchmark` | 3,869 | 1,267 |
Forced balanced routing makes these benchmark numbers, not real-training numbers.
## Testing
- `pytest tests/unit_tests/cpu/recipes`: the new recipes build; the MLA override tests also pass when run alone.
- Config build of all four benchmark recipes, diffed field by field as above.
- FakePG, logical 64 GPUs, rank 0, 10 steps, both `_fake` recipes: MXFP8 step-2 peak 239.52 allocated / 252.68 reserved GiB, the same as an earlier FakePG run of this config. Activation offload moves 124.73 GiB (MXFP8) and 100.90 GiB (BF16) per forward, the same as the reference real runs.
- 64 GPUs, 100 steps, both precisions (MXFP8 twice): all ranks exit 0; numerics above.
## Known issues / follow-ups
- The numbers predate #6137 (activation reloads wait on FSDP2's copy-in stream). Its effect on these recipes is not measured.
- torchtitan does not check that a CP group sits in one NVLink domain.
- With FSDP symmetric memory and EP, `destroy_process_group` can hang after training. The recipe cannot skip it; the launcher must.
- `pytorch/pytorch#204942` is required: without it step 1 runs out of memory. This was measured with DP8/CP8, not rechecked with DP32/CP2.
stack-info: PR: #6252, branch: fegin/stack/45
fegin
added a commit
that referenced
this pull request
Dec 1, 2026
…ctivation offload
## Summary (human-written)
<!-- Write this yourself, not with an AI tool. 2-5 sentences: the problem, why
this approach, and what you checked yourself. -->
## Why
Our fastest Muse Spark 816B runs on 64 GPUs cannot be reproduced from the repo. They start from the 64-GPU recipe and change it in an out-of-tree launcher: layout, forced routing, Dist-MoE budgets, remat and offload policy, Adam moment placement, the optimizer CUDA graph, and FSDP symmetric memory. The launch environment and the dependency versions are not written down anywhere either.
The 64-GPU recipe also all-gathers the K/V of the full 32K sequence in every layer. The sliding-window varlen layers (46 of 62 layers, 2048-token window) read only the blocks inside their window, so most of that K/V is never used.
**Example.**
```text
before: muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64, then the launcher sets
DP32/CP2, forced routing, scratch 2, slot factor 0, remat p3,
offload attention + MoE projections, moments on GPU, optimizer graph,
FSDP symmetric memory, c4_test, 100 steps
after: --module torchtitan_recipes.models.muse_spark \
--config muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark
```
## What changed
- The Muse K/V-gather CP transform maps `SlidingWindowVarlenInnerAttention` to `SelectiveGatherKVSlidingWindowVarlenInnerAttention`. Global layers keep `AllGatherKVVarlenInnerAttention`. This applies to every 64-GPU recipe.
- The Muse save region becomes `attention.inner_attention*`, so the selective-gather assembly region nested in attention is saved with it. torch_remat rejects a recomputed region inside a saved one. The 256- and 512-GPU and UltraData recipes have no region nested in attention, so the wildcard does not change them.
- `_muse_spark_816b_dist_moe_spmd_64` takes `context_parallel_degree`; FSDP gets the other 64 / CP ranks. The existing 64-GPU recipes pass 8, as before.
- New `muse_spark_816b_a42b_dist_moe_{bf16,mxfp8}_spmd_64_benchmark` recipes and their `_fake` variants. They are benchmark only: forced balanced routing does not train a usable model.
| Setting | BF16 | MXFP8 |
| --- | --- | --- |
| layout | DP32, CP2, EP64, 2 microbatches per step | same |
| routing | forced balanced (round robin) | same |
| Dist-MoE | scratch_capacity_factor 2, activation_slot_capacity_factor 0 | same |
| remat save regions | Dist-MoE defaults + `attention.*` | + pooler, unpooler, router |
| activation offload | block input + `attention.*`, not in the last block | + pooler, unpooler, router |
| Adam moments | GPU (moment_cpu_offload_fraction 0.0) | same |
| CUDA graphs | per microbatch group + optimizer graph | same |
| FSDP symmetric memory | scope all (off in `_fake`) | same |
| data | c4_test, random init, 100 steps (10 in `_fake`) | same |
- The benchmark docstring lists the launch environment (`NCCL_NVLS_ENABLE=1`, `PYTORCH_ALLOC_CONF=pinned_max_round_threshold_mb:1`, one NVLink domain per CP group, skipping `destroy_process_group`) and the dependency versions.
## Dependencies
- PyTorch nightly from 2026-11-20 or later. Activation offload on main calls `FSDPModule.get_all_gather_copy_in_stream` (pytorch/pytorch#205180).
- Depends on meta-pytorch/attention-gym#651 (selective gather); the attention-gym pin bump lands separately.
## How to reproduce
Stage the Muse Spark Open tokenizer files at `./assets/hf/Muse-Spark-Open-816B-A42B`, then on each of 16 hosts (4 GPUs each, all in one NVLink domain):
```bash
NCCL_NVLS_ENABLE=1 PYTORCH_ALLOC_CONF=pinned_max_round_threshold_mb:1 \
torchrun --nnodes 16 --nproc-per-node 4 --node-rank <i> \
--master-addr <host 0> --master-port 29500 -m torchtitan.train \
--module torchtitan_recipes.models.muse_spark \
--config muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark
```
Use `..._bf16_spmd_64_benchmark` for BF16. Measure tps as the mean of steps 71-90.
## Numerics
No model or kernel change. Forced routing makes the loss meaningless for training quality; it is only a run-to-run check.
The benchmark recipes build the same effective config as the launcher-built reference runs, field by field, except: `offload_last_block=False` in the reference runs, which #6020 removed (the recipes keep the last block on GPU with a `BlockRematOverride`, the same per-block offload plan), the new `per_sample_pad_multiple=1` dataloader default from main, main's RoPE `scaling='none'` -> `scaling=None` refactor, the launcher's profiler settings, and the tokenizer path.
100-step runs on 64 GPUs vs the reference runs of the same precision:
| Recipe | Mean / max abs loss diff | Loss at step 100 (new / reference) |
| --- | --- | --- |
| BF16 | 0.0017 / 0.0057 | 6.92717 / 6.92149 |
| MXFP8, run 1 | 0.0034 / 0.0086 | 6.94351 / 6.95157 |
| MXFP8, run 2 | 0.00025 / 0.0012 | 6.95231 / 6.95157 |
The two MXFP8 runs of this recipe differ from each other by 0.0035, so the run 1 gap is run-to-run noise. Step 1 matches the references exactly, and step-1 and step-2 peak memory match to 0.01 GiB.
## Performance
64 GB300 GPUs (16 nodes x 4), 100 steps. tps and TFLOPs are per GPU as logged by torchtitan, mean of steps 71-90. These runs used the launcher-built reference config, which matches these recipes field by field (see Numerics), on an earlier revision of this stack and of activation offload (#6020). These runs used `max_num_documents=64`. #5882 raises it to 128, which removes the padding (10.7% of the tokens on C4) and lowers the reported tps, because tps counts padding tokens.
| Recipe | tps | TFLOPs |
| --- | ---: | ---: |
| `muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark` | 5,166 | 1,691 |
| `muse_spark_816b_a42b_dist_moe_bf16_spmd_64_benchmark` | 3,869 | 1,267 |
Forced balanced routing makes these benchmark numbers, not real-training numbers.
## Testing
- `pytest tests/unit_tests/cpu/recipes`: the new recipes build; the MLA override tests also pass when run alone.
- Config build of all four benchmark recipes, diffed field by field as above.
- FakePG, logical 64 GPUs, rank 0, 10 steps, both `_fake` recipes: MXFP8 step-2 peak 239.52 allocated / 252.68 reserved GiB, the same as an earlier FakePG run of this config. Activation offload moves 124.73 GiB (MXFP8) and 100.90 GiB (BF16) per forward, the same as the reference real runs.
- 64 GPUs, 100 steps, both precisions (MXFP8 twice): all ranks exit 0; numerics above.
## Known issues / follow-ups
- The numbers predate #6137 (activation reloads wait on FSDP2's copy-in stream). Its effect on these recipes is not measured.
- torchtitan does not check that a CP group sits in one NVLink domain.
- With FSDP symmetric memory and EP, `destroy_process_group` can hang after training. The recipe cannot skip it; the launcher must.
- `pytorch/pytorch#204942` is required: without it step 1 runs out of memory. This was measured with DP8/CP8, not rechecked with DP32/CP2.
stack-info: PR: #6252, branch: fegin/stack/45
fegin
added a commit
that referenced
this pull request
Dec 1, 2026
…6132) Stacked PRs: * #6252 * #5746 * #6135 * #6134 * #6133 * #6468 * __->__#6132 * #5882 (landed) * #5881 (landed) --- --- --- ### [trainer][perf] Log training metrics without waiting for the device ## Summary (human-written) TorchTitan's logging currently waits for the device. But it can actually be overlapped with the next step. Right now we have to adjust the logging frequency to avoid logging being the bottleneck. This is very annoying. With this PR, we can set logging frequency to 1 which is very useful when the cluster resource is busy and we don't have luxury to run many iterations. Follows the design of #2728 and fixes some issues. ## Why Each logged step reads its metrics right after `optim_step()`. The first read, `int(global_main_loss_token_count)`, and the `.item()` calls after it wait until the device finishes the optimizer update. Only then does the host fetch, preprocess, and copy the next step's inputs, so the device sits idle before the next step's first kernel or CUDA graph. With `log_freq=1` this happens every step. Blocking host-to-device copies wait for the update too: the global token count before the next forward, and the token and FLOP counts that the logged reductions create with `torch.tensor(..., device=...)`. ```text before: optim_step | .item() waits for the update | fetch, preprocess, H2D | device idle | forward after: optim_step | queue metric copies | fetch, preprocess, H2D, queue forward | print the previous step ``` #2728 deferred the same reads by one step. It was closed without merging: the review asked to wait for #4202 (distributed tensor logging), so metrics could handle device and host values together. #4202 is still open, and it adds per-tensor statistics; it does not remove these per-step reads. This change is small and self-contained, so it can land now and move onto #4202's mechanism when that lands. ## What changed - `MetricsProcessor.log_async` takes the logged values as tensors or floats. It starts a non-blocking host copy of each tensor and returns. `flush()` waits for those copies and emits the metrics. `log()` is `log_async()` plus `flush()`, so other callers keep their behavior. - The global token count, and the token and FLOP counts reduced for logging, are copied to the device with `non_blocking=True`. A blocking copy from pageable memory waits for the previous optimizer update. - `Trainer.train_step` calls `log_async` and flushes the previous logged step after queuing its own forward and backward. `train()` also flushes before validation and when training ends, so log lines keep their order. - The throughput window ends when the device reaches the `log_async` call. It is timed with device events recorded at `reset()` and at `log_async`. A checkpoint saved after the step is not in its window, as before. Validation throughput is timed with the same events. Runs without an accelerator (`torch.accelerator.is_available()` is false) use the host clock. Token count, data loading time, and peak memory are read at `log_async`, so data the next step fetches before the flush is not counted. - The logged reductions keep their results on the device: `dist_sum_tensor`, a new `dist_max_tensor`, and `dist_mean_tensor` (renamed from `dist_mean` to match the other two). `collect_aux_loss_metrics` returns device scalars, divided in float64 as before, and the RL trainer converts them where it needs floats. - The `global_valid_tokens` trace record is passed to `log_async` apart from the metrics and emitted at the flush. `log_trace_scalar` takes optional `step` and `relative_step`, so the record keeps the step it belongs to. Its step tags come from the step that flushes it. ## User-facing changes | | Before | After | |---|---|---| | Training log line of step N | printed during step N | printed during step N+1, after its work is queued | | `dist_mean` | returns a float | renamed `dist_mean_tensor`, returns a device tensor | | `collect_aux_loss_metrics` | returns floats | returns device scalars | The order of log lines (training before validation of the same step), metric keys, and values are unchanged. ## Numerics / performance Loss and grad_norm are unchanged; only when they are read changes. llama3 debug model, 2 GPUs, seed 42, deterministic, 12 steps with `log_freq=5`, validation, and a checkpoint at step 10: loss, grad_norm, and validation loss match the parent commit at every logged step. Peak reserved memory of step 1 is 0.89 GiB vs 0.78 GiB on the parent; later steps match (0.80 GiB). Freed blocks used by other streams go back to the allocator later when the host runs ahead. 64 real GB300 GPUs, `muse_spark_816b_a42b_dist_moe_bf16_spmd_64` (DP8/CP8/EP64, 32K, pinned-host Adam moments, log_freq=1), 100 steps from random init: 2,122.2 -> 2,158.7 tps over steps 71-90 (+1.7%). Step-1 peak allocated memory is unchanged (257.82 GiB). FakePG run of the same recipe (`_fake`), one GPU, NUMA-bound, arms alternated on the same GPU, median tps of steps 5-10 (log_freq=1) or the steps 11-20 window (log_freq=10), relative to the parent commit: | | log_freq=1 | log_freq=10 | |---|---|---| | parent | 1.000 | 1.000 | | this commit | 1.028, 1.029, 1.027 | 1.009, 1.009 | Logging every step costs the parent 1.8%; this commit removes that cost. Host wall time per step agrees with the event-timed tps (-2.9%). Peak memory is unchanged. Copying each value separately costs at most 0.1% compared with one stacked copy. An earlier version without the non-blocking count copies gave no gain at log_freq=1. With `debug.seed=42`, losses match the parent within the parent's own run-to-run noise on this recipe. ## Testing - `test_async_log_uses_the_window_at_log_time`: data fetched before the flush must not count in the logged step's throughput window, and the emitted values must match the logged tensors. The deferred trace record must carry the logged step and relative step. The loss is (1,)-shaped, like the loss on PP ranks without the last stage, while grad_norm is 0-dim. - `test_trainer_accumulates_reused_accelerator_graph_losses` checks the values passed to `log_async` and that each step flushes. - `pytest tests/unit_tests/cpu/test_trainer.py tests/unit_tests/cpu/observability tests/unit_tests/cpu/components/test_invalid_loss.py tests/unit_tests/cpu/components/test_validator.py tests/unit_tests/cpu/models/common/test_aux_loss.py`: 244 passed, 1 skipped, with GPUs visible and with `CUDA_VISIBLE_DEVICES=` (no accelerator). - llama3 debug model, 2 GPUs, seed 42, deterministic: loss and grad_norm in TensorBoard are bitwise equal to the parent commit at every logged step for FSDP 2 with 20 steps at `log_freq=1` and `log_freq=10`, and for PP 2 with 1F1B (`llama3_debugmodel_pp2_1f1b`) with 10 steps at `log_freq=1`. The PP run checks that the rank without the last stage can log its (1,)-shaped loss sentinel. - `test_trainer_keeps_scheduled_eval_during_warmup`: its fake trainer gets a `metrics_processor`, since `train()` flushes before validation. ## Known issues / follow-ups - An error raised after a step is logged but before the flush, for example an NCCL timeout, loses that step's log line. - #4202 (distributed tensor logging) is a separate mechanism for per-tensor statistics; it does not remove these reads. This change was written with an AI assistant (Claude).
fegin
added a commit
that referenced
this pull request
Dec 1, 2026
…ctivation offload
## Summary (human-written)
<!-- Write this yourself, not with an AI tool. 2-5 sentences: the problem, why
this approach, and what you checked yourself. -->
## Why
Our fastest Muse Spark 816B runs on 64 GPUs cannot be reproduced from the repo. They start from the 64-GPU recipe and change it in an out-of-tree launcher: layout, forced routing, Dist-MoE budgets, remat and offload policy, Adam moment placement, the optimizer CUDA graph, and FSDP symmetric memory. The launch environment and the dependency versions are not written down anywhere either.
The 64-GPU recipe also all-gathers the K/V of the full 32K sequence in every layer. The sliding-window varlen layers (46 of 62 layers, 2048-token window) read only the blocks inside their window, so most of that K/V is never used.
**Example.**
```text
before: muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64, then the launcher sets
DP32/CP2, forced routing, scratch 2, slot factor 0, remat p3,
offload attention + MoE projections, moments on GPU, optimizer graph,
FSDP symmetric memory, c4_test, 100 steps
after: --module torchtitan_recipes.models.muse_spark \
--config muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark
```
## What changed
- The Muse K/V-gather CP transform maps `SlidingWindowVarlenInnerAttention` to `SelectiveGatherKVSlidingWindowVarlenInnerAttention`. Global layers keep `AllGatherKVVarlenInnerAttention`. This applies to every 64-GPU recipe.
- The Muse save region becomes `attention.inner_attention*`, so the selective-gather assembly region nested in attention is saved with it. torch_remat rejects a recomputed region inside a saved one. The 256- and 512-GPU and UltraData recipes have no region nested in attention, so the wildcard does not change them.
- `_muse_spark_816b_dist_moe_spmd_64` takes `context_parallel_degree`; FSDP gets the other 64 / CP ranks. The existing 64-GPU recipes pass 8, as before.
- New `muse_spark_816b_a42b_dist_moe_{bf16,mxfp8}_spmd_64_benchmark` recipes and their `_fake` variants. They are benchmark only: forced balanced routing does not train a usable model.
| Setting | BF16 | MXFP8 |
| --- | --- | --- |
| layout | DP32, CP2, EP64, 2 microbatches per step | same |
| routing | forced balanced (round robin) | same |
| Dist-MoE | scratch_capacity_factor 2, activation_slot_capacity_factor 0 | same |
| remat save regions | Dist-MoE defaults + `attention.*` | + pooler, unpooler, router |
| activation offload | block input + `attention.*`, not in the last block | + pooler, unpooler, router |
| Adam moments | GPU (moment_cpu_offload_fraction 0.0) | same |
| CUDA graphs | per microbatch group + optimizer graph | same |
| FSDP symmetric memory | scope all (off in `_fake`) | same |
| data | c4_test, random init, 100 steps (10 in `_fake`) | same |
- The benchmark docstring lists the launch environment (`NCCL_NVLS_ENABLE=1`, `PYTORCH_ALLOC_CONF=pinned_max_round_threshold_mb:1`, one NVLink domain per CP group, skipping `destroy_process_group`) and the dependency versions.
## Dependencies
- PyTorch nightly from 2026-11-20 or later. Activation offload on main calls `FSDPModule.get_all_gather_copy_in_stream` (pytorch/pytorch#205180).
- Depends on meta-pytorch/attention-gym#651 (selective gather); the attention-gym pin bump lands separately.
## How to reproduce
Stage the Muse Spark Open tokenizer files at `./assets/hf/Muse-Spark-Open-816B-A42B`, then on each of 16 hosts (4 GPUs each, all in one NVLink domain):
```bash
NCCL_NVLS_ENABLE=1 PYTORCH_ALLOC_CONF=pinned_max_round_threshold_mb:1 \
torchrun --nnodes 16 --nproc-per-node 4 --node-rank <i> \
--master-addr <host 0> --master-port 29500 -m torchtitan.train \
--module torchtitan_recipes.models.muse_spark \
--config muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark
```
Use `..._bf16_spmd_64_benchmark` for BF16. Measure tps as the mean of steps 71-90.
## Numerics
No model or kernel change. Forced routing makes the loss meaningless for training quality; it is only a run-to-run check.
The benchmark recipes build the same effective config as the launcher-built reference runs, field by field, except: `offload_last_block=False` in the reference runs, which #6020 removed (the recipes keep the last block on GPU with a `BlockRematOverride`, the same per-block offload plan), the new `per_sample_pad_multiple=1` dataloader default from main, main's RoPE `scaling='none'` -> `scaling=None` refactor, the launcher's profiler settings, and the tokenizer path.
100-step runs on 64 GPUs vs the reference runs of the same precision:
| Recipe | Mean / max abs loss diff | Loss at step 100 (new / reference) |
| --- | --- | --- |
| BF16 | 0.0017 / 0.0057 | 6.92717 / 6.92149 |
| MXFP8, run 1 | 0.0034 / 0.0086 | 6.94351 / 6.95157 |
| MXFP8, run 2 | 0.00025 / 0.0012 | 6.95231 / 6.95157 |
The two MXFP8 runs of this recipe differ from each other by 0.0035, so the run 1 gap is run-to-run noise. Step 1 matches the references exactly, and step-1 and step-2 peak memory match to 0.01 GiB.
## Performance
64 GB300 GPUs (16 nodes x 4), 100 steps. tps and TFLOPs are per GPU as logged by torchtitan, mean of steps 71-90. These runs used the launcher-built reference config, which matches these recipes field by field (see Numerics), on an earlier revision of this stack and of activation offload (#6020). These runs used `max_num_documents=64`. #5882 raises it to 128, which removes the padding (10.7% of the tokens on C4) and lowers the reported tps, because tps counts padding tokens.
| Recipe | tps | TFLOPs |
| --- | ---: | ---: |
| `muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark` | 5,166 | 1,691 |
| `muse_spark_816b_a42b_dist_moe_bf16_spmd_64_benchmark` | 3,869 | 1,267 |
Forced balanced routing makes these benchmark numbers, not real-training numbers.
## Testing
- `pytest tests/unit_tests/cpu/recipes`: the new recipes build; the MLA override tests also pass when run alone.
- Config build of all four benchmark recipes, diffed field by field as above.
- FakePG, logical 64 GPUs, rank 0, 10 steps, both `_fake` recipes: MXFP8 step-2 peak 239.52 allocated / 252.68 reserved GiB, the same as an earlier FakePG run of this config. Activation offload moves 124.73 GiB (MXFP8) and 100.90 GiB (BF16) per forward, the same as the reference real runs.
- 64 GPUs, 100 steps, both precisions (MXFP8 twice): all ranks exit 0; numerics above.
## Known issues / follow-ups
- The numbers predate #6137 (activation reloads wait on FSDP2's copy-in stream). Its effect on these recipes is not measured.
- torchtitan does not check that a CP group sits in one NVLink domain.
- With FSDP symmetric memory and EP, `destroy_process_group` can hang after training. The recipe cannot skip it; the launcher must.
- `pytorch/pytorch#204942` is required: without it step 1 runs out of memory. This was measured with DP8/CP8, not rechecked with DP32/CP2.
stack-info: PR: #6252, branch: fegin/stack/45
fegin
added a commit
that referenced
this pull request
Dec 1, 2026
#6468) Stacked PRs: * #6252 * #5746 * #6135 * #6134 * #6133 * __->__#6468 * #6132 (landed) * #5882 (landed) * #5881 (landed) --- --- --- ### [torchft] Log training metrics without waiting for the device ## Summary (human-written) <!-- Write this yourself, not with an AI tool. 2-5 sentences: the problem, why this approach, and what you checked yourself. --> ## Why #6132 makes the core trainer log through `MetricsProcessor.log_async`. The torchft trainer has its own `train_step` and still calls the blocking `MetricsProcessor.log()` with floats read by `dist_sum`, `dist_max`, and `.item()`. It is the only caller of `log()`, and the only reason `log_async` accepts floats for the loss and grad_norm. Moving it to `log_async` leaves one logging API with tensor-only loss and grad_norm. The speedup for torchft is small: `TorchFTOptim` already waits for the device every step (`step_is_finite.item()`), and so does `should_commit()`. The main value is the API cleanup. ## What changed - `FaultTolerantTrainer.train_step` reduces the logged values with `dist_sum_tensor` and `dist_max_tensor` (with `ft_pg`, as before), keeps grad_norm and the loss on the device, and calls `log_async`. It flushes the previous logged step after the next step's data is on the device and before `forward_backward`. The core trainer flushes after `forward_backward`, but here `zero_grad` in `forward_backward` starts the next quorum, which may reconfigure `ft_pg`, so the previous step's logging all-reduces on `ft_pg` must finish first, as they did before this change. - `train()` flushes before validation and when training ends, so log lines keep their order. - Host-to-device copies of the token counts and FLOPs use `non_blocking=True`, as in the core trainer. - `MetricsProcessor.log()` is deleted. `log_async` takes `global_avg_loss`, `global_max_loss`, and `grad_norm` as tensors only. `num_flops` stays `float | torch.Tensor`, because the trainers pass a Python float when DP is off. ## User-facing changes | | Before | After | |---|---|---| | torchft training log line of step N | printed during step N | printed during step N+1, before its forward | | `MetricsProcessor.log()` | blocking log | deleted; use `log_async()` and `flush()` | ## Numerics / performance Loss and grad_norm are unchanged; only when they are read changes. The divisions by the replica count are the same, applied to tensors instead of floats. ## Testing - `test_ft_averages_logged_loss_and_flops_by_active_replica_count` mocks the tensor reductions, and checks the values passed to `log_async`, that the logged sums go through `ft_pg`, and that the step flushes before `forward_backward`. - `pytest torchtitan/experiments/torchft/tests/test_torchft_trainer.py tests/unit_tests/cpu/test_trainer.py tests/unit_tests/cpu/observability tests/unit_tests/cpu/components/test_invalid_loss.py tests/unit_tests/cpu/components/test_validator.py tests/unit_tests/cpu/models/common/test_aux_loss.py`: 256 passed, 1 skipped. - Not run: the 8-GPU torchft integration test (torchft is not installable here). CI runs it. This change was written with an AI assistant (Claude).
fegin
added a commit
that referenced
this pull request
Dec 2, 2026
…ctivation offload
## Summary (human-written)
<!-- Write this yourself, not with an AI tool. 2-5 sentences: the problem, why
this approach, and what you checked yourself. -->
## Why
Our fastest Muse Spark 816B runs on 64 GPUs cannot be reproduced from the repo. They start from the 64-GPU recipe and change it in an out-of-tree launcher: layout, forced routing, Dist-MoE budgets, remat and offload policy, Adam moment placement, the optimizer CUDA graph, and FSDP symmetric memory. The launch environment and the dependency versions are not written down anywhere either.
The 64-GPU recipe also all-gathers the K/V of the full 32K sequence in every layer. The sliding-window varlen layers (46 of 62 layers, 2048-token window) read only the blocks inside their window, so most of that K/V is never used.
**Example.**
```text
before: muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64, then the launcher sets
DP32/CP2, forced routing, scratch 2, slot factor 0, remat p3,
offload attention + MoE projections, moments on GPU, optimizer graph,
FSDP symmetric memory, c4_test, 100 steps
after: --module torchtitan_recipes.models.muse_spark \
--config muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark
```
## What changed
- The Muse K/V-gather CP transform maps `SlidingWindowVarlenInnerAttention` to `SelectiveGatherKVSlidingWindowVarlenInnerAttention`. Global layers keep `AllGatherKVVarlenInnerAttention`. This applies to every 64-GPU recipe.
- The Muse save region becomes `attention.inner_attention*`, so the selective-gather assembly region nested in attention is saved with it. torch_remat rejects a recomputed region inside a saved one. The 256- and 512-GPU and UltraData recipes have no region nested in attention, so the wildcard does not change them.
- `_muse_spark_816b_dist_moe_spmd_64` takes `context_parallel_degree`; FSDP gets the other 64 / CP ranks. The existing 64-GPU recipes pass 8, as before.
- New `muse_spark_816b_a42b_dist_moe_{bf16,mxfp8}_spmd_64_benchmark` recipes and their `_fake` variants. They are benchmark only: forced balanced routing does not train a usable model.
| Setting | BF16 | MXFP8 |
| --- | --- | --- |
| layout | DP32, CP2, EP64, 2 microbatches per step | same |
| routing | forced balanced (round robin) | same |
| Dist-MoE | scratch_capacity_factor 2, activation_slot_capacity_factor 0 | same |
| remat save regions | Dist-MoE defaults + `attention.*` | + pooler, unpooler, router |
| activation offload | block input + `attention.*`, not in the last block | + pooler, unpooler, router |
| Adam moments | GPU (moment_cpu_offload_fraction 0.0) | same |
| CUDA graphs | per microbatch group + optimizer graph | same |
| FSDP symmetric memory | scope all (off in `_fake`) | same |
| data | c4_test, random init, 100 steps (10 in `_fake`) | same |
- The benchmark docstring lists the launch environment (`NCCL_NVLS_ENABLE=1`, `PYTORCH_ALLOC_CONF=pinned_max_round_threshold_mb:1`, one NVLink domain per CP group, skipping `destroy_process_group`) and the dependency versions.
## Dependencies
- PyTorch nightly from 2026-11-20 or later. Activation offload on main calls `FSDPModule.get_all_gather_copy_in_stream` (pytorch/pytorch#205180).
- Depends on meta-pytorch/attention-gym#651 (selective gather); the attention-gym pin bump lands separately.
## How to reproduce
Stage the Muse Spark Open tokenizer files at `./assets/hf/Muse-Spark-Open-816B-A42B`, then on each of 16 hosts (4 GPUs each, all in one NVLink domain):
```bash
NCCL_NVLS_ENABLE=1 PYTORCH_ALLOC_CONF=pinned_max_round_threshold_mb:1 \
torchrun --nnodes 16 --nproc-per-node 4 --node-rank <i> \
--master-addr <host 0> --master-port 29500 -m torchtitan.train \
--module torchtitan_recipes.models.muse_spark \
--config muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark
```
Use `..._bf16_spmd_64_benchmark` for BF16. Measure tps as the mean of steps 71-90.
## Numerics
No model or kernel change. Forced routing makes the loss meaningless for training quality; it is only a run-to-run check.
The benchmark recipes build the same effective config as the launcher-built reference runs, field by field, except: `offload_last_block=False` in the reference runs, which #6020 removed (the recipes keep the last block on GPU with a `BlockRematOverride`, the same per-block offload plan), the new `per_sample_pad_multiple=1` dataloader default from main, main's RoPE `scaling='none'` -> `scaling=None` refactor, the launcher's profiler settings, and the tokenizer path.
100-step runs on 64 GPUs vs the reference runs of the same precision:
| Recipe | Mean / max abs loss diff | Loss at step 100 (new / reference) |
| --- | --- | --- |
| BF16 | 0.0017 / 0.0057 | 6.92717 / 6.92149 |
| MXFP8, run 1 | 0.0034 / 0.0086 | 6.94351 / 6.95157 |
| MXFP8, run 2 | 0.00025 / 0.0012 | 6.95231 / 6.95157 |
The two MXFP8 runs of this recipe differ from each other by 0.0035, so the run 1 gap is run-to-run noise. Step 1 matches the references exactly, and step-1 and step-2 peak memory match to 0.01 GiB.
## Performance
64 GB300 GPUs (16 nodes x 4), 100 steps. tps and TFLOPs are per GPU as logged by torchtitan, mean of steps 71-90. These runs used the launcher-built reference config, which matches these recipes field by field (see Numerics), on an earlier revision of this stack and of activation offload (#6020). These runs used `max_num_documents=64`. #5882 raises it to 128, which removes the padding (10.7% of the tokens on C4) and lowers the reported tps, because tps counts padding tokens.
| Recipe | tps | TFLOPs |
| --- | ---: | ---: |
| `muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark` | 5,166 | 1,691 |
| `muse_spark_816b_a42b_dist_moe_bf16_spmd_64_benchmark` | 3,869 | 1,267 |
Forced balanced routing makes these benchmark numbers, not real-training numbers.
## Testing
- `pytest tests/unit_tests/cpu/recipes`: the new recipes build; the MLA override tests also pass when run alone.
- Config build of all four benchmark recipes, diffed field by field as above.
- FakePG, logical 64 GPUs, rank 0, 10 steps, both `_fake` recipes: MXFP8 step-2 peak 239.52 allocated / 252.68 reserved GiB, the same as an earlier FakePG run of this config. Activation offload moves 124.73 GiB (MXFP8) and 100.90 GiB (BF16) per forward, the same as the reference real runs.
- 64 GPUs, 100 steps, both precisions (MXFP8 twice): all ranks exit 0; numerics above.
## Known issues / follow-ups
- The numbers predate #6137 (activation reloads wait on FSDP2's copy-in stream). Its effect on these recipes is not measured.
- torchtitan does not check that a CP group sits in one NVLink domain.
- With FSDP symmetric memory and EP, `destroy_process_group` can hang after training. The recipe cannot skip it; the launcher must.
- `pytorch/pytorch#204942` is required: without it step 1 runs out of memory. This was measured with DP8/CP8, not rechecked with DP32/CP2.
stack-info: PR: #6252, branch: fegin/stack/45
…ctivation offload
## Summary (human-written)
<!-- Write this yourself, not with an AI tool. 2-5 sentences: the problem, why
this approach, and what you checked yourself. -->
## Why
Our fastest Muse Spark 816B runs on 64 GPUs cannot be reproduced from the repo. They start from the 64-GPU recipe and change it in an out-of-tree launcher: layout, forced routing, Dist-MoE budgets, remat and offload policy, Adam moment placement, the optimizer CUDA graph, and FSDP symmetric memory. The launch environment and the dependency versions are not written down anywhere either.
The 64-GPU recipe also all-gathers the K/V of the full 32K sequence in every layer. The sliding-window varlen layers (46 of 62 layers, 2048-token window) read only the blocks inside their window, so most of that K/V is never used.
**Example.**
```text
before: muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64, then the launcher sets
DP32/CP2, forced routing, scratch 2, slot factor 0, remat p3,
offload attention + MoE projections, moments on GPU, optimizer graph,
FSDP symmetric memory, c4_test, 100 steps
after: --module torchtitan_recipes.models.muse_spark \
--config muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark
```
## What changed
- The Muse K/V-gather CP transform maps `SlidingWindowVarlenInnerAttention` to `SelectiveGatherKVSlidingWindowVarlenInnerAttention`. Global layers keep `AllGatherKVVarlenInnerAttention`. This applies to every 64-GPU recipe.
- The Muse save region becomes `attention.inner_attention*`, so the selective-gather assembly region nested in attention is saved with it. torch_remat rejects a recomputed region inside a saved one. The 256- and 512-GPU and UltraData recipes have no region nested in attention, so the wildcard does not change them.
- `_muse_spark_816b_dist_moe_spmd_64` takes `context_parallel_degree`; FSDP gets the other 64 / CP ranks. The existing 64-GPU recipes pass 8, as before.
- New `muse_spark_816b_a42b_dist_moe_{bf16,mxfp8}_spmd_64_benchmark` recipes and their `_fake` variants. They are benchmark only: forced balanced routing does not train a usable model.
| Setting | BF16 | MXFP8 |
| --- | --- | --- |
| layout | DP32, CP2, EP64, 2 microbatches per step | same |
| routing | forced balanced (round robin) | same |
| Dist-MoE | scratch_capacity_factor 2, activation_slot_capacity_factor 0 | same |
| remat save regions | Dist-MoE defaults + `attention.*` | + pooler, unpooler, router |
| activation offload | block input + `attention.*`, not in the last block | + pooler, unpooler, router |
| Adam moments | GPU (moment_cpu_offload_fraction 0.0) | same |
| CUDA graphs | per microbatch group + optimizer graph | same |
| FSDP symmetric memory | scope all (off in `_fake`) | same |
| data | c4_test, random init, 100 steps (10 in `_fake`) | same |
- The benchmark docstring lists the launch environment (`NCCL_NVLS_ENABLE=1`, `PYTORCH_ALLOC_CONF=pinned_max_round_threshold_mb:1`, one NVLink domain per CP group, skipping `destroy_process_group`) and the dependency versions.
## Dependencies
- PyTorch nightly from 2026-11-20 or later. Activation offload on main calls `FSDPModule.get_all_gather_copy_in_stream` (pytorch/pytorch#205180).
- Depends on meta-pytorch/attention-gym#651 (selective gather); the attention-gym pin bump lands separately.
## How to reproduce
Stage the Muse Spark Open tokenizer files at `./assets/hf/Muse-Spark-Open-816B-A42B`, then on each of 16 hosts (4 GPUs each, all in one NVLink domain):
```bash
NCCL_NVLS_ENABLE=1 PYTORCH_ALLOC_CONF=pinned_max_round_threshold_mb:1 \
torchrun --nnodes 16 --nproc-per-node 4 --node-rank <i> \
--master-addr <host 0> --master-port 29500 -m torchtitan.train \
--module torchtitan_recipes.models.muse_spark \
--config muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark
```
Use `..._bf16_spmd_64_benchmark` for BF16. Measure tps as the mean of steps 71-90.
## Numerics
No model or kernel change. Forced routing makes the loss meaningless for training quality; it is only a run-to-run check.
The benchmark recipes build the same effective config as the launcher-built reference runs, field by field, except: `offload_last_block=False` in the reference runs, which #6020 removed (the recipes keep the last block on GPU with a `BlockRematOverride`, the same per-block offload plan), the new `per_sample_pad_multiple=1` dataloader default from main, main's RoPE `scaling='none'` -> `scaling=None` refactor, the launcher's profiler settings, and the tokenizer path.
100-step runs on 64 GPUs vs the reference runs of the same precision:
| Recipe | Mean / max abs loss diff | Loss at step 100 (new / reference) |
| --- | --- | --- |
| BF16 | 0.0017 / 0.0057 | 6.92717 / 6.92149 |
| MXFP8, run 1 | 0.0034 / 0.0086 | 6.94351 / 6.95157 |
| MXFP8, run 2 | 0.00025 / 0.0012 | 6.95231 / 6.95157 |
The two MXFP8 runs of this recipe differ from each other by 0.0035, so the run 1 gap is run-to-run noise. Step 1 matches the references exactly, and step-1 and step-2 peak memory match to 0.01 GiB.
## Performance
64 GB300 GPUs (16 nodes x 4), 100 steps. tps and TFLOPs are per GPU as logged by torchtitan, mean of steps 71-90. These runs used the launcher-built reference config, which matches these recipes field by field (see Numerics), on an earlier revision of this stack and of activation offload (#6020). These runs used `max_num_documents=64`. #5882 raises it to 128, which removes the padding (10.7% of the tokens on C4) and lowers the reported tps, because tps counts padding tokens.
| Recipe | tps | TFLOPs |
| --- | ---: | ---: |
| `muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmark` | 5,166 | 1,691 |
| `muse_spark_816b_a42b_dist_moe_bf16_spmd_64_benchmark` | 3,869 | 1,267 |
Forced balanced routing makes these benchmark numbers, not real-training numbers.
## Testing
- `pytest tests/unit_tests/cpu/recipes`: the new recipes build; the MLA override tests also pass when run alone.
- Config build of all four benchmark recipes, diffed field by field as above.
- FakePG, logical 64 GPUs, rank 0, 10 steps, both `_fake` recipes: MXFP8 step-2 peak 239.52 allocated / 252.68 reserved GiB, the same as an earlier FakePG run of this config. Activation offload moves 124.73 GiB (MXFP8) and 100.90 GiB (BF16) per forward, the same as the reference real runs.
- 64 GPUs, 100 steps, both precisions (MXFP8 twice): all ranks exit 0; numerics above.
## Known issues / follow-ups
- The numbers predate #6137 (activation reloads wait on FSDP2's copy-in stream). Its effect on these recipes is not measured.
- torchtitan does not check that a CP group sits in one NVLink domain.
- With FSDP symmetric memory and EP, `destroy_process_group` can hang after training. The recipe cannot skip it; the launcher must.
- `pytorch/pytorch#204942` is required: without it step 1 runs out of memory. This was measured with DP8/CP8, not rechecked with DP32/CP2.
stack-info: PR: #6252, branch: fegin/stack/45
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked PRs:
[muse_spark] Add 64-GPU benchmark recipes with selective gather and activation offload
Summary (human-written)
Why
Our fastest Muse Spark 816B runs on 64 GPUs cannot be reproduced from the repo. They start from the 64-GPU recipe and change it in an out-of-tree launcher: layout, forced routing, Dist-MoE budgets, remat and offload policy, Adam moment placement, the optimizer CUDA graph, and FSDP symmetric memory. The launch environment and the dependency versions are not written down anywhere either.
The 64-GPU recipe also all-gathers the K/V of the full 32K sequence in every layer. The sliding-window varlen layers (46 of 62 layers, 2048-token window) read only the blocks inside their window, so most of that K/V is never used.
Example.
What changed
SlidingWindowVarlenInnerAttentiontoSelectiveGatherKVSlidingWindowVarlenInnerAttention. Global layers keepAllGatherKVVarlenInnerAttention. This applies to every 64-GPU recipe.attention.inner_attention*, so the selective-gather assembly region nested in attention is saved with it. torch_remat rejects a recomputed region inside a saved one. The 256- and 512-GPU and UltraData recipes have no region nested in attention, so the wildcard does not change them._muse_spark_816b_dist_moe_spmd_64takescontext_parallel_degree; FSDP gets the other 64 / CP ranks. The existing 64-GPU recipes pass 8, as before.muse_spark_816b_a42b_dist_moe_{bf16,mxfp8}_spmd_64_benchmarkrecipes and their_fakevariants. They are benchmark only: forced balanced routing does not train a usable model.attention.*attention.*, not in the last block_fake)_fake)NCCL_NVLS_ENABLE=1,PYTORCH_ALLOC_CONF=pinned_max_round_threshold_mb:1, one NVLink domain per CP group, skippingdestroy_process_group) and the dependency versions.Dependencies
FSDPModule.get_all_gather_copy_in_stream([FSDP2] Add FSDPModule.get_all_gather_copy_in_stream pytorch#205180).How to reproduce
Stage the Muse Spark Open tokenizer files at
./assets/hf/Muse-Spark-Open-816B-A42B, then on each of 16 hosts (4 GPUs each, all in one NVLink domain):Use
..._bf16_spmd_64_benchmarkfor BF16. Measure tps as the mean of steps 71-90.Numerics
No model or kernel change. Forced routing makes the loss meaningless for training quality; it is only a run-to-run check.
The benchmark recipes build the same effective config as the launcher-built reference runs, field by field, except:
offload_last_block=Falsein the reference runs, which #6020 removed (the recipes keep the last block on GPU with aBlockRematOverride, the same per-block offload plan), the newper_sample_pad_multiple=1dataloader default from main, main's RoPEscaling='none'->scaling=Nonerefactor, the launcher's profiler settings, and the tokenizer path.100-step runs on 64 GPUs vs the reference runs of the same precision:
The two MXFP8 runs of this recipe differ from each other by 0.0035, so the run 1 gap is run-to-run noise. Step 1 matches the references exactly, and step-1 and step-2 peak memory match to 0.01 GiB.
Performance
64 GB300 GPUs (16 nodes x 4), 100 steps. tps and TFLOPs are per GPU as logged by torchtitan, mean of steps 71-90. These runs used the launcher-built reference config, which matches these recipes field by field (see Numerics), on an earlier revision of this stack and of activation offload (#6020). These runs used
max_num_documents=64. #5882 raises it to 128, which removes the padding (10.7% of the tokens on C4) and lowers the reported tps, because tps counts padding tokens.muse_spark_816b_a42b_dist_moe_mxfp8_spmd_64_benchmarkmuse_spark_816b_a42b_dist_moe_bf16_spmd_64_benchmarkForced balanced routing makes these benchmark numbers, not real-training numbers.
Testing
pytest tests/unit_tests/cpu/recipes: the new recipes build; the MLA override tests also pass when run alone._fakerecipes: MXFP8 step-2 peak 239.52 allocated / 252.68 reserved GiB, the same as an earlier FakePG run of this config. Activation offload moves 124.73 GiB (MXFP8) and 100.90 GiB (BF16) per forward, the same as the reference real runs.Known issues / follow-ups
destroy_process_groupcan hang after training. The recipe cannot skip it; the launcher must.pytorch/pytorch#204942is required: without it step 1 runs out of memory. This was measured with DP8/CP8, not rechecked with DP32/CP2.