Skip to content

feat(scripts): add Ultra script prerequisites - #4223

Merged
yaoyu-33 merged 3 commits into
mainfrom
chcui/ultra-script-prereqs
Jun 10, 2026
Merged

feat(scripts): add Ultra script prerequisites#4223
yaoyu-33 merged 3 commits into
mainfrom
chcui/ultra-script-prereqs

Conversation

@cuichenx

@cuichenx cuichenx commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • make pack_sft_data.py accept recipe-supported sequence length and HF path overrides
  • add explicit input/output packing paths for preprocessed packed-sequence data generation
  • make text-generation distributed initialization use safe rank/world/master defaults for Slurm/srun-native launches

Blast Radius / Test Assessment

  • Touches shared user-facing scripts used by conversion/training/inference workflows.
  • L0/unit-style static validation is sufficient for this script-only PR; no new functional CI labels are added.
  • Manual validation should include an srun-native inference launch and an SFT packing invocation through a model recipe.

Validation

  • uv run --no-sync pre-commit run --files scripts/training/pack_sft_data.py scripts/inference/text_generation.py
  • uv run --no-sync python -m py_compile scripts/training/pack_sft_data.py scripts/inference/text_generation.py

Signed-off-by: Chen Cui <chcui@nvidia.com>
Comment thread scripts/training/pack_sft_data.py Outdated
@claude

claude Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Light Code Review --- Bug in pack_sft_data.py: silent drop of --seq-length / --hf-path overrides (inline comment posted). When the user passes these flags but the recipe function does not accept them, the values are silently ignored. This should error or warn. --- text_generation.py: Distributed init changes look correct. --- Test coverage: Neither script has tests; the new argument-forwarding logic would benefit from unit tests. --- Suggested test cases: No perf tests impacted.

@yaoyu-33 yaoyu-33 added area:data Dataset builders, preprocessing, and samplers feature New capabilities, enhancements, or enablement work waiting-on-customer Waiting on the original author to respond labels Jun 9, 2026
Signed-off-by: Chen Cui <chcui@nvidia.com>
@cuichenx

cuichenx commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

/claude review

assert kwargs["output_metadata_path"] == metadata_output
assert kwargs["packed_sequence_size"] == 2048
assert kwargs["max_seq_length"] == 4096
assert kwargs["num_tokenizer_workers"] == 1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: _PackedSequenceSpecs defaults num_tokenizer_workers to -1, and the script passes it through unchanged to prepare_packed_sequence_data. This assertion will fail.

Suggested change
assert kwargs["num_tokenizer_workers"] == 1
assert kwargs["num_tokenizer_workers"] == -1

@cuichenx cuichenx Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the existing assertion is intentional here. The script sets cfg.dataset.packed_sequence_specs.num_tokenizer_workers = 1 before it calls prepare_packed_sequence_data(...) (see scripts/training/pack_sft_data.py around the worker cap), so the value forwarded to the packer should be 1 rather than the dataclass default -1. I reran the targeted test and it passes with the current assertion.

@claude

claude Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Light Code Review -- Bug: tests/unit_tests/scripts/test_pack_sft_data.py:220 -- The assertion num_tokenizer_workers == 1 will fail. The _PackedSequenceSpecs stub defaults num_tokenizer_workers to -1, and the script passes it through unchanged. The assertion should be == -1. -- Suggested test cases: test_pack_sft_data_packs_validation_split_when_both_paths_provided, test_pack_sft_data_rejects_val_input_without_val_output, test_pack_sft_data_falls_back_to_builder_pack_metadata, test_maybe_initialize_distributed_preserves_existing_env_vars. No perf tests impacted.

Signed-off-by: Chen Cui <chcui@nvidia.com>
@cuichenx

Copy link
Copy Markdown
Contributor Author

/ok to test f2f017c

@yaoyu-33
yaoyu-33 merged commit 1d0dab6 into main Jun 10, 2026
102 checks passed
@yaoyu-33
yaoyu-33 deleted the chcui/ultra-script-prereqs branch June 10, 2026 20:27
vasunvidia pushed a commit to vasunvidia/Megatron-Bridge that referenced this pull request Jun 10, 2026
Signed-off-by: Chen Cui <chcui@nvidia.com>
Signed-off-by: Vasudevan Rengasamy <vrengasamy@nvidia.com>
cuichenx added a commit that referenced this pull request Jun 23, 2026
Signed-off-by: Chen Cui <chcui@nvidia.com>
(cherry picked from commit 1d0dab6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:data Dataset builders, preprocessing, and samplers feature New capabilities, enhancements, or enablement work waiting-on-customer Waiting on the original author to respond

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants