Repository navigation
fix(qwen3.8): allow sequence-boundary shape specialization - #4028
Merged
Merged
Conversation
hubert-marek
marked this pull request as ready for review
October 11, 2026 18:52
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
hubert-marek
force-pushed
the
fix/qwen38-optional-dynamic-sequences
branch
from
October 15, 2026 11:11
afcb32d to
13beb48
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.
Compiled Qwen 3.8 training fails on a single packed sequence with
ConstraintViolationError: the ngram/position-learning path specializescu_seqlensto length 2, butmark_dynamicforbids that specialization.Use
maybe_mark_dynamicfor this dimension so Dynamo can specialize the single-sequence case while attempting dynamic shapes for other packed-sequence counts. Shape guards remain active. This changes only Qwen 3.8; it does not change embedding sharding, model math, or other architectures.Targets
main, which already contains the affected text-model path. Multimodal support in #3916 is independent of this fix.Validation on an H200 compute allocation with PyTorch
2.13.0+cu130:ConstraintViolationErrorin the real ngram module.rtol=2e-4, atol=2e-5.git diff --checkpass.The isolated probe uses small real PLE/ngram modules, not the full distributed model. These checks do not establish a successful full-model distributed compiled update.
Note
Low Risk
Single-line Dynamo annotation change in one model; validated for numerical parity across packed-sequence shapes without altering training math.
Overview
Fixes compiled Qwen 3.8 training when a batch is a single packed sequence: Torch Dynamo was hitting
ConstraintViolationErrorbecause the PLE/ngram path specializescu_seqlenslength (e.g. to 2) whilemark_dynamicblocked that specialization.In
Qwen3_8FlashNextTextModel.forward,cu_seqlensdim 0 is annotated withtorch._dynamo.maybe_mark_dynamicinstead ofmark_dynamic, so Dynamo can specialize the one-sequence case while still treating other packed-sequence counts as dynamic. Scope is Qwen 3.8 Flash Next only; model math, sharding, and other architectures are unchanged.Reviewed by Cursor Bugbot for commit afcb32d. Bugbot is set up for automated code reviews on this repo. Configure here.