[main] [1/5] Qwen3.5 support: MTP packed-seq CP+THD fix - #4752
Closed
wplf wants to merge 1 commit into
Closed
Conversation
This was referenced May 12, 2026
This was referenced May 12, 2026
In `_roll_tensor_packed_seq`, use `packed_seq_params.cu_seqlens_q_padded` when available so per-sample boundaries on each CP rank match the partition produced by `tex.thd_get_partitioned_indices`, which slices on padded boundaries. Falls back to `cu_seqlens_q` to preserve behavior for callers that don't pad to a multiple of `2 * cp_size`. Padding tokens carry `loss_mask=0` / `label=-100`, so rolling them is a no-op for the loss. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-Authored-By: BestJuly <19769279+BestJuly@users.noreply.github.com>
wplf
force-pushed
the
fix/mtp-packed-seq-cp-padded-main
branch
from
May 13, 2026 10:24
518be21 to
f9a99bd
Compare
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.
Superseded
This PR is superseded by #4495, which lands the same MTP CP+THD fix.
Closing once the replacement merges.
Qwen3.5 support series
This is part of a 5-PR series adding Qwen3.5-VL support, split for review clarity.
Main PRs (this series):
Dev PRs (corresponding mirrors):
Summary
_roll_tensor_packed_seq, preferpacked_seq_params.cu_seqlens_q_paddedwhen available, falling back tocu_seqlens_q.Why
Under CP+THD, the per-sample CP partition produced by
tex.thd_get_partitioned_indicesslices on padded boundaries (each sample padded to a multiple of2 * cp_size). Using the unpaddedcu_seqlens_qto roll the MTP target on each rank therefore misaligns boundaries and shifts tokens across sample edges on some ranks.Padding tokens carry
loss_mask=0/label=-100, so rolling across them is a no-op for the loss but unaligned rolling on unpadded boundaries is not.The fallback preserves behavior for callers that don't pad to a multiple of
2 * cp_size.Notes
Mirror of #4747 (same patch, targeting
maininstead ofdev).🤖 Generated with Claude Code