Long-context LLM training · Dynamic context parallelism

Demystifying and Taming Dynamic Context Parallelism at Production Scale

Training timeline of one iteration under Mcore DCP across nine pipeline stages; large green pipeline bubbles and a DP bubble before the optimizer step.
One iteration of our production 256K-context job on 11K+ GPUs under Megatron-Core DCP. Microbatches with similar token counts differ by up to 5× in execution time, so pipeline bubbles (green) eat 46% of the pipeline and the DP replicas idle before the optimizer step.
TL;DR

Production DCP sizes each sequence's context-parallel (CP) degree to fit memory. Memory grows linearly with length but attention grows quadratically, so equal tokens hide unequal work. HyDra sizes CP degrees by attention load instead, pulling every rank toward one closed-form load target. It places sequences with lazy heaps instead of whole-pool scans, and runs the large degrees this target demands with a nested inner-Ulysses × outer-ring CP engine.

GPUs in the production job we characterize
11K+
256K context, Mcore DCP
Throughput vs. Mcore DCP at 256K
2.48×
average, 512-GPU testbed
Throughput vs. Mcore DCP in production
1.25×
average, 2,048 GPUs (1.59× vs. static CP)
Pipeline bubble in production
36% → 14%
2,048 GPUs, vs. Mcore DCP

00Abstract

Long-context training runs on sequences whose lengths span orders of magnitude, and dynamic context parallelism (DCP) gives each sequence its own CP degree. Existing DCP systems either do not scale or perform poorly on mainstream models, leaving Megatron-Core (Mcore) DCP as the only option at production scale. Mcore DCP, however, sizes each degree to fit memory, which grows linearly with length while attention grows quadratically, so comparable token counts hide unequal computation. In our production 256K-context training job on more than 11K GPUs under Mcore DCP, per-rank microbatch times differ by up to 5× at similar token counts. The skew leads to a 46% pipeline bubble and a 13% data-parallel bubble.

We present HyDra, a scalable load-driven DCP system. Its scheduler balances computation by pulling every rank toward one load target, and balance in turn makes that target solvable in closed form. It places sequences with lazy heaps rather than whole-pool scans. That balance asks for CP degrees larger than memory requires, so its CP engine nests an inner Ulysses group in a shallow outer ring, letting a higher degree lower computation and communication together.

Evaluation at both scales shows consistent gains. On a 512-GPU testbed, HyDra raises throughput over Mcore DCP by 1.18× on average at 32K context and 2.48× at 256K. On a 2,048-GPU production job, it shrinks the pipeline bubble from 36% to 14%, cuts scheduling time by 2.3×, and raises throughput by 1.10–1.43× (avg. 1.25×) over Mcore DCP and 1.33–1.90× (avg. 1.59×) over static CP.

01Comparable tokens, unequal computation

Real long-context corpora mix many short documents with a few very long ones: in our 256K dataset, more than 85% of sequences are below 2K tokens and fewer than 0.6% exceed 32K. DCP handles this by giving each sequence its own CP degree, cut from a shared hybrid data-parallel (HDP) pool of DP×CP ranks.

The DCP scheduler shipped in Megatron-Core sizes each degree from a per-rank token budget, so every sequence goes to the fewest ranks that hold it. The budget counts tokens, but attention work grows as \(s^2\). We traced Mcore DCP on a 256K-context job with 11K+ GPUs (Hy4-preview, 770B MoE, \(tp{=}2, pp{=}9, ep{=}32\)) and found four problems.

DCP under a 4K per-rank token budget: a 16K sequence spans four ranks, 8K sequences take two, 4K sequences stay on one.
Memory-driven DCP with a 4K per-rank token budget. The same four ranks form one group of four in MB 0, two groups of two in MB 1, and four groups of one in MB 2.

Per-rank tokens are balanced. Attention is not.

Across the microbatches (MBs) of one iteration, per-rank token counts stay of the same order (about 5K on average), while per-rank attention intensity \(\mathcal{I}=\sum_i s_i^2/R\) spans four orders of magnitude, from about 0.1M to about 1,000M.

The heaviest MB runs more than 5× longer than the lightest. Every stage must process it, so it sets the critical path and widens the PP bubble from a ~10% balanced floor to 45.97%.

Insight 1. MBs must be balanced by attention computation, not by tokens alone.

Per-rank tokens and attention intensity for 27 microbatches: tokens 2.6K to 8K, intensity 0.03M to 671M.
Per-rank profile of each MB: tokens (blue) vs. attention intensity (orange, log scale).

02HyDra: load-driven DCP

HyDra system overview: load-driven scheduling (closed-form targets, piggyback packing, heap-accelerated scheduling) feeding balance-preserving CP communication (inner Ulysses / outer ring, exposed all-to-all overlap).
HyDra overview. The scheduler sets every sequence's CP degree, and the CP engine executes those degrees.

HyDra turns the four insights into four principles and realizes them with two co-designed components inside Megatron-LM (about 3K lines of Python).

  1. Balance computation, not just tokens, while keeping the memory feasibility DCP already provides.
  2. Balance within and across MBs: CP groups inside an MB and DP replicas across the iteration.
  3. Keep online planning lightweight: no whole-pool work as clusters grow.
  4. Scale CP without a communication bottleneck: degrees beyond the head count, with traffic that shrinks as the degree grows.
§5.1
Load-driven scheduling. Estimates attention load from sequence lengths and picks each sequence's CP degree and placement against a single per-rank load target (Principles 1–3).
§5.2
Balance-preserving CP communication. Executes the selected degrees beyond native CP limits and hides exposed transfers behind dependency-free compute (Principle 4).

Neither component works alone: native CP cannot reach the target the scheduler sets, and the degrees the engine supports pay off only when a balanced plan requests them.

One load target, in closed form

Load target
$$\Lambda^\star=\frac{s_{\max}^2}{C}$$

Even at the cap \(C\), the longest sequence leaves \(s_{\max}^2/C\) on each of its ranks. This is the lowest feasible target, and also the easiest for token-limited MBs of short sequences to reach.

CP cap
$$T(C)\approx T_0+\frac{\beta}{C}+\gamma C$$$$\widehat C^\star=\sqrt{\beta/\gamma}$$

Iteration time with skew is a graph of waits with no closed form. Under balance, a larger cap trades a shorter pipeline bubble (\(\beta/C\)) against more MBs, each with a fixed cost (\(\gamma C\)). Only the ratio \(\theta/c\) needs to be calibrated.

Per-sequence degree
$$cp(s)=\min\!\Big\{C^\star,\ \Big\lceil \max\!\Big\{\tfrac{s^2}{\Lambda^\star},\,\tfrac{s}{B}\Big\}\Big\rceil_2\Big\}$$

The smallest power-of-two degree that meets both the computation target and the token budget \(B\). Mcore enforces only \(s/B\).

Try it: memory-driven vs. load-driven CP degrees

Eq. (9) in the 256K production setting (\(s_{\max}=256\text{K}\), \(B=8\text{K}\), so \(C_{\text{mem}}=32\)). Drag the cap \(C\) to see how HyDra gives long sequences more ranks and flattens the heaviest per-rank load.

CP cap \(C\)
CP degree of a length-\(s\) sequence
Per-rank attention load \(s^2/cp\) (1 = Mcore's heaviest)
Table view

Illustrative, per-sequence view of the paper's equations. Short sequences are not left underloaded: piggyback packing fills ranks with them up to \(\Lambda^\star\) or the token budget. Packing, communication, and pipeline effects are not modeled here.

Piggyback packing

Sequences are placed longest-first, one MB at a time across all \(G\) ranks. A sequence needing degree \(k\) opens a new \(k\)-aligned group if enough ranks are free. Otherwise it piggybacks on the smallest feasible open group of size \(\ge k\), with ties broken by load. Short sequences fill the gaps next to wide long-sequence groups, so fewer ranks sit idle and fewer MBs are needed. Because every MB is packed against the same \(\Lambda^\star\), the balance extends to the CP and EP groups inside an MB and to the DP replicas after it.

Heap-accelerated scheduling

Open groups are partitioned by CP degree. Each class keeps a lazy min-heap keyed by load and a max-heap keyed by remaining token capacity. Stale entries are dropped on access, and a candidate that violates the budget is demoted instead of rescanned. Classes whose minimum already reaches \(\Lambda^\star\) are pruned. The result is the same least-loaded placement as a linear search, with the same tie-breaking.

\(O(NG)\)→\(O(N\log G)\)

Balance-preserving CP communication

Inner Ulysses × outer ring

$$P=cp_u\cdot cp_r,\qquad cp_u=\min(P,h),\quad cp_r=P/cp_u$$

Up to the head count \(h\), the degree is pure Ulysses. Beyond it, a shallow outer ring supplies the remaining factor, so the scheduler may request any \(P\le C^\star\) while per-rank compute stays \(s^2/P\). The ring's flat traffic floor is confined to the residual factor: at \(P{=}256\) and \(h{=}64\), the outer ring spans only four ranks.

Exposed all-to-all overlap

Rather than materializing Q, K, and V and then issuing three blocking collectives, HyDra launches each all-to-all on a separate stream as soon as its tensor is final, and hides it behind the independent branches of gated MLA. Q goes first (covered by the KV projections), then V (covered by K's RoPE and concat), then K (covered by the gate projection). Launch and wait are paired autograd functions, so backward gets the mirrored overlap automatically.

Asynchronous all-to-all schedule in gated MLA: Q, V, K all-to-alls overlap with Comp_kv, Comp_k, Comp_gate in forward; mirrored in backward.
Asynchronous all-to-all schedule in gated MLA, forward and backward.
Profiler trace of one attention layer in HyDra: Ulysses all-to-alls overlap with compute and ring send/recv pipeline with flash-attention kernels.
Attention trace in HyDra: the Ulysses all-to-alls run behind computation, and the outer ring's send/recv pipelines with the attention kernels.

03Results

We evaluate at three scales: a 512-GPU NVIDIA H20 testbed, a production job on 2,048 NVIDIA H800 GPUs (both on an internal MLA-based MoE model with \(tp1, pp4, ep8\)), and simulation at 8K–40K GPUs. Baselines on hardware are static CP and Mcore DCP. Simulation adds ByteScale, WLB-LLM, and FlexSP.

512-GPU testbed

2.48×avg. throughput vs. Mcore DCP (1.42–3.08×)
2.30×avg. throughput vs. static CP
23.3%PP bubble, vs. 36.5% static CP / 55.7% Mcore DCP
76.0%compute-stream busy time, vs. 39.0% static CP / 42.2% Mcore DCP
256K throughput: static CP 11.2, Mcore DCP 10.4, HyDra 25.8 B tokens/day.
Throughput (B tokens/day)
256K step time range.
Step-time range
256K per-step step time series.
Step time per step
Legend: chunk 0/1/2 forward and backward, optimizer.
Static CP256K pipeline timeline under static CP.
Mcore DCP256K pipeline timeline under Mcore DCP.
HyDra256K pipeline timeline under HyDra.

One iteration across the four PP stages at 256K context (same time axis). Under Mcore DCP the stages are full of gaps. Under HyDra they stay packed and the iteration ends much earlier.

2,048-GPU production job · 256K context

1.25×avg. throughput vs. Mcore DCP (1.10–1.43×)
1.59×avg. throughput vs. static CP (1.33–1.90×)
13.6%PP bubble, vs. 47.1% static CP / 36.4% Mcore DCP
<1%DP bubble, vs. up to 59.2% static CP / 10.1% Mcore DCP
2,048-GPU iteration time: HyDra 15.9 s vs 25.2 s static CP and 19.9 s Mcore DCP.
Iteration time
2,048-GPU throughput: HyDra 182.7 B tokens/day.
Throughput
2,048-GPU microbatch time range; coefficient of variation 49% under HyDra vs 73% and 108%.
MB-time range (CV: 49% HyDra, 73% static CP, 108% Mcore DCP)
Legend: chunk 0/1/2 forward and backward, optimizer.
Static CPProduction pipeline timeline under static CP.
Mcore DCPProduction pipeline timeline under Mcore DCP, ending around 20.6 s.
HyDraProduction pipeline timeline under HyDra, ending around 16 s.

One iteration across the four PP stages on 2,048 GPUs (same time axis).

Where the CP degrees go

HyDra spends context parallelism where it balances MBs. Mcore DCP never exceeds the memory-driven \(cp{=}32\). HyDra puts 45.5% of GPUs at \(cp \ge 64\) and 22.7% at \(cp{=}256\), which the inner-Ulysses × outer-ring engine makes affordable.

What it saves

For an illustrative 2T-token budget at these rates, training takes 17.4 days under static CP, 13.7 under Mcore DCP, and 11.0 under HyDra. At $2 per GPU-hour that is $632K saved over static CP and $271K over Mcore DCP on 2,048 GPUs.

Fraction of GPUs at each CP degree under Mcore DCP: max CP 32.
Mcore DCP
Fraction of GPUs at each CP degree under HyDra: up to CP 256 (22.7%).
HyDra

Scheduling overhead

Scheduling runs on the CPU, so we can measure it at any rank count. Mcore DCP's whole-pool scans reach 47.85 s at 16K GPUs, while HyDra takes 4.12 s, an 11.6× speedup. On the 2K-GPU production run, online scheduling drops from 0.78 s to 0.34 s (2.3×).

Scheduling time of Mcore DCP vs HyDra from 2K to 16K GPUs.

Model convergence

HyDra reorders gradient and loss reductions, so small floating-point differences are expected. Over roughly 8,000 iterations its language-modeling loss stays within 10−3 of static CP, and it records the lower loss in about half of the iterations: unbiased noise rather than drift.

Training loss curves of HyDra and static CP overlapping over about 8,000 iterations.

Scale-out simulation, 8K–40K GPUs

An in-house simulator replays batches through the full parallel schedule with operator costs measured on the same hardware. Validated against per-rank production traces at 11K+ GPUs, it lands within 10% of the measured mean iteration time.

On Hy3 (GQA) at 8K GPUs, HyDra improves over the strongest baseline, ByteScale, by 1.28×, over Mcore DCP by 1.53×, over WLB-LLM by 1.56×, and over FlexSP and static CP by 1.7–2.2×. It is not the best on any single axis. It wins because it keeps the PP bubble (19.8%) and DP bubble (3.6%) low together without paying static CP's communication cost.

Under weak scaling to 40K GPUs, HyDra is fastest at every scale. Its lead is wider on the MLA model DeepSeek-V3: 1.53× over ByteScale, 1.61× over Mcore DCP, and up to 13.8× over ring static CP.

Simulation on 8K GPUs: normalized throughput, step time, PP bubble and DP bubble for seven systems; HyDra best throughput 2.22.
Hy3 on 8K GPUs, normalized to static CP (ring).
Legend: CP (ring), CP (Ulysses), MCore DCP, HyDra, FlexSP, WLB-LLM, Bytescale.
Weak scaling throughput, Hy3.
Throughput (Hy3)
Weak scaling iteration time, Hy3.
Iteration time (Hy3)
Weak scaling MFU, Hy3.
MFU (Hy3)
Weak scaling throughput, DeepSeek-V3.
Throughput (DeepSeek-V3)
Weak scaling iteration time, DeepSeek-V3.
Iteration time (DeepSeek-V3)
Weak scaling MFU, DeepSeek-V3.
MFU (DeepSeek-V3)

04Paper & citation

First page of the HyDra paper.
BibTeX
@misc{fan2026hydra,
  title  = {HyDra: Demystifying and Taming Dynamic Context
            Parallelism at Production Scale},
  author = {Fan, Zihao and Liu, Yunzhuo and Jiang, Bo and
            Zheng, Changgang and Zheng, Lin and Ying, Ray and
            Zhang, Key},
  year   = {2026},
  note   = {Preprint}
}