Skip to content

Commit e828ea5

Browse files
[doc] refactor: split technique guidance into docs, skills, and knowledge (#2809)
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com> Signed-off-by: Yu Yao <yaoyu.094@gmail.com> Signed-off-by: Yu Yao <54727607+yaoyu-33@users.noreply.github.com> Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
1 parent 210d6e3 commit e828ea5

34 files changed

Lines changed: 3053 additions & 1368 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ instance/
9191
# Sphinx documentation
9292
docs/_build
9393
docs/apidocs
94+
docs/skills
9495

9596
# PyBuilder
9697
target/

‎docs/conf.py‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,19 @@
1818
# https://www.sphinx-doc.org/en/master/usage/configuration.html
1919

2020
import os
21+
import shutil
2122
import sys
2223

2324

25+
_SKILLS_SRC = os.path.join(os.path.dirname(__file__), os.pardir, "skills")
26+
_SKILLS_DST = os.path.join(os.path.dirname(__file__), "skills")
27+
28+
if os.path.isdir(_SKILLS_SRC):
29+
if os.path.exists(_SKILLS_DST):
30+
shutil.rmtree(_SKILLS_DST)
31+
shutil.copytree(_SKILLS_SRC, _SKILLS_DST)
32+
33+
2434
# -- Project information -----------------------------------------------------
2535
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
2636

@@ -43,7 +53,16 @@
4353
]
4454

4555
templates_path = ["_templates"]
46-
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
56+
exclude_patterns = [
57+
"_build",
58+
"Thumbs.db",
59+
".DS_Store",
60+
"skills/perf-techniques/README.md",
61+
]
62+
63+
suppress_warnings = [
64+
"misc.highlighting_failure", # skills use Cursor-specific code reference syntax
65+
]
4766

4867
# -- Options for MyST Parser (Markdown) --------------------------------------
4968
# MyST Parser settings

‎docs/index.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ training/checkpointing.md
4444
training/megatron-fsdp.md
4545
training/resiliency.md
4646
training/mixed-precision.md
47+
training/cuda-graphs.md
48+
training/hybrid-context-parallel.md
4749
training/communication-overlap.md
4850
training/attention-optimizations.md
4951
training/activation-recomputation.md
@@ -82,6 +84,13 @@ releases/changelog.md
8284
releases/known-issues.md
8385
```
8486

87+
```{toctree}
88+
:caption: Agent Skills
89+
:hidden:
90+
91+
skills-index
92+
```
93+
8594
```{toctree}
8695
:caption: Directory Readme Files
8796
:hidden:

‎docs/parallelisms.md‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,53 @@ For example, with 32 GPUs total and the configuration above:
435435
- `context_parallel_size = 2`
436436
- `data_parallel_size = 32 / (2 × 4 × 2) = 2`
437437

438+
## Strategy Selection Guide
439+
440+
Choosing the right combination depends on model size, hardware topology,
441+
and sequence length.
442+
443+
### Dense Models by Size
444+
445+
| Model size | GPUs | Recommended starting point |
446+
|---|---|---|
447+
| < 1B | 1-8 | DP only |
448+
| 1-10B | 8-16 | TP=2-4 + DP |
449+
| 10-70B | 16-64 | TP=4-8 + PP=2-4 + DP |
450+
| 70-175B | 64-256 | TP=8 + PP=4-8 + DP |
451+
| 175-500B | 256-1024 | TP=8 + PP=8-16 + CP=2 + DP |
452+
453+
### MoE Models
454+
455+
MoE models differ fundamentally from dense models: only a fraction of
456+
parameters are active per token, so TP can often stay at 1 or 2. EP is
457+
the primary scaling dimension.
458+
459+
| Total / active params | Typical layout |
460+
|---|---|
461+
| < 20B | EP only (TP=1, PP=1) |
462+
| 20-100B | TP=1-2 + PP=2-4 + EP=8-16 |
463+
| 100-500B | TP=2-4 + PP=8-16 + EP=8-32 |
464+
| 500B+ | TP=2 + PP=16 + EP=32-64 |
465+
466+
### By Hardware Topology
467+
468+
- **Single node with NVLink**: maximize TP within the node (up to TP=8).
469+
- **Multiple nodes with InfiniBand**: keep TP within a node, use PP across nodes.
470+
- **Limited network (Ethernet)**: minimize TP, prefer PP for cross-node scaling.
471+
472+
### By Sequence Length
473+
474+
| Sequence length | Recommendation |
475+
|---|---|
476+
| < 2K | standard TP + PP + DP |
477+
| 2K-8K | add SP (`sequence_parallel=True`) |
478+
| 8K-32K | add CP=2 |
479+
| 32K+ | add CP=4-8, consider hierarchical CP |
480+
481+
For operational details on configuring combined parallelism, troubleshooting
482+
layouts, and memory estimation, see the
483+
[parallelism strategies skill](skills/perf-techniques/parallelism-strategies/SKILL.md).
484+
438485
## Configuration Guidelines
439486

440487
### Memory Optimization
@@ -458,6 +505,11 @@ For example, with 32 GPUs total and the configuration above:
458505
- **Token dropping** requires `alltoall` or `alltoall_seq` token dispatcher
459506
- All parallelism strategies can be combined, but total parallelism must divide evenly into the world size
460507

508+
## Related Artifacts
509+
510+
- **Operational skill**: [skills/perf-techniques/parallelism-strategies/SKILL.md](skills/perf-techniques/parallelism-strategies/SKILL.md) — enablement, pitfalls, memory estimation, verification
511+
- **Knowledge card**: [skills/perf-techniques/parallelism-strategies/card.yaml](skills/perf-techniques/parallelism-strategies/card.yaml) — structured metadata and validation status
512+
461513
## Resources
462514

463515
- [Megatron Core Developer Guide](https://docs.nvidia.com/megatron-core/developer-guide/latest/)

‎docs/performance-guide.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ Additionally, because CP shards activations, it also partitions optimizer states
299299

300300
> 1. Megatron-Bridge supports graph capture, significantly reducing host overhead. CUDA Graph is applicable only to LLMs with a static tensor shape across training steps. For example, it supports fixed-size packed sequences but does not handle sequences with varying lengths at each step. Also, MoE models with token-dropless propagation have limited CUDA graph support, restricted to the dense modules only.
301301
> 2. CUDA graph requires additional memory for static buffer management, typically adding a few gigabytes for static buffers, while models with PP size > 1 may consume over 10GB. We are actively working to reduce this memory overhead.
302-
> 3. `TransformerConfig.enable_cuda_graph=true`
302+
> 3. See [CUDA Graphs](training/cuda-graphs.md) for configuration details (`cuda_graph_impl`, `cuda_graph_scope`).
303303
304304
5. Bind CPU memory for GPU processes
305305

@@ -677,7 +677,7 @@ python -u /home/dpsk_a2a/deepep/tests/test_internode.py
677677
- `TransformerConfig.cpu_offloading_num_layers`
678678
- `TransformerConfig.cpu_offloading_weights`
679679
- `GPTProvider.cross_entropy_loss_fusion`
680-
- `TransformerConfig.enable_cuda_graph`
680+
- `TransformerConfig.cuda_graph_impl` / `cuda_graph_scope` (see [CUDA Graphs](training/cuda-graphs.md))
681681
- `MixedPrecisionConfig.fp8_param_gather`
682682
- `GPTProvider.gradient_accumulation_fusion`
683683
- `TransformerConfig.masked_softmax_fusion`

‎docs/skills-index.md‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Agent Skills Reference
2+
3+
Operational guides and validated knowledge cards for Megatron Bridge.
4+
5+
Each skill contains enablement snippets, code anchors, constraints, pitfalls,
6+
and verification steps.
7+
8+
```{toctree}
9+
:caption: Performance Techniques
10+
:maxdepth: 1
11+
12+
skills/perf-techniques/parallelism-strategies/SKILL
13+
skills/perf-techniques/cuda-graphs/SKILL
14+
skills/perf-techniques/tp-dp-comm-overlap/SKILL
15+
skills/perf-techniques/megatron-fsdp/SKILL
16+
skills/perf-techniques/packed-sequences-long-context/SKILL
17+
skills/perf-techniques/sequence-packing/SKILL
18+
skills/perf-techniques/hybrid-context-parallel/SKILL
19+
skills/perf-techniques/expert-parallel-overlap/SKILL
20+
skills/perf-techniques/moe-comm-overlap/SKILL
21+
```
22+
23+
```{toctree}
24+
:caption: Resiliency
25+
:maxdepth: 1
26+
27+
skills/resiliency/SKILL
28+
```

‎docs/training/README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ This directory contains comprehensive documentation for training and customizing
4141
| **[Optimizer & Scheduler](optimizer-scheduler.md)** | Optimizer and learning rate scheduler configuration | Setting up optimization |
4242
| **[Mixed Precision](mixed-precision.md)** | Mixed precision training for memory efficiency | Reducing memory usage |
4343
| **[Communication Overlap](communication-overlap.md)** | Overlapping communication with computation | Optimizing distributed training |
44+
| **[Hybrid Context Parallel](hybrid-context-parallel.md)** | Hierarchical `a2a+p2p` context parallel guidance | Advanced long-sequence scaling |
4445
| **[Attention Optimizations](attention-optimizations.md)** | Optimizing attention mechanisms | Improving training speed |
4546
| **[Activation Recomputation](activation-recomputation.md)** | Gradient checkpointing strategies | Reducing memory footprint |
4647
| **[CPU Offloading](cpu-offloading.md)** | Offloading to CPU for memory management | Working with limited GPU memory |
@@ -59,6 +60,7 @@ This directory contains comprehensive documentation for training and customizing
5960
|----------|---------|--------------|
6061
| **[PEFT](peft.md)** | Parameter-Efficient Fine-Tuning (LoRA, etc.) | Fine-tuning with limited resources |
6162
| **[Packed Sequences](packed-sequences.md)** | Sequence packing for efficiency | Optimizing data loading |
63+
| **[Megatron FSDP](megatron-fsdp.md)** | Stable overview of Megatron FSDP | Choosing an FSDP path |
6264
| **[Distillation](distillation.md)** | Knowledge distillation techniques | Transferring knowledge between models |
6365
| **[Checkpointing](checkpointing.md)** | Checkpoint saving, loading, and resuming | Managing training state |
6466
| **[Callbacks](callbacks.md)** | Inject custom logic into training loop | Custom logging, metrics, third-party integrations |

0 commit comments

Comments
 (0)