fix(sp): preserve packed boundaries when padding auxiliary fields - #10180
Open
Excelius-Wang wants to merge 1 commit into
Open
Excelius-Wang wants to merge 1 commit into
Excelius-Wang wants to merge 1 commit into
Conversation
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.
PR type
PR information
Packed ring parallelism pads each sequence independently. Padding an earlier sequence shifts the boundaries of subsequent sequences.
extra_split_valuescurrently use the already-padded position IDs to pad tensors that still have their original lengths. With packed lengths[3, 5]and two ring ranks, this produces a four-position visual mask for six-position local embeddings, causingpad_and_split_mm_tokensto raise anIndexErrorin Qwen deepstack processing.Pad auxiliary fields using the original sequence boundaries before padding the position IDs. Add CPU regressions for packed and single sequences, single-token samples, pure Ulysses, ring and combined parallel layouts, visual embedding gradients, and the Qwen deepstack caller after the input-splitting hook.
Experiment results
python -m pytest tests/sequence_parallel/test_input_alignment.py tests/sequence_parallel/test_zigzag_ring_attn.py -q: 114 passed, 4 CUDA tests skipped.[26, 33]. All 4 RP=2/SP=2 and all 16 RP=2/SP=8 simulated ranks fail on the upstream method and pass forward/backward after the fix. The latter model keeps the official 16 attention heads and 8 KV heads. An aligned-prefix[24, 33]control passes before and after.pre-commit run --all-filesandgit diff --cached --checkpassed.Validation uses PyTorch 2.9.1 and Transformers 5.12.1 on CPU. The additional probes are local harnesses outside this diff. Rank selection is simulated, and the reduced-model probe uses local SDPA, not distributed attention; it validates reachability and tensor alignment, not distributed numerical equivalence. No GPU collectives or full-size pretrained training were run.