Repository navigation
[feature] intra-microbatch reordering for MegatronMIMO (+ sequence packing, scalable DP) #4609
Description
User problem
Non-colocated MegatronMIMO training (e.g. Qwen3.5-VL: separate vision encoder + language model wired by BridgeCommunicator) has a per-step data-parallel straggler: per-micro-batch multimodal load
(vision patch count) is uneven across samples, so a DP rank that draws a heavy-image shard stalls the whole group every step. Throughput is bounded by the slowest rank.
Two supporting gaps make this worse / block the fix:
- Sequence packing is unused. MegatronMIMO on Megatron-Core supports packed sequences, but in Megatron Bridge, there is no logic to actually feed a packed language shard, so padding is computed.
- Data parallelism is not scalable (vision DP = 1 only). Today every DP worker reads the full global micro-batch and slices its own part locally in the forward step → CPU/host-IO overhead that scales with DP, and vision DP > 1 is effectively unsupported. When the vision data parallel degress scale linearly, the total i/o volume across the cluster will scale quadratically.
Desired outcome
Main — Intra-microbatch Reordering (cf. DistTrain §5.2, https://arxiv.org/abs/2408.04275):
rebalance each micro-batch's vision load across the module DP group, so per-rank vision
load is even and the straggler tail is removed. Works with heterogeneous DP (vision_dp != language_dp)
via canonical n_groups pairing (vision replica r ↔ language replica r) and a variable number of
images per sample (0 / 1 / N).
Auxiliary 1 — Sequence Packing: add the logic to pack a language DP shard's real tokens into a
single [1, T] THD sequence so the LM skips padding compute (MCore already accepts packed input).
Auxiliary 2 — Scalable Data Parallelism: let each rank's sampler read only its disjoint 1/dp
shard instead of every rank reading the full batch and slicing locally — reducing the per-rank CPU/IO
overhead and enabling vision DP > 1. This is the read-sharding base the reorder rebalances on top of.
All three are off by default and gated by MegatronMIMOFeatureConfig. Expected effect (16-GPU
validation): median throughput dominated by the read-sharding win, plus a large straggler-tail
reduction; same total work / same images processed.
The name/implementation of the configuration class can be a subject of discussion.
Alternatives considered
- Status quo — full-batch read + forward-time local slice (
slice_batch_for_megatron_mimo):
wastes host IO, supports vision DP = 1 only, cannot rebalance per-rank cost.
Affected area
area:data (primary), area:training
Urgency / use case
Important but not blocking.
Use case: non-colocated MegatronMIMO VLM finetuning (Qwen3.5-VL + receipt/doc datasets) where vision load is the per-step straggler.
Extra context
- Implementation: PR feat(data): intra-microbatch reordering for MegatronMIMO (+ sequence packing, scalable DP) #4608 .
- Out of scope: Inter-microbatch (DistTrain S5.3) reordering is a future follow-up — the
transport is built inter-ready but the balancer stays intra-only.
Activity
liding-nv commentedon Jul 2, 2026
@sailor1493 thank you for the contribution. i will review the PR and we can take it from there
liding-nv commentedon Jul 9, 2026
hello @sailor1493 following up after checking the PR and the issue. This is a good feature and we definitely want to have them. I have several high-level points I'd like to align on first
sailor1493 commentedon Jul 10, 2026
Good day! @liding-nv
It seems that our views are largely aligned. However, since today is my last day at NAVER Cloud—I’m moving on to a new opportunity :)—I may not be able to contribute further to this issue. Yoonsik or Gayeon will make further comments.
Yoonsik (@terryyoo), Gayeon (@going-song), and other contributors will continue working on it. Thank you for your understanding.
Wishing both NVIDIA and NAVER Cloud the very best!
huvunvidia commentedon Jul 10, 2026
Hi @sailor1493 ,
Thank you for letting us know.
Since I am not able to tag Yoonsik and Gayeon, I wonder if you can engage them into the conversation to move forward with @liding-nv 's discussion above?
terryoo commentedon Jul 12, 2026
Hi @liding-nv , this is Yoonsik from NAVER Cloud. I'll be taking over this discussion going forward along with Gayeon.
terryoo commentedon Jul 14, 2026
Good day! @liding-nv
2 remaining items
feat(training): add MegatronMIMO in-batch sequence packing
feat(training): add MegatronMIMO in-batch sequence packing
going-song commentedon Jul 28, 2026
Hi @liding-nv — first split is up (#5131) : MegatronMIMO in-batch sequence packing
The second (scalable data loading) and third (intra-microbatch reordering) are
in progress and will follow as separate PRs on top of it.
(cc. @sailor1493 @terryoo )
feat(data): scalable canonical-grid reads for MegatronMIMO data loading
feat(data): scalable canonical-grid reads for MegatronMIMO data loading
feat(data): scalable canonical-grid reads for MegatronMIMO data loading
feat(data): scalable canonical-grid reads for MegatronMIMO data loading
feat(data): scalable canonical-grid reads for MegatronMIMO data loading
going-song commentedon Oct 3, 2026
Hi @liding-nv — the remaining two splits are up:
#6306 also carries two small unrelated fixes needed for MegatronMIMO training on current main; details in the PR description.
(cc. @sailor1493 @terryoo)
going-song commentedon Oct 13, 2026
All three splits from #4609 (comment) are merged:
The original PR #4608 is already closed, so this issue can be closed as well.