Repository navigation
fix(qwen3vl): add the M-RoPE delta per row in a batched decode step - #269
Merged
Merged
Conversation
A cached decode step with batch size 2 or more added the delta of shape [batch] to positions of shape [batch, seqLength] on the last axis, and the broadcast failed. The delta now goes along the batch axis, as mlx-vlm qwen3_vl does with delta.reshape(-1, 1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
Merge-time synchronization: current main was merged normally into this branch at |
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.
Implementation
Fixes #266. Preparation only; no merge, deployment or downstream pin update.
Cached Qwen3-VL steps must add
[batch]M-RoPE deltas along the batch axis, not along the last position axis. Reshape the offset-plus-delta to[-1, 1]before addition. The original code could both trap on a nonsquare chunk and silently corrupt a square chunk when unequal row deltas were treated as column deltas.Merged main
3799b1150699e5595ae4c100a36b1a07cef3c44fwithout rebasing and preserved both fork-map topics. The actual stored-delta branch now uses a single internal pureQwen3VLLanguage.cachedPositionIdshelper, also used by permanent exact-position regressions. No public API, model-state test hook or reflection was added. The old kernel recording's batch-one comment is removed and its cache/full comparison now uses both token rows. All existing shape, dtype, finite, causality, batch-invariance and cache assertions remain.Before
After
Fresh Validation (2026-10-03)
swift build --build-tests -j 6: passes; all test targets compiled, not a full-suite execution.scripts/run-nested-suite.sh 'Qwen3VLBatchedDecodeTests|Qwen3VLForwardPassTests' --no-parallel: 23 tests pass, no skips, after the final candidate rebuild.positionResultprompts. Expected deltas are[-2,-3,-6]for images and[-2,-3,-9]for videos. Exact Int32 checks cover all three rotary axes at widthsbatch, 1 and 4, plus singleton-delta repetition. Text cached/full logits retain tolerance 1e-4 with chunks 5/3/1/1/1 at batch 1/2/3. Actual B=1 image/video prefill and cached/full-logit tests also ran.base + deltain the production-used helper, rebuilt, and ran the permanent test. Batch-2 square positions were[22,22,22,22]instead of[22,23,21,22]on each axis; the following width-1 case then exited with signal 5 on the broadcast. Restored the fix, rebuilt, and reran all 23 tests successfully. The baseline variant was never committed or pushed.git diff --checkandpython3 scripts/check_forkdiff.py: pass. Changed Swift files are formatted; the stricter localswift format lint --strictadditionally reports an unchanged pre-existingOnlyOneTrailingClosureArgumentdiagnostic at Qwen3VL.swift:188. Latest-head hosted Lint, Fork Diff Check and CodeQL have succeeded.0f4fe403/3fa8f25e/02cf6f4d/17c9c070).Scope And Gates
Multimodal prefill at B>1 remains explicitly unsupported by the baseline position builder. The unequal media-delta checks compose separately supported B=1 builder results to validate the cached arithmetic; they do not qualify a batched vision prefill path. CBv2 positioned-forward serving supplies its own position IDs and bypasses this legacy stored-delta calculation. No hosted checkpoint/provider qualification, production test or memory-policy change is claimed.
Base remains main; no dependency retarget is required. Related PR #267 has its own independent media/fork-map topic. Signed head
4870ac69a532bf9852bac261a4df7b86f104b0efis GitHub Verified. Latest-head Fork Tests are still running; that required CI gate must settle before readiness is claimed, and old red runs are not evidence about this head. No review findings have been posted at the latest refresh.Latest refresh at 2026-10-03 08:58 UTC: all PR-only commits are GitHub Verified (
valid), base main, MERGEABLE / UNSTABLE. Lint, Fork Diff Check and CodeQL succeeded; Fork Tests 37110757267 is still in progress. No reviews, comments or inline findings are posted. Both diagrams were verified as rendered GitHub Mermaid SVGs, without syntax errors. This is prepared but not yet CI-cleared for merge.Combined Integration Validation
On 2026-10-03, the current prepared heads of the twelve held PRs were composed
on a local-only validation branch based on main
3799b115, including thesigned-padding compatibility correction
96d5f976. No PR was merged.swift build --build-tests -j 4completed successfully.five optional fixture-dependent XCTest cases skipped. Advanced Arrays/Mamba
and nested signed-padding round trips passed in this composed build.
passed, with no failures or skips, covering paged backend, scheduler,
checkpoint engine, SSM bounds, Nemotron storage/priming, OpenAI service and
tool parser paths.
swift test --skip-build --filter ... --no-parallelunder the shared GPU mutex. This is focused integration validation, not a
full-package, real-weight or provider qualification. Exact compatible MLX
dependency tuple and immutable Metal artifact were verified before staging.
git diff --checkandpython3 scripts/check_forkdiff.pypassed.Existing assertions remain intact; this evidence does not waive required
latest-head CI, review, or parent-first retarget/revalidation gates.