You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e4f8f96
Browse filesBrowse the repository at this point in the historyBrowse files
**Important**: When using Megatron FSDP (`use_megatron_fsdp=True`), you must set `ckpt_format="fsdp_dtensor"`. Other formats are not compatible with FSDP's sharded parameter layout. See {doc}`megatron-fsdp` for complete FSDP configuration details.
193
193
194
+
### Generalized Tensor Parallelism (GTP)
195
+
196
+
Use `torch_dist` checkpoints for BF16 GTP models with TransformerEngine 2.19 or newer.
197
+
Checkpoint metadata and fully parallel save/load include the GTP rematerialization
198
+
axis. RNG checkpoint entries preserve distinct streams on dense and expert GTP ranks.
199
+
200
+
HF import splits each mapped TP-local tensor into its stored GTP row shard. HF export
201
+
gathers those rows and removes alignment padding before applying the existing TP/EP/PP
202
+
mappings. Use `AutoBridge.export_hf_weights()` or `save_hf_weights()` for this export;
203
+
the local HF parameter-view API cannot describe the extra GTP shard axis. Quantized
204
+
HF export and LoRA adapter export/merge also gather before applying their mappings.
205
+
Raw FP8 export tasks and local native MXFP8 parameter export reject GTP before
206
+
yielding weights, because their storage views cannot preserve this layout.
207
+
208
+
When loading a native GTP checkpoint with `load_megatron_model()`, pass `mp_overrides`
209
+
with the saved TP size and weight shard count for each axis that uses GTP:
210
+
`tensor_model_parallel_size` / `tensor_parallel_num_weight_shards` for dense weights,
211
+
and `expert_tensor_parallel_size` / `expert_tensor_parallel_num_weight_shards` for
212
+
expert weights. Axes without GTP can still change TP independently. Changing a GTP
213
+
weight-sharding topology is
214
+
rejected because the current Megatron-Core SwiGLU checkpoint layout can reorder
215
+
gate/up rows. Training resume and finetuning enforce the same restriction, including
216
+
loading a non-GTP native checkpoint into a GTP model. To change layouts, export HF
217
+
weights from the original topology first, then import the HF weights into the new
218
+
topology.
219
+
220
+
Energon shards samples across DP and dense GTP ranks while CP peers consume the
221
+
same samples. Dataloader checkpoints use the same group for file ownership and
222
+
restore; old duplicated GTP states with a different stream count are rejected.
223
+
With GTP, do not enable both `dist_ckpt_optim_fully_reshardable` and
224
+
`distrib_optim_fully_reshardable_mem_efficient`: Core does not create the Gloo
225
+
groups needed by that combination.
226
+
227
+
The focused two-GPU regression covers exact BF16 HF round-trips, model and named
228
+
RNG-stream resume, and rejection of unsafe topology changes, with fully parallel
229
+
checkpoint I/O enabled and disabled:
230
+
231
+
```bash
232
+
uv run python -m torch.distributed.run --standalone --nproc_per_node=2 -m pytest \
0 commit comments