Skip to content

Commit 8af1ed3

Browse files
committed
[doc] chore: refresh communication overlap guidance
Clarify when communication overlap helps, split stable docs from operational EP overlap guidance, and record the current experiment-backed recommendations. Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com> Made-with: Cursor
1 parent f386fd6 commit 8af1ed3

3 files changed

Lines changed: 519 additions & 158 deletions

File tree

Lines changed: 141 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,180 @@
11
# Communication Overlap
22

33
Communication overlap reduces exposed communication cost in distributed training
4-
by overlapping collectives or point-to-point transfers with useful compute.
5-
Megatron Bridge supports overlap across several parallelism dimensions, but the
6-
available behavior is not identical for every mode.
4+
by hiding collectives or point-to-point transfers under useful compute.
75

8-
This page is the stable overview for what communication overlap is, when to use
9-
it, and which constraints are durable. For operational setup, code anchors, and
10-
verification commands, see:
6+
This page is the stable guide for what communication overlap is, when it tends
7+
to help, and which boundaries are durable across Megatron Bridge. For exact
8+
knobs, code anchors, and verification commands, see:
119

12-
- [skills/perf-techniques/tp-dp-comm-overlap/SKILL.md](../skills/perf-techniques/tp-dp-comm-overlap/SKILL.md)
13-
- [skills/perf-techniques/expert-parallel-overlap/SKILL.md](../skills/perf-techniques/expert-parallel-overlap/SKILL.md)
10+
- `skills/perf-techniques/tp-dp-comm-overlap/SKILL.md`
11+
- `skills/perf-techniques/expert-parallel-overlap/SKILL.md`
1412

1513
## What It Is
1614

17-
In Bridge, communication overlap spans several related subfeatures:
15+
In Bridge, communication overlap is a family of related techniques rather than a
16+
single switch:
1817

19-
- data-parallel overlap for gradient reduce-scatter and parameter all-gather
20-
- tensor-parallel overlap for TP communication under GEMM work
21-
- pipeline-parallel overlap for PP send and receive behavior
22-
- context-parallel overlap built into context-parallel execution paths
23-
- MoE expert-parallel overlap for expert token dispatch communication
18+
| Mode | What gets hidden | Main gate |
19+
|---|---|---|
20+
| DP | gradient reduce-scatter and parameter all-gather | distributed-optimizer overlap path |
21+
| TP | tensor-parallel collectives under layer compute | `CommOverlapConfig.tp_comm_overlap` plus sequence parallelism |
22+
| PP | pipeline send/recv work under schedule execution | pipeline schedule and virtual pipeline layout |
23+
| CP | context-parallel communication inside CP execution paths | CP implementation choice |
24+
| EP | MoE token dispatch/combine communication under expert compute | `overlap_moe_expert_parallel_comm` |
2425

25-
These are related performance techniques, but they do not share the same gates,
26-
defaults, or operational risks.
26+
These paths share the same goal, but they do not share the same enablement
27+
rules, evidence level, or failure modes.
28+
29+
## What Problem It Solves
30+
31+
Distributed training often becomes communication-bound before it becomes
32+
compute-bound. Once TP, DP, PP, CP, or EP traffic is visible on the critical
33+
path, adding more GPUs may raise communication time faster than it raises useful
34+
compute.
35+
36+
Communication overlap addresses that by moving communication earlier or later in
37+
the step so the same transfer can happen while some other part of the model is
38+
already doing useful work. It does not change the training objective. It tries
39+
to reduce idle time.
40+
41+
## Impacted Training Dimensions
42+
43+
| Dimension | Effect | Confidence | Why |
44+
|---|---|---|---|
45+
| `speed` | `+` to `++` | medium | The whole point is to hide communication time, but gain depends strongly on which overlap mode is active and whether communication is actually exposed. |
46+
| `memory` | `0` | low | Overlap itself is usually not a primary memory technique, although some implementations add buffer or scheduling constraints. |
47+
| `scale` | `+` | medium | Overlap becomes more valuable as communication dominates larger distributed runs. |
48+
| `convergence` | `0` | medium | The intent is to preserve the same training math, though schedule changes can alter floating-point accumulation order. |
49+
| `stability` | `-` | medium | More overlap usually means tighter requirements around schedule shape, precision, runtime versions, and feature combinations. |
2750

2851
## When to Use It
2952

30-
Communication overlap is a good fit when:
53+
Enable communication overlap when all of the following are mostly true:
3154

