Skip to content

[https://nvbugs/6395830][fix] Qwen-VL mRoPE: move seq-slot delta cach…#16537

Open
nv-guomingz wants to merge 1 commit into
NVIDIA:mainfrom
nv-guomingz:user/guomingz/fix_nvbug_6395830
Open

[https://nvbugs/6395830][fix] Qwen-VL mRoPE: move seq-slot delta cach…#16537
nv-guomingz wants to merge 1 commit into
NVIDIA:mainfrom
nv-guomingz:user/guomingz/fix_nvbug_6395830

Conversation

@nv-guomingz

@nv-guomingz nv-guomingz commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

…e update to model device

Text-only startup of the Qwen3.6-27B dense VL checkpoint crashes during KV-cache capacity estimation in the shared Qwen-VL mRoPE path (_prepare_qwen_vl_mrope_config):

mrope_position_deltas_cache.index_copy_(0, seq_slots, deltas)
RuntimeError: Expected all tensors to be on the same device, but got
source is on cpu, different from other tensors on cuda:0

Root cause: checkpoints carrying language_model_only: false with the dense Qwen3_5ForConditionalGeneration arch are routed to QwenImageBenchModel, whose multimodal_data_device_paths was missing the mrope_config.mrope_position_ids / mrope_config.mrope_position_deltas entries that its sibling _Qwen3_5VLModel lists. The engine's H2D move (MultimodalParams.to_device with target_keywords) therefore skips the mRoPE tensors, leaving the deltas CPU-resident when the GPU seq-slot cache write (introduced in #11943) consumes them. MoE VL checkpoints (Qwen3_5MoeForConditionalGeneration) never match the image-bench route and are unaffected.

Fix both layers:

  • QwenImageBenchModel.multimodal_data_device_paths: add the two mrope_config.* entries, matching _Qwen3_5VLModel, so mRoPE tensors ride the engine's pinned async H2D move like every other Qwen-VL model.
  • _prepare_qwen_vl_mrope_config: normalize deltas onto the cache device before index_copy_ as a defensive backstop for any path that still reaches the write branch with CPU tensors (no-op when devices already match).

Summary by CodeRabbit

  • Bug Fixes
    • Improved device handling for multimodal position data during processing.
    • Enhanced reliability of multimodal cache updates by ensuring related data is transferred consistently to the required device.

Description

Test Coverage

PR Checklist

Please review the following before submitting your PR:

  • PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.

  • PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.

  • Test cases are provided for new code paths (see test instructions)

  • If PR introduces API changes, an appropriate PR label is added - either api-compatible or api-breaking. For api-breaking, include BREAKING in the PR title.

  • Any new dependencies have been scanned for license and vulnerabilities

  • CODEOWNERS updated if ownership changes

  • Documentation updated as needed

  • Update tava architecture diagram if there is a significant design change in PR.

  • The reviewers assigned automatically/manually are appropriate for the PR.

  • Please check this after reviewing the above items as appropriate for this PR.

GitHub Bot Help

To see a list of available CI bot commands, please comment /bot help.

…e update to model device

Text-only startup of the Qwen3.6-27B dense VL checkpoint crashes during
KV-cache capacity estimation in the shared Qwen-VL mRoPE path
(`_prepare_qwen_vl_mrope_config`):

    mrope_position_deltas_cache.index_copy_(0, seq_slots, deltas)
    RuntimeError: Expected all tensors to be on the same device, but got
    source is on cpu, different from other tensors on cuda:0

Root cause: checkpoints carrying `language_model_only: false` with the
dense `Qwen3_5ForConditionalGeneration` arch are routed to
`QwenImageBenchModel`, whose `multimodal_data_device_paths` was missing
the `mrope_config.mrope_position_ids` / `mrope_config.mrope_position_deltas`
entries that its sibling `_Qwen3_5VLModel` lists. The engine's H2D move
(`MultimodalParams.to_device` with `target_keywords`) therefore skips the
mRoPE tensors, leaving the deltas CPU-resident when the GPU seq-slot cache
write (introduced in NVIDIA#11943) consumes them. MoE VL checkpoints
(`Qwen3_5MoeForConditionalGeneration`) never match the image-bench route
and are unaffected.

Fix both layers:
- `QwenImageBenchModel.multimodal_data_device_paths`: add the two
  `mrope_config.*` entries, matching `_Qwen3_5VLModel`, so mRoPE tensors
  ride the engine's pinned async H2D move like every other Qwen-VL model.
- `_prepare_qwen_vl_mrope_config`: normalize `deltas` onto the cache
  device before `index_copy_` as a defensive backstop for any path that
  still reaches the write branch with CPU tensors (no-op when devices
  already match).

Signed-off-by: nv-guomingz <137257613+nv-guomingz@users.noreply.github.com>
@nv-guomingz
nv-guomingz requested a review from a team as a code owner July 17, 2026 08:06
@nv-guomingz
nv-guomingz requested a review from aswinvisva July 17, 2026 08:06
@nv-guomingz

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: bc005a33-e523-4f34-91d5-9ea45d9bcf46

📥 Commits

Reviewing files that changed from the base of the PR and between ed1a0b9 and 425e1a2.

📒 Files selected for processing (2)
  • tensorrt_llm/_torch/models/modeling_qwen2vl.py
  • tensorrt_llm/_torch/models/modeling_qwen_image_bench.py

📝 Walkthrough

Walkthrough

The changes track Qwen mRoPE position data for multimodal device movement and align concatenated mRoPE deltas with the seq-slot cache device before index_copy_.

Changes

Qwen mRoPE device alignment

Layer / File(s) Summary
Track multimodal mRoPE tensors
tensorrt_llm/_torch/models/modeling_qwen_image_bench.py
multimodal_data_device_paths now includes mrope_position_ids and mrope_position_deltas for H2D movement.
Align seq-slot delta cache updates
tensorrt_llm/_torch/models/modeling_qwen2vl.py
Concatenated mRoPE deltas are moved to mrope_position_deltas_cache.device with non-blocking transfer before index_copy_.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: aswinvisva

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the fix, includes the NVBugs ticket and type, and clearly summarizes the mRoPE device-placement bug.
Description check ✅ Passed The description explains the crash, root cause, and fix, though the Test Coverage section is not filled in.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #59937 [ run ] triggered by Bot. Commit: 425e1a2 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #59937 [ run ] completed with state FAILURE. Commit: 425e1a2
/LLM/main/L0_MergeRequest_PR pipeline #48338 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants