Skip to content

Commit aa7b720

Browse files
authored
Merge branch 'main' into chcui/talia/remove-retired-models
2 parents 12427d1 + 2161fe9 commit aa7b720

58 files changed

Lines changed: 5642 additions & 238 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.main.commit‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
441a987409b8fdd2b90b463f7999bac970109a43
1+
8949def81eb744b9219e2d794c80265928c40a5b

‎docs/_static/model-verification/catalog-v1.json‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,35 +1347,35 @@
13471347
"workflow": "pretrain"
13481348
},
13491349
{
1350-
"bridge_commit": "330f87c0a391eb2770cbf2306352cc807211d7ba",
1350+
"bridge_commit": "b2ebece6a78fbee6a734655cc6993c13a08b60a4",
13511351
"command_topologies": [
13521352
{
1353-
"gpus_per_node": "1",
1353+
"gpus_per_node": "8",
13541354
"nodes": "1",
13551355
"recipe": "gemma3_vl_4b_sft_config",
13561356
"sequence_length": "4096",
1357-
"total_gpus": 1
1357+
"total_gpus": 8
13581358
}
13591359
],
13601360
"commands": [
1361-
"./scripts/training/train.sh --nodes 1 --gpus-per-node 1 --recipe gemma3_vl_4b_sft_config --mode sft --dataset cord-v2 --pretrained_checkpoint work/model-verification/gemma-3-4b-it/imported-megatron/iter_0000000 --max_steps 10 --seq_length 4096 'dataset.source.load_kwargs={revision:\"7f0115a4b758a71d6473b8d085751692da2fef98\"}' validation.eval_iters=0 validation.eval_interval=0 checkpoint.load=null --save_dir work/model-verification/gemma-3-4b-it/sft-checkpoints --save_interval 10 logger.log_interval=1 logger.log_throughput=true"
1361+
"./scripts/training/train.sh --nodes 1 --gpus-per-node 8 --recipe gemma3_vl_4b_sft_config --mode sft --dataset cord-v2 --pretrained_checkpoint work/model-verification/gemma-3-4b-it/imported-megatron/iter_0000000 --max_steps 10 --seq_length 4096 'dataset.source.load_kwargs={revision:\"7f0115a4b758a71d6473b8d085751692da2fef98\"}' validation.eval_iters=0 validation.eval_interval=0 checkpoint.load=null --save_dir work/model-verification/gemma-3-4b-it/sft-checkpoints --save_interval 10 logger.log_interval=1 logger.log_throughput=true"
13621362
],
13631363
"dimensions": {},
13641364
"enabled_features": {},
13651365
"entry_id": "gemma-3-4b-it-sft-h100",
1366-
"expected_result": "Pending exact-revision CORD-v2 full-SFT verification with the public Gemma 3 VL 4B H100 recipe. The run must complete at least ten optimizer steps with finite loss, no skipped or NaN iterations, all five metrics, and a reloadable final full-model checkpoint.\n",
1366+
"expected_result": "On 8 H100s, the TP1/PP1 recipe completes exactly ten exact-revision CORD-v2 full-SFT steps at global batch size 32 and sequence length 4096. Loss is finite from 1.163850 to 0.143927 with no skipped or NaN iterations. The ten-step metric window includes the first-step cold-start cost by policy, and the final iteration-10 checkpoint saves successfully.\n",
13671367
"hardware": "H100",
1368-
"last_verified": null,
1368+
"last_verified": "2026-10-09",
13691369
"metrics": {
1370-
"final_loss": null,
1371-
"initial_loss": null,
1372-
"last_10_steps_model_tflops_per_gpu_avg": null,
1373-
"last_10_steps_step_time_ms_avg": null,
1374-
"last_10_steps_tokens_per_second_per_gpu_avg": null
1370+
"final_loss": 0.143927,
1371+
"initial_loss": 1.16385,
1372+
"last_10_steps_model_tflops_per_gpu_avg": 22.45,
1373+
"last_10_steps_step_time_ms_avg": 5461.01,
1374+
"last_10_steps_tokens_per_second_per_gpu_avg": 3000.178
13751375
},
13761376
"precision": "bf16",
13771377
"source_pointer": "items.sft.H100",
1378-
"status": "unverified",
1378+
"status": "verified",
13791379
"variant": null,
13801380
"workflow": "sft"
13811381
},
@@ -1481,7 +1481,7 @@
14811481
"min_transformers_version": "5.8.0",
14821482
"slug": "gemma-3-4b-it",
14831483
"source_card": "examples/model_verification_cards/gemma-3-4b-it/card.yaml",
1484-
"summary": "Performance disclaimer: this model has not been performance-tuned; reported timing and throughput metrics are sanity checks, not optimized performance results. Gemma 3 4B Instruct exact-checkpoint CPU and TP2/PP2 GPU import, CPU and TP2/PP2 GPU export, manual multimodal forward parity, and deterministic TP2/PP2 inference are verified. SFT, post-SFT export/inference, and PEFT remain pending. Pretraining and checkpoint resume are unsupported because there is no public exact-model pretraining recipe. Long-context SFT is unsupported because the required dense local/global attention biases currently exclude context parallelism and in-batch THD packing. Existing toy-model tests are not used as exact-model evidence.\n",
1484+
"summary": "Performance disclaimer: this model has not been performance-tuned; reported timing and throughput metrics are sanity checks, not optimized performance results. Gemma 3 4B Instruct exact-checkpoint CPU and TP2/PP2 GPU import, CPU and TP2/PP2 GPU export, manual multimodal forward parity, deterministic TP2/PP2 inference, and 8-GPU H100 full SFT are verified. Post-SFT export/inference and PEFT remain pending. Pretraining and checkpoint resume are unsupported because there is no public exact-model pretraining recipe. Long-context SFT is unsupported because the required dense local/global attention biases currently exclude context parallelism and in-batch THD packing. Existing toy-model tests are not used as exact-model evidence.\n",
14851485
"title": "gemma_3_4b_it"
14861486
},
14871487
{

‎docs/fern/versions/_nav_order.yml‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,19 +97,20 @@
9797
"./versions/nightly/pages/training/cuda-graphs.mdx": 13
9898
"./versions/nightly/pages/models/nemotron/index.mdx": 14
9999
"./versions/nightly/pages/training/hierarchical-context-parallel.mdx": 14
100+
"./versions/nightly/pages/training/dynamic-context-parallel.mdx": 15
100101
"./versions/nightly/pages/models/olmoe/index.mdx": 15
101-
"./versions/nightly/pages/training/communication-overlap.mdx": 15
102+
"./versions/nightly/pages/training/communication-overlap.mdx": 16
102103
"./versions/nightly/pages/models/qwen/index.mdx": 16
103-
"./versions/nightly/pages/training/attention-optimizations.mdx": 16
104+
"./versions/nightly/pages/training/attention-optimizations.mdx": 17
104105
"./versions/nightly/pages/models/sarvam/index.mdx": 17
105-
"./versions/nightly/pages/training/activation-recomputation.mdx": 17
106+
"./versions/nightly/pages/training/activation-recomputation.mdx": 18
106107
"./versions/nightly/pages/models/stepfun/index.mdx": 18
107-
"./versions/nightly/pages/training/cpu-offloading.mdx": 18
108-
"./versions/nightly/pages/training/moe-optimization.mdx": 19
109-
"./versions/nightly/pages/training/peft.mdx": 20
110-
"./versions/nightly/pages/training/packed-sequences.mdx": 21
111-
"./versions/nightly/pages/training/multi-token-prediction.mdx": 22
112-
"./versions/nightly/pages/training/callbacks.mdx": 23
108+
"./versions/nightly/pages/training/cpu-offloading.mdx": 19
109+
"./versions/nightly/pages/training/moe-optimization.mdx": 20
110+
"./versions/nightly/pages/training/peft.mdx": 21
111+
"./versions/nightly/pages/training/packed-sequences.mdx": 22
112+
"./versions/nightly/pages/training/multi-token-prediction.mdx": 23
113+
"./versions/nightly/pages/training/callbacks.mdx": 24
113114
"./versions/nightly/pages/models/nemotron/nemotron3-ultra.mdx": 7
114115
"./versions/nightly/pages/models/nemotron/nemotron3.5-super-vl.mdx": 9
115116
"./versions/nightly/pages/models/nemotron/nemotron3.5-super-vl-text-only.mdx": 10

‎docs/fern/versions/nightly.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ navigation:
196196
path: ./nightly/pages/training/cuda-graphs.mdx
197197
- page: Hierarchical Context Parallel
198198
path: ./nightly/pages/training/hierarchical-context-parallel.mdx
199+
- page: Dynamic Context Parallel
200+
path: ./nightly/pages/training/dynamic-context-parallel.mdx
199201
- page: Communication Overlap
200202
path: ./nightly/pages/training/communication-overlap.mdx
201203
- page: Attention Optimizations

‎docs/fern/versions/nightly/pages/models/gemma/gemma3-vl.mdx‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ Choose a workflow, precision, and exact recorded combination. The command and ex
7979
</span>
8080
<span class="verification-combination-meta">Precision not specified</span>
8181
</button>
82-
<button type="button" class="verification-combination" data-capability="sft" data-precision="bf16" data-hardware="H100" data-status="unverified" data-entry="gemma-3-4b-it-sft-h100" aria-controls="gemma-3-4b-it-sft-h100" aria-pressed="false">
82+
<button type="button" class="verification-combination" data-capability="sft" data-precision="bf16" data-hardware="H100" data-status="verified" data-entry="gemma-3-4b-it-sft-h100" aria-controls="gemma-3-4b-it-sft-h100" aria-pressed="false">
8383
<span class="verification-combination-heading">
8484
<strong>SFT · H100</strong>
85-
<span class="verification-status verification-status--unverified" title="Unverified">○ Unverified</span>
85+
<span class="verification-status verification-status--verified" title="Verified">✓ Verified</span>
8686
</span>
8787
<span class="verification-combination-meta">BF16</span>
8888
</button>
@@ -249,35 +249,35 @@ Choose a workflow, precision, and exact recorded combination. The command and ex
249249
<article id="gemma-3-4b-it-sft-h100" class="verification-model-detail" data-entry-detail="gemma-3-4b-it-sft-h100" tabindex="-1">
250250
<header class="verification-model-detail-heading">
251251
<h4>SFT · H100</h4>
252-
<span class="verification-status verification-status--unverified" title="Unverified">○ Unverified</span>
252+
<span class="verification-status verification-status--verified" title="Verified">✓ Verified</span>
253253
</header>
254254
<dl class="verification-model-detail-meta">
255255
<div><dt>Hardware</dt><dd>H100</dd></div>
256256
<div><dt>Precision</dt><dd>BF16</dd></div>
257-
<div><dt>Last verified</dt><dd>—</dd></div>
257+
<div><dt>Last verified</dt><dd>2026-10-09</dd></div>
258258
</dl>
259259
<section class="verification-recorded-metrics">
260260
<h5>Recorded metrics</h5>
261261
<dl class="verification-metric-list">
262262
<div>
263263
<dt>Initial loss</dt>
264-
<dd>None</dd>
264+
<dd>1.16385</dd>
265265
</div>
266266
<div>
267267
<dt>Final loss</dt>
268-
<dd>None</dd>
268+
<dd>0.143927</dd>
269269
</div>
270270
<div>
271271
<dt>Step time · last 10 avg</dt>
272-
<dd>None ms</dd>
272+
<dd>5,461.010 ms</dd>
273273
</div>
274274
<div>
275275
<dt>Model throughput · last 10 avg</dt>
276-
<dd>None TFLOP/s/GPU</dd>
276+
<dd>22.450 TFLOP/s/GPU</dd>
277277
</div>
278278
<div>
279279
<dt>Token throughput · last 10 avg</dt>
280-
<dd>None tokens/s/GPU</dd>
280+
<dd>3,000.178 tokens/s/GPU</dd>
281281
</div>
282282
</dl>
283283
</section>
@@ -288,12 +288,12 @@ Choose a workflow, precision, and exact recorded combination. The command and ex
288288
<span>Command</span>
289289
<button type="button" class="verification-copy-command">Copy</button>
290290
</div>
291-
<pre><code class="language-bash">./scripts/training/train.sh --nodes 1 --gpus-per-node 1 --recipe gemma3_vl_4b_sft_config --mode sft --dataset cord-v2 --pretrained_checkpoint work/model-verification/gemma-3-4b-it/imported-megatron/iter_0000000 --max_steps 10 --seq_length 4096 &#x27;dataset.source.load_kwargs=&#123;revision:&quot;7f0115a4b758a71d6473b8d085751692da2fef98&quot;&#125;&#x27; validation.eval_iters=0 validation.eval_interval=0 checkpoint.load=null --save_dir work/model-verification/gemma-3-4b-it/sft-checkpoints --save_interval 10 logger.log_interval=1 logger.log_throughput=true</code></pre>
291+
<pre><code class="language-bash">./scripts/training/train.sh --nodes 1 --gpus-per-node 8 --recipe gemma3_vl_4b_sft_config --mode sft --dataset cord-v2 --pretrained_checkpoint work/model-verification/gemma-3-4b-it/imported-megatron/iter_0000000 --max_steps 10 --seq_length 4096 &#x27;dataset.source.load_kwargs=&#123;revision:&quot;7f0115a4b758a71d6473b8d085751692da2fef98&quot;&#125;&#x27; validation.eval_iters=0 validation.eval_interval=0 checkpoint.load=null --save_dir work/model-verification/gemma-3-4b-it/sft-checkpoints --save_interval 10 logger.log_interval=1 logger.log_throughput=true</code></pre>
292292
</div>
293293
</section>
294294
<section class="verification-expected-result">
295295
<h5>Expected result</h5>
296-
<p>Pending exact-revision CORD-v2 full-SFT verification with the public Gemma 3 VL 4B H100 recipe. The run must complete at least ten optimizer steps with finite loss, no skipped or NaN iterations, all five metrics, and a reloadable final full-model checkpoint.</p>
296+
<p>On 8 H100s, the TP1/PP1 recipe completes exactly ten exact-revision CORD-v2 full-SFT steps at global batch size 32 and sequence length 4096. Loss is finite from 1.163850 to 0.143927 with no skipped or NaN iterations. The ten-step metric window includes the first-step cold-start cost by policy, and the final iteration-10 checkpoint saves successfully.</p>
297297
</section>
298298
</article>
299299
<article id="gemma-3-4b-it-sft-long-context-h100" class="verification-model-detail" data-entry-detail="gemma-3-4b-it-sft-long-context-h100" tabindex="-1">

‎docs/fern/versions/nightly/pages/training/README.mdx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ This directory contains comprehensive documentation for training and customizing
4343
| **[Mixed Precision](mixed-precision.md)** | Mixed precision training for memory efficiency | Reducing memory usage |
4444
| **[Communication Overlap](communication-overlap.md)** | Overlapping communication with computation | Optimizing distributed training |
4545
| **[Hierarchical Context Parallel](hierarchical-context-parallel.md)** | Hierarchical `a2a+p2p` context parallel guidance | Advanced long-sequence scaling |
46+
| **[Dynamic Context Parallel](dynamic-context-parallel.md)** | Per-microbatch context-parallel groups sized by global-batch packing | Variable-length long-context training |
4647
| **[Attention Optimizations](attention-optimizations.md)** | Optimizing attention mechanisms | Improving training speed |
4748
| **[Activation Recomputation](activation-recomputation.md)** | Gradient checkpointing strategies | Reducing memory footprint |
4849
| **[CPU Offloading](cpu-offloading.md)** | Offloading to CPU for memory management | Working with limited GPU memory |
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# Dynamic Context Parallel
2+
3+
Dynamic context parallelism (dynamic CP) runs every packed microbatch on a
4+
context-parallel group sized for its longest sequence, instead of splitting
5+
every microbatch across the full `context_parallel_size` group. It builds on
6+
[global-batch online packing](packed-sequences.md#global-batch-online-packing):
7+
the packing scheduler already sees the whole global batch across data-parallel
8+
ranks, and with dynamic CP it also picks a context-parallel group for each
9+
packed bin from the pool of `data_parallel_size x context_parallel_size` ranks.
10+
11+
Dynamic CP needs the Megatron-Core `dev` submodule pin:
12+
13+
```bash
14+
./scripts/switch_mcore.sh dev && uv sync
15+
```
16+
17+
`ConfigContainer.validate` reports what an older pin is missing.
18+
19+
## When to Use It
20+
21+
Static context parallelism is sized for the longest sequence a run must fit.
22+
On a variable-length stream most sequences are much shorter, and splitting them
23+
across the whole group adds context-parallel communication and smaller kernels
24+
without needing the memory. Dynamic CP pays off when both of these hold:
25+
26+
- Static CP is required by memory for the long tail. A large vocabulary can
27+
make the logits buffer the limit, for example.
28+
- The stream has a meaningful share of sequences short enough to run on one GPU
29+
or a small group.
30+
31+
When nearly every sequence needs the full group, dynamic CP matches static CP up
32+
to a small scheduling overhead.
33+
34+
## How It Works
35+
36+
`model.max_seqlen_per_dp_cp_rank` is the token capacity of one rank in one
37+
microbatch. With `default_dynamic_cp`, a sequence of at most that length runs on
38+
one GPU, a sequence of up to twice that length on a two-GPU group, and so on up
39+
to the whole pool. The scheduler forms bins longest first and gives each bin a
40+
power-of-two group, and every rank runs the same number of microbatches in a
41+
step.
42+
43+
Bridge wires this through the global-batch packing path:
44+
45+
- `model.dynamic_context_parallel=True` makes validation select the
46+
`default_dynamic_cp` scheduler instead of `dp_balanced`.
47+
- The packed batch fetch receives the dynamic-CP flag and returns a
48+
`PackedSeqParams` that carries the microbatch's context-parallel group, which
49+
attention and rotary embeddings use in place of the static group.
50+
- The per-sequence alignment multiple covers every group the pool can form:
51+
`2 x dp x cp`, and also `dp x cp x tp` under sequence parallelism.
52+
53+
## Configuration
54+
55+
```python
56+
cfg.dataset.enable_global_batch_packing = True
57+
cfg.dataset.dataloader_type = "single"
58+
cfg.model.context_parallel_size = 4 # static CP domain inside each data-parallel replica
59+
cfg.model.dynamic_context_parallel = True
60+
cfg.model.min_dynamic_context_parallel_size = 1
61+
cfg.model.max_seqlen_per_dp_cp_rank = cfg.model.seq_length // 4
62+
cfg.model.calculate_per_token_loss = True
63+
cfg.ddp.average_in_collective = False
64+
cfg.train.micro_batch_size = 1
65+
```
66+
67+
Validation applies every global-batch packing rule and adds these:
68+
69+
- The `dp x cp` pool is a power of two with at least two ranks.
70+
- `min_dynamic_context_parallel_size` is a power of two no larger than the pool.
71+
- `dist.use_decentralized_pg=False`, because Megatron-Core resolves dynamic
72+
groups from its global parallel state.
73+
- The pool times `max_seqlen_per_dp_cp_rank` covers `seq_length`.
74+
75+
## Reference Recipe
76+
77+
`qwen35_text_35b_a3b_sft_8gpu_gb200_bf16_dynamic_cp_config` fine-tunes
78+
Qwen3.5-35B-A3B on CoderForge-Preview SWE-Rebench trajectories with TP1, PP1,
79+
CP4, and EP8 on eight GB200 GPUs and a 32K-token cap.
80+
`examples/training_features/long_context/qwen35_35b_a3b_dynamic_cp.py` launches
81+
it. Add these overrides for the static-CP baseline on the same packing path:
82+
83+
```bash
84+
model.dynamic_context_parallel=false model.sequence_packing_scheduler=dp_balanced
85+
```
86+
87+
On the recipe's own data, about nine in ten CoderForge trajectories exceed the
88+
32K cap, so nearly every packed sequence needs the full CP4 group. There,
89+
dynamic CP runs within noise of static CP4: a median step of 88 s against
90+
83 s, at about 90 model TFLOP/s per GPU. The example's README lists the
91+
measurements, including the effect of loader workers and recompute choices.
92+
Expect gains on streams where a meaningful share of sequences is short enough
93+
to run on one GPU or a small group.
94+
95+
## Models with Wide Attention Heads
96+
97+
Transformer Engine does not train with cuDNN fused attention at head dimension
98+
256 on Blackwell, so Qwen3.5 attention runs on FlashAttention. FlashAttention
99+
rejects THD bins that contain padding between sequences. Such models need two
100+
changes:
101+
102+
- `fold_alignment_padding=True` on the dataset config, which reports each
103+
sequence's alignment padding as part of that sequence. The padding stays
104+
loss-masked and follows the sequence's last token, so causal attention and
105+
recurrent layers compute the same outputs for real tokens.
106+
- A Megatron-Core that derives `pad_between_seqs` from the actual `cu_seqlens`,
107+
proposed in [Megatron-LM #7417](https://github.com/NVIDIA/Megatron-LM/pull/7417).
108+
109+
Leave `fold_alignment_padding` off for head dimensions of 128 or less, where
110+
cuDNN fused attention handles the padding itself.
111+
112+
## Practical Caveats
113+
114+
- The first step that uses a new group size pays communicator and kernel setup,
115+
so expect a few slow early steps.
116+
- The scheduler may place short sequences on larger groups to keep every rank
117+
busy, so fewer sequences run on one GPU than the length histogram suggests.
118+
- Transformer Engine's FusedAdam draws parameter handles from a pool of roughly
119+
20,000. Many experts on few expert-parallel ranks can exhaust it with the
120+
precision-aware optimizer. Use more expert-parallel ranks, as the recipe does
121+
with EP8, or offload part of the optimizer to the CPU.
122+
- The fused cross-entropy materializes an fp32 buffer of tokens per rank times
123+
vocabulary size. At a 248K vocabulary this buffer sets
124+
`max_seqlen_per_dp_cp_rank` and makes context parallelism necessary at long
125+
caps.
126+
127+
## Related Docs
128+
129+
- [Packed Sequences](packed-sequences.md)
130+
- [Hierarchical Context Parallel](hierarchical-context-parallel.md)
131+
- [Activation Recomputation](activation-recomputation.md)

0 commit comments

Comments
 (0)