32-
- the model already needs TP, DP, PP, CP, or EP for scale
55+
- the distributed configuration already works correctly without overlap
3356
- communication is a meaningful part of step time
34-
- correctness is already established and you are tuning for throughput
57+
- you are tuning throughput or utilization, not doing first bring-up
58+
- you can benchmark the specific overlap mode you plan to use
59+
60+
As a rule of thumb:
61+
62+
| Mode | Good first use case | Recommendation |
63+
|---|---|---|
64+
| DP | distributed optimizer on multi-GPU or multi-node training | Usually worth considering early once optimizer sharding is already chosen. |
65+
| TP | `TP >= 2` with sequence parallelism and TE-enabled path | Benchmark when TP collectives are visible in the profile. |
66+
| PP | interleaved pipeline schedules where p2p overhead is visible | Treat as schedule tuning, not a blanket PP default. |
67+
| CP | large-context runs already using CP | Follow the CP-specific guidance rather than treating it as a separate generic knob. |
68+
| EP | large-scale MoE with many micro-batches and inter-node A2A cost | Most promising at larger EP and with higher-latency dispatcher backends. |
69+
70+
Measured repo evidence today is strongest for MoE EP overlap. On
71+
Qwen3-30B-A3B with EP=4 and `alltoall` on 2 H100 nodes, EP overlap is
72+
numerically safe at GBS=8 but provides no speedup, and it is about 13% slower
73+
at GBS=64. On Qwen3-Next-80B-A3B with EP=8 and `alltoall` on 8 nodes, the
74+
overlap variants are stable while the non-overlap baseline NaNs, but
75+
`delay_wgrad_compute` is still about 4.8% slower than overlap-only. That makes
76+
EP overlap correctness-backed in this repo, but not yet broadly speedup-backed.
77+
78+
## When Not to Use It
79+
80+
Avoid communication overlap when any of these are true:
81+
82+
- you are still debugging a new distributed setup
83+
- the profile is compute-bound rather than communication-bound
84+
- the required companion feature is missing, such as sequence parallelism for TP
85+
- another feature already imposes conflicting runtime constraints
86+
- you have not benchmarked the exact model and parallelism shape
87+
88+
For MoE EP overlap specifically, avoid treating it as a default when:
89+
90+
- `EP <= 4` with `alltoall` on `<= 2` nodes
91+
- the run has very few pipeline micro-batches
92+
- `moe_shared_expert_overlap` must stay enabled
93+
- full recompute or recompute scheduling incompatible with EP overlap is required
94+
95+
## Feature Interactions
3596

36-
It is less appropriate when:
97+
The most important interactions are:
3798

38-
- you are still bringing up a new training path and want minimal moving parts
39-
- the feature combination is branch-sensitive or weakly validated
40-
- launch-time environment tuning is likely to conflict with another technique
99+
- DP overlap is tied to distributed-optimizer behavior rather than a fully independent tuning path.
100+
- TP overlap depends on sequence parallelism and the supported TE overlap path.
101+
- PP and EP overlap interact with virtual pipeline layout when `PP > 1`.
102+
- CP overlap should be reasoned about together with the chosen CP communication type.
103+
- EP overlap with DeepEP or HybridEP requires explicitly switching the dispatcher to `flex`.
104+
- EP overlap and `moe_shared_expert_overlap` are mutually exclusive.
105+
- CUDA graphs plus `delay_wgrad_compute` adds extra TE-version and graph-scope restrictions.
106+
- Launch-time environment tuning can conflict across overlap paths, especially TP or CP overlap versus DeepEP or HybridEP tuning.
41107

42-
## Stable Per-Mode Guidance
108+
## Bridge Configuration
43109

44-
### Data Parallel
110+
At a high level, communication overlap is configured through
111+
`CommOverlapConfig`, plus mode-specific model settings:
45112

46-
DP overlap is tied to the distributed-optimizer path. It is the natural overlap
47-
mechanism for sharded optimizer-state training and should be reasoned about
48-
together with distributed optimizer behavior rather than as an isolated knob.
113+
```python
114+
from megatron.bridge.training.comm_overlap import CommOverlapConfig
115+
from megatron.bridge.training.flex_dispatcher_backend import apply_flex_dispatcher_backend
49116

50-
### Tensor Parallel
117+
cfg.comm_overlap = CommOverlapConfig(tp_comm_overlap=True)
51118

52-
TP overlap is conceptually tied to sequence parallelism. If sequence
53-
parallelism is not available or not enabled, TP overlap should not be assumed to
54-
remain active.
119+
cfg.model.tensor_model_parallel_size = 2
120+
cfg.model.sequence_parallel = True
55121

56-
### Pipeline Parallel
122+
cfg.comm_overlap.overlap_moe_expert_parallel_comm = True
123+
cfg.comm_overlap.delay_wgrad_compute = False
124+
cfg.model.expert_model_parallel_size = 8
125+
cfg.model.num_moe_experts = 64
126+
cfg.model.moe_token_dispatcher_type = "alltoall"
127+
cfg.model.moe_shared_expert_overlap = False
57128

58-
PP overlap is not a blanket property of all pipeline-parallel training. In
59-
practice, interleaved pipeline schedules are the most important positive case.
129+
# For DeepEP or HybridEP, switch the dispatcher to "flex" explicitly.
130+
# apply_flex_dispatcher_backend(cfg.model, moe_flex_dispatcher_backend="deepep")
131+
```
60132

61-
### Context Parallel
133+
The important design point is that "communication overlap" is not one universal
134+
toggle. DP, TP, PP, CP, and EP each have different prerequisites and should be
135+
enabled based on the actual bottleneck.
62136

