Add mock SFT dataset and varlen dataset family - #6734
Merged
Conversation
Split 2/10 from NVIDIA#3386 (sequence packing / THD E2E support). Adds the sequence_packing_scheduler knob to ModelParallelConfig, its validation (field checks in ModelParallelConfig post_init; TE>=2.9 pin and alltoall dispatcher in TransformerConfig), 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>
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>
Split 9/10 from NVIDIA#3386 (sequence packing / THD E2E support). Adds the variable-length packed (THD) dataset family: HF-hub/parquet/jsonl loading, THD __getitem__ with cu_seqlens, SBHD validation mode, and the mock variant, with unit tests. Also adds hybrid_context_parallel=False to the _make_config test helper (deviation from NVIDIA#3386: fixes a latent AttributeError in _calculate_padding_divisor with SimpleNamespace configs). Original changes by @xiaoyao0115 in NVIDIA#3386. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: ilml <tolong@nvidia.com>
Contributor
Author
|
/ok to test d9fdfa6 |
ilml
marked this pull request as ready for review
August 21, 2026 03:06
This was referenced Aug 21, 2026
cuichenx
approved these changes
Aug 21, 2026
zhongbozhu
approved these changes
Aug 21, 2026
Contributor
Author
|
/ok to test 946476b |
The module-level import broke the minimal-install import check: pandas is deliberately only in the ci dependency group, not a core dependency. Guard the import inside the mode == "file" branch with a targeted ImportError, matching the existing pattern in varlen_dataset.py. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: ilml <tolong@nvidia.com>
janEbert
reviewed
Aug 24, 2026
janEbert
left a comment
Contributor
There was a problem hiding this comment.
It seems like Pandas is just used to load CSV/JSON. In the case of JSON, I think you can load from JSON directly with datasets.load_dataset.
For CSV, I'd also say just use the csv package from stdlib, unless it's too slow compared to using Pandas.
Then we avoid introducing the additional dependency, since Pandas isn't used anywhere else yet (except CI).
Contributor
Author
|
/ok to test 4ccffde |
Per review: pandas was only used to read the mock sequence-length CSV
and local jsonl files, and is not a package dependency (it is only in
the ci group).
- MockSFTLowLevelDataset(mode="file") reads the CSV with the stdlib csv
module, skipping non-numeric cells such as a header row.
- VarlenLowLevelDataset parses local jsonl with the stdlib json module
and builds the table with Dataset.from_list. This keeps the property
the pandas path existed for: one pyarrow pass over the whole file, so
rows with differing field sets unify into one schema instead of
failing datasets.load_dataset("json")'s per-chunk inference with a
CastError (e.g. LongAlpaca-12k).
- Remove the now-stale pytest.importorskip("pandas") gates so the tests
also run in environments without pandas.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: ilml <tolong@nvidia.com>
Contributor
Author
|
/ok to test 41de47f |
The pre-existing allgather-vs-variable_seq_lengths ValueError ran for dense models too, where the (unused) dispatcher default is allgather. Sequence packing derives variable_seq_lengths=True, so every dense packing config failed validation. Gate the check on num_moe_experts, matching the packing-specific dispatcher assert below, and update the MoE test to expect the general check's ValueError, which fires before the packing assert for allgather. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: ilml <tolong@nvidia.com>
Contributor
Author
|
/ok to test 0b38f86 |
jaredcasper
approved these changes
Aug 26, 2026
ilml
enabled auto-merge
August 27, 2026 05:17
Contributor
Author
|
/ok to test 300c9c45b4ebf69d4e1a9dc8fe69449a82e94e7c |
# Conflicts: # megatron/training/arguments.py
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/33065907111 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds the mock SFT dataset (with a generalized SFT padding divisor) and the varlen dataset family (
VarlenLowLevelDataset,VarlenDataset,MockVarlenDataset) with unit tests. The datasets are inert until the follow-up training-integration PR wires them into pretraining.Part of the #3386 split series tracked in the Dynamic Context Parallelism project. Original changes by @xiaoyao0115 in #3386.
Series status
Remaining PRs of the #3386 split, tracked in the Dynamic Context Parallelism project. All PRs target
main— no stacked bases. Reviews run in parallel; merges go in order:pretrain_gpt+pretrain_hybrid)#6734 carries a temporary copy of #5902's commit, and #6742 carries #6734's commits (review its last three commits) — the duplicates drop out automatically as parents merge and the branches are rebased.
Merged so far: #5901, #5903, #6625, #5908, #6684, #5902.
Contribution process