[codex] Preserve real and padded THD sequence lengths - #5541
Conversation
12a33d8 to
e740e93
Compare
|
Suggestion: replace pad_packed_seq_by_appending_dummy_seq: bool with an explicit tail-policy enum: This avoids silently changing the meaning of the existing boolean option and makes the trade-offs explicit |
e740e93 to
d314db2
Compare
|
/ok to test d314db2 |
d314db2 to
101e3d4
Compare
|
/ok to test 101e3d4 |
101e3d4 to
641e942
Compare
61103e4 to
13ecbe2
Compare
|
/ok to test 13ecbe2 |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
|
/ok to test 05e6f6d |
|
/ok to test 93daff4 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/30519040434 |
Signed-off-by: Tailai Ma <58548582+xiaoyao0115@users.noreply.github.com>
|
/ok to test b4b68ba |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/30526345696 |
What does this PR do?
This PR fixes THD tail-padding metadata in two cases:
cu_seqlensunchanged and extendscu_seqlens_padded[-1]to the actual padded tensor size.For non-dummy padding, tensors are padded before context-parallel slicing to ensure the correct token distribution.
The default dummy-sequence behavior remains unchanged.
Why?
Using physical padded boundaries as valid-token boundaries makes padding appear to be real data and prevents Transformer Engine from inferring gaps between sequences correctly.
Impact
THD attention still receives physical storage boundaries, while routing and loss paths retain the real token boundaries. The default dummy-sequence behavior remains unchanged. The
extend_lastpolicy is opt-in.The sequence-packing test now validates deterministic metadata locally on every rank and checks padding presence across the CP group. This avoids incorrectly comparing independent DP replicas or requiring every CP slice to contain padding.
Validation
BASE_REF=dev CHECK_ONLY=true SKIP_DOCS=true bash tools/autoformat.shtests/unit_tests/test_sequence_packing.py: 29 passedtests/unit_tests/transformer/test_thd_cuda_graph.py: 28 passed, 2 skipped pending the required TE changetests/unit_tests/transformer/moe/test_token_dispatcher.py: 19 passed, 92 skipped by configuration