63-
CP overlap is part of Bridge's context-parallel execution model rather than a
64-
separate standalone technique page. For hierarchical or `a2a+p2p` CP guidance,
65-
see `docs/training/hybrid-context-parallel.md`.
137+
## Minimal Runnable Example
66138

67-
### MoE Expert Parallel
139+
For a measured end-to-end MoE overlap path, use:
68140

69-
MoE expert-parallel overlap hides the cost of token dispatch/combine all-to-all
70-
communication by overlapping it with expert FFN compute. Optionally, delayed
71-
expert weight-gradient computation (`moe_delay_wgrad_compute`) provides
72-
additional overlap.
141+
- `scripts/experiments/ep_overlap_qwen3_moe.py`
73142

74-
MoE overlap should be treated separately from generic TP, DP, and PP overlap.
75-
Its constraints depend on dispatcher choice (`alltoall` or `flex`), expert
76-
parallelism degree, precision (BF16/FP16), and runtime support. When pipeline
77-
parallelism is used, virtual pipeline parallelism is required for the overlap
78-
scheduling to interleave correctly.
143+
That wrapper exists because some recipes leave `comm_overlap=None`, and CLI
144+
overrides cannot create `CommOverlapConfig` from `None`.
79145

80-
## Stable Constraints and Caveats
146+
For lightweight local verification of overlap validation logic, start from:
81147

82-
The most durable caveats are:
148+
- `tests/unit_tests/training/test_comm_overlap.py`
149+
- `tests/unit_tests/training/test_deepep.py`
83150

84-
1. Not all overlap modes are auto-enabled in the same situations.
85-
2. Some overlap-related precision settings are owned by mixed-precision config,
86-
not by standalone overlap tuning alone.
87-
3. Launch-time environment settings are part of the technique in practice,
88-
especially for TP, CP, and MoE overlap paths.
89-
4. Recipe defaults are often conservative; feature existence does not imply that
90-
every public recipe enables the corresponding overlap path.
151+
## Expected Metric Changes
91152

92-
## Recommendation Level
153+
| Metric | Expected Change | Conditions | Evidence |
154+
|---|---|---|---|
155+
| `step_time` | down | DP overlap with distributed optimizer on communication-heavy runs | expected |
156+
| `step_time` | down | TP overlap with `TP >= 2`, sequence parallelism, and supported TE path | expected |
157+
| `pipeline_idle_time` | down | interleaved PP where p2p cost is visible | expected |
158+
| `step_time` | flat | Qwen3-30B-A3B, EP=4, `alltoall`, 2 nodes, GBS=8 | measured: 822ms baseline vs 827ms overlap |
159+
| `step_time` | up | same model/config, GBS=64 | measured: 4889ms baseline vs 5538ms overlap |
160+
| `step_time` | up | Qwen3-Next-80B-A3B, EP=8, `alltoall`, 8 nodes, `delay_wgrad_compute=True` vs overlap-only | measured: 4912ms vs 4686ms |
93161

94-
Treat communication overlap as a tuning layer on top of a working distributed
95-
configuration, not as the first knob to reach for when basic correctness is
96-
still uncertain.
162+
Do not assume one overlap win transfers automatically to another mode. The
163+
correct question is always "which communication path is exposed in this run?"
97164

98-
For most teams, the right order is:
165+
## Common Failure Modes
99166

100-
1. establish a correct distributed configuration
101-
2. choose the necessary parallelism strategy
102-
3. enable or tune overlap for the specific communication bottleneck
167+
- TP overlap silently disables itself when sequence parallelism is off or `TP < 2`.
168+
- PP overlap expectations are wrong when the schedule is non-interleaved or VPP is missing.
169+
- EP overlap asserts when `PP > 1` but `virtual_pipeline_model_parallel_size` is unset.
170+
- EP overlap asserts when full recompute, recompute method, or shared-expert overlap stays enabled.
171+
- Setting `moe_flex_dispatcher_backend` alone does not activate DeepEP or HybridEP; the dispatcher must actually switch to `flex`.
172+
- Small-EP `alltoall` MoE runs can get slower because scheduling overhead is larger than the communication being hidden.
103173

104174
## Related Docs
105175

106-
- [docs/performance-guide.md](../performance-guide.md)
107-
- [docs/training/hybrid-context-parallel.md](hybrid-context-parallel.md)
108-
- [skills/perf-techniques/tp-dp-comm-overlap/SKILL.md](../skills/perf-techniques/tp-dp-comm-overlap/SKILL.md)
109-
- [skills/perf-techniques/expert-parallel-overlap/SKILL.md](../skills/perf-techniques/expert-parallel-overlap/SKILL.md)
176+
- [Performance Guide](../performance-guide.md)
177+
- [CUDA Graphs](cuda-graphs.md)
178+
- [Hybrid Context Parallel](hybrid-context-parallel.md)
179+
- `skills/perf-techniques/tp-dp-comm-overlap/SKILL.md`
180+
- `skills/perf-techniques/expert-parallel-overlap/SKILL.md`

0 commit comments

Comments
 (0)