Skip to content

Add DP-balanced sequence-packing scheduler and integrate it into GPT pretraining - #6679

Closed
ilml wants to merge 4 commits into
NVIDIA:mainfrom
ilml:split/3386-dcp-scheduler
Closed

Add DP-balanced sequence-packing scheduler and integrate it into GPT pretraining#6679
ilml wants to merge 4 commits into
NVIDIA:mainfrom
ilml:split/3386-dcp-scheduler

Conversation

@ilml

@ilml ilml commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds the DP-balanced sequence-packing scheduler for dynamic context parallelism and integrates it into the training loop and GPT pretraining. Part of the #3386 split series tracked in the Dynamic Context Parallelism project. Original changes by @xiaoyao0115 in #3386.

This consolidates three former layers of the series (their PRs #6626/#6627/#6628 were closed by a base-branch mishap; nothing from them landed):

Commit Layer Content
1 02 Temporary copy of #5902 (config field, CLI arg, validation) — see note below
2 05 DP-balanced sequence-packing scheduler and wrap_data_iterator entry point (megatron/core/datasets/data_schedule.py)
3 06 Mock SFT dataset and generalized SFT padding divisor
4 07 Scheduler integration into train_step/evaluate and pretrain_gpt.py

Note: commit 1 is a copy of open PR #5902 (approved, awaiting one @NVIDIA/core-adlr approval), which the mock-SFT and integration layers depend on. Once #5902 merges, this branch will be rebased and that commit (and its ~80 diff lines) drop out automatically. Merge order: #5902 → this PR → the varlen dataset PR.

Contribution process

  • Draft PR per contributing guidelines
  • Commits signed off (DCO)

ilml and others added 4 commits August 19, 2026 20:24
Split 2/10 from NVIDIA#3386 (sequence packing / THD E2E support). Adds the
sequence_packing_scheduler knob to ModelParallelConfig, its
TransformerConfig validation (TE>=2.9 pin, variable_seq_lengths,
alltoall dispatcher), the explicit CLI args, and validate_args checks.
Feature-flagged no-op until the scheduler lands.

Original changes by @xiaoyao0115 in NVIDIA#3386.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: ilml <tolong@nvidia.com>
…ry point

Split 5/10 from NVIDIA#3386 (sequence packing / THD E2E support). Adds
BasePackingScheduler, DpBalancedScheduler, PackingSchedulerEnum, the
wrap_data_iterator entry point, docs, and the wrap_dataloader unit
tests.

Original changes by @xiaoyao0115 in NVIDIA#3386.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: ilml <tolong@nvidia.com>
Split 6/10 from NVIDIA#3386 (sequence packing / THD E2E support). Adds
MockSFTDataset/MockSFTLowLevelDataset with file- and distribution-mode
sequence-length configs, the load_json_arg helper, the
--sft-mock-dataset-config-json arg with lognormal default, and
generalizes the SFT padding divisor beyond cp>1.

Original changes by @xiaoyao0115 in NVIDIA#3386.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: ilml <tolong@nvidia.com>
…aining

Split 7/10 from NVIDIA#3386 (sequence packing / THD E2E support). Wires
wrap_data_iterator into train_step/evaluate with dynamic
num_microbatches, adds global seqlen-stats plumbing for FLOPs
accounting, gates the HybridCP sampler, and restructures
pretrain_gpt.forward_step for packed (THD) batches with padding mask.

Original changes by @xiaoyao0115 in NVIDIA#3386.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: ilml <tolong@nvidia.com>
@copy-pr-bot

copy-pr-bot Bot commented Aug 19, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@ilml

ilml commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 65727ed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant