Skip to content

[NPU] Enable Qwen3-VL GRPO (single- & multi-turn) on Ascend#314

Merged
CalvinXKY merged 7 commits into
vllm-project:ascendfrom
Meihan-chen:feat/qwen3_vlm
Jul 17, 2026
Merged

[NPU] Enable Qwen3-VL GRPO (single- & multi-turn) on Ascend#314
CalvinXKY merged 7 commits into
vllm-project:ascendfrom
Meihan-chen:feat/qwen3_vlm

Conversation

@Meihan-chen

@Meihan-chen Meihan-chen commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

Brings up Qwen3-VL-8B-Instruct GRPO on Ascend NPU for both the single-turn (examples/geo3k_vlm) and multi-turn (examples/geo3k_vlm_multi_turn) examples, on vllm-ascend rollout + Megatron-Bridge/MindSpeed training.

Base VLM fixes (apply to both single- & multi-turn)

  • Weight load: register MindSpeedTEColumnParallelLinear in Bridge AutoMapping (megatron-bridge.patch).
  • Forward — nvtx: replace raw torch.cuda.nvtx.* with megatron.core.utils.nvtx_range_* (no CUDA NVTX on NPU) (megatron-bridge.patch).
  • Forward — THD mrope: preprocess_packed_seqs integer-indexed an int32 mask → mrope positions collapse (ppl ~13000, abs_diff ≈ 9); build the mask as bool (megatron-bridge.patch).
  • Vision attention: MindSpeed varlen kernel forced a causal mask despite attn_mask_type=no_mask, breaking the bidirectional vision tower (image abs_diff ≈ 0.8); honor no_mask (mindspeed.patch).
  • Weight sync: packed_broadcast_producer read source tensors on the packing stream before the caller stream finished; add wait_stream(source_stream) (vllm-ascend.patch).

Multi-turn fixes

  • Prefix-stability / token desync: re-rendering the whole conversation each turn triggers a tokenizer BPE re-merge at the assistant\n seam, shifting the token stream away from what vLLM actually generated. Fixed by aligning rollout.py to upstream [Bugfix][Rollout] Fix Geo3K VLM multi-turn rollout #341 — render once + observation-suffix delta.
  • The rewritten rollout imports only helpers already present on the ascend branch (GenerateState, _build_inference_sampling_params, _coerce_flat_int_token_ids, _mm_render_response_to_generate_body) and inlines response/routing parsing (_parse_choice, _decode_routing_metadata), so it no longer depends on the vime-only helpers and vime/rollout/vllm_rollout.py is untouched.

@gemini-code-assist

Copy link
Copy Markdown

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@Meihan-chen

Meihan-chen commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator Author

Qwen3-VL-8B-Instruct-multi-turn-NPU
image

Qwen3-VL-8B-Instruct-multi-turn-GPU
image

Signed-off-by: Meihan-chen <zr010426ztt@outlook.com>
Signed-off-by: Meihan-chen <zr010426ztt@outlook.com>
Signed-off-by: Meihan-chen <zr010426ztt@outlook.com>
Signed-off-by: Meihan-chen <zr010426ztt@outlook.com>
@Meihan-chen

Meihan-chen commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator Author

Qwen3-VL-8B-Instruct-single-turn vs multi-turn
image

@floatlibai

Copy link
Copy Markdown
Contributor

The main branch seems to have a refactor #341 , maybe you can have a look.

Comment thread docker/npu_patch/mindspeed.patch Outdated
- if packed_seq_params is not None
- else {}
- )
+ attention_mask = torch.triu(

@floatlibai floatlibai Jul 16, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This attention_mask line can be removed.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks,done

Signed-off-by: Meihan-chen <zr010426ztt@outlook.com>
Signed-off-by: Meihan-chen <zr010426ztt@outlook.com>
@Meihan-chen
Meihan-chen marked this pull request as ready for review July 16, 2026 09:40
@Meihan-chen

Meihan-chen commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator Author

The main branch seems to have a refactor #341 , maybe you can have a look.

#341 fixes the same two multi-turn issues as our earlier in-house patch, using the same approach — render once, keep the generated token ids as the canonical history, and append only the observation suffix delta between turns.

The only difference was code structure (our hand-rolled generate() vs upstream’s _Geo3kRollout class). This PR adopts #341 verbatim so the file matches upstream, with a single required shim: this Ascend branch’s Sample has no append_response_tokens(), so _Geo3kRollout._append_response() maintains tokens/loss_mask/rollout_log_probs/response_length directly. diff vs upstream = only that method + its 3 call-sites.

Signed-off-by: Meihan-chen <zr010426ztt@outlook.com>

@CalvinXKY CalvinXKY left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Nit: PR description is slightly stale — it still says we restore 3 helpers in vime/rollout/vllm_rollout.py deleted by #178, but this diff does not touch that file. The multi-turn rollout now imports fewer helpers (_coerce_flat_int_token_ids / _mm_render_response_to_generate_body already present on ascend) and aligns with the #341 “render once + observation suffix” approach. Worth updating the “Multi-turn fixes” section so it matches the final code.

@Meihan-chen

Meihan-chen commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator Author

LGTM. Nit: PR description is slightly stale — it still says we restore 3 helpers in vime/rollout/vllm_rollout.py deleted by #178, but this diff does not touch that file. The multi-turn rollout now imports fewer helpers (_coerce_flat_int_token_ids / _mm_render_response_to_generate_body already present on ascend) and aligns with the #341 “render once + observation suffix” approach. Worth updating the “Multi-turn fixes” section so it matches the final code.LGTM。

Good catch — updated. Reworded the alignment note accordingly.

@CalvinXKY
CalvinXKY merged commit fde9f6f into vllm-project:ascend Jul 17, 2026
4 checks passed
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.

3 participants