Skip to content

[main] [1/5] Qwen3.5 support: MTP packed-seq CP+THD fix - #4752

Closed
wplf wants to merge 1 commit into
NVIDIA:mainfrom
wplf:fix/mtp-packed-seq-cp-padded-main
Closed

[main] [1/5] Qwen3.5 support: MTP packed-seq CP+THD fix#4752
wplf wants to merge 1 commit into
NVIDIA:mainfrom
wplf:fix/mtp-packed-seq-cp-padded-main

Conversation

@wplf

@wplf wplf commented May 12, 2026

Copy link
Copy Markdown
Contributor

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

  • In _roll_tensor_packed_seq, prefer packed_seq_params.cu_seqlens_q_padded when available, falling back to cu_seqlens_q.

Why

Under CP+THD, the per-sample CP partition produced by tex.thd_get_partitioned_indices slices on padded boundaries (each sample padded to a multiple of 2 * cp_size). Using the unpadded cu_seqlens_q to 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 main instead of dev).

🤖 Generated with Claude Code

@wplf wplf added the Run tests label May 12, 2026
@copy-pr-bot

copy-pr-bot Bot commented May 12, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

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
wplf force-pushed the fix/mtp-packed-seq-cp-padded-main branch from 518be21 to f9a99bd Compare May 13, 2026 10:24
@wplf wplf closed this May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant