Head parallel and batch fold blocking for Qwen3-VL MOE - #1229
Open
kdulla wants to merge 34 commits into
Open
Conversation
kdulla
marked this pull request as draft
July 31, 2026 12:28
ochougul
marked this pull request as ready for review
August 5, 2026 07:36
ochougul
marked this pull request as draft
August 5, 2026 07:39
kdulla
force-pushed
the
qwen3_vl_moe_kv_main
branch
2 times, most recently
from
August 6, 2026 06:40
fea1490 to
4f454a7
Compare
kdulla
marked this pull request as ready for review
August 6, 2026 07:31
Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com> Co-authored-by: Kushal Dulla <kdulla@qti.qualcomm.com> Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
## Summary of Changes
- Adds
examples/image_text_to_text/models/qwen3_vl_moe/qwen3_vl_moe_blocking_headpar_example.py,
a self-contained
end-to-end script that exercises three blocked-attention configurations
for the Qwen3-VL-MoE
- Added support in Qwen3VL-MOE forward to use prefill_blocked_interface
if requested by user.
## Blocking modes covered in example script
- --blocking-mode decode
Decode QPC: HQKV + kv_blocking_headpar_split=0
- --blocking-mode prefill_par
Decode QPC: HQKV
Prefill QPC: prefill_blocking_mode="qkv"
Description: Separate QPCs;
chunked-prefill + manual decode loop
- --blocking-mode prefill_online
Decode QPC: HQKV
Prefill QPC:
prefill_blocking_mode="online"
Description: Same as above with
online-softmax prefill
- --blocking-mode all
Decode QPC: —
Prefill QPC: —
Description: Runs all three back-to-back
## Usage
python
examples/image_text_to_text/models/qwen3_vl_moe/qwen3_vl_moe_blocking_headpar_example.py
--blocking-mode all
---------
Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
Updated qwen3vl moe disaggregated inference example script --------- Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
Signed-off-by: ochougul <ochougul@qti.qualcomm.com> Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
Updated missing write in prefill mode and changed an incorrect skip on min pos id instead of max. --------- Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
added batch fold decode attention forward and updated example scripts accordingly --------- Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com> Signed-off-by: kdulla <kdulla@qti.qualcomm.com> Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
Signed-off-by: ochougul <ochougul@qti.qualcomm.com> Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
Signed-off-by: ochougul <ochougul@qti.qualcomm.com> Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
Signed-off-by: ochougul <ochougul@qti.qualcomm.com> Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
…quic#1186) Identified incorrect implementation in read cache, updated cache layout and read calls accordingly, still has ongoing compilation bug. Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
Signed-off-by: ochougul <ochougul@qti.qualcomm.com> Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
Prefill and decode run for 1 iteration Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
…quic#1192) Adjusted prefill normalization and decode cache layout in example script --------- Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com> Signed-off-by: kdulla <kdulla@qti.qualcomm.com> Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
Added qwen3 moe optimizations to qwen3vl moe, and changed export BS to 2 if >1. Checked e2e run, able to run generation with the example script: `python examples/image_text_to_text/models/qwen3_vl_moe/qwen3_vl_disagg_mode.py` --------- Signed-off-by: vbaddi <vbaddi@qti.qualcomm.com> Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com> Co-authored-by: vbaddi <vbaddi@qti.qualcomm.com> Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
Added in progress changes for benchmark alignment, including updated CtxChunkScatter, reshape before custom op and introduction of kv unroll option Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
…16 (quic#1223) Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
Signed-off-by: Ann Kuruvilla <akuruvil@qti.qualcomm.com> Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
…locking tests to disagg infra Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
kdulla
force-pushed
the
qwen3_vl_moe_kv_main
branch
from
August 7, 2026 06:23
2f7d72b to
148366a
Compare
Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
ochougul
reviewed
Aug 7, 2026
| inputs[f"past_value.{i}"] = qpc_out[f"past_value.{i}_RetainedState"] | ||
| print(f"ttft={(time.time() - loop_start):.3f}") | ||
|
|
||
| exit(0) |
ochougul
reviewed
Aug 7, 2026
|
|
||
| all_outputs.append(np.argmax(decode_out["logits"])) | ||
| pos_id = np.max(decode_inputs["position_ids"], axis=-1, keepdims=True) + 1 | ||
| # exit(0) |
ochougul
reviewed
Aug 7, 2026
Comment on lines
+320
to
+322
| # for i in range(config.text_config.num_hidden_layers): | ||
| # loop_decode_inputs[f"past_key.{i}"] = decode_out[f"past_key.{i}_RetainedState"] | ||
| # loop_decode_inputs[f"past_value.{i}"] = decode_out[f"past_value.{i}_RetainedState"] |
ochougul
reviewed
Aug 7, 2026
Comment on lines
+330
to
+332
| # for j in range(config.text_config.num_hidden_layers): | ||
| # loop_decode_inputs[f"past_key.{j}"] = decode_out[f"past_key.{j}_RetainedState"] | ||
| # loop_decode_inputs[f"past_value.{j}"] = decode_out[f"past_value.{j}_RetainedState"] |
Contributor
Author
There was a problem hiding this comment.
Resolved, these were older experiments being done that were incorrectly pushed. Cleaned up example script code accordingly
Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
Signed-off-by: Kushal Dulla <kdulla@qti.qualcomm.com>
ochougul
reviewed
Aug 7, 2026
| BlockingMode, | ||
| generic_blocked_attention_interface, | ||
| past_key_value_update, | ||
| prefill_blocked_attention_interface, |
Contributor
There was a problem hiding this comment.
why are we introducing new interface ? can't it be handled within, we also did siimlar for latent attention?
ochougul
reviewed
Aug 7, 2026
Comment on lines
+159
to
+160
| # routing_weights = torch.zeros_like(router_logits) | ||
| # routing_weights.scatter_(1, top_i, top_w) |
ochougul
reviewed
Aug 7, 2026
Contributor
There was a problem hiding this comment.
Do we really need 3 example files, all of them can be like CLI options for one example file.
Contributor
There was a problem hiding this comment.
And default value is the one that is best performant.
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.
Overview
This PR adds support for new blocking modes, including head parallel blocking, prefill blocking, decode MOE blocking and batch-fold blocking. Head parallel blocking is introduced for causal models while the other approaches are introuced for Qwen3-VL MOE. Expert Parallelism is enabled via expert_parallel compile option while new flags in qaic_config can be passed for different attention blocking configurations. Additionally, this PR contains updated tests for the new blocking modes introduced.
Modes Added
Additionally, pre-existing KV blocking modes have been updated to correctly use ctx_len from compile_time for computing block sizes instead of past_seen-tokens.
Scripts
E2E run on Qwen3-VL moe with batch fold and prefill blocking can be ran via:
python examples/image_text_to_text/models/qwen3_vl_moe/qwen3_vl_disagg_mode.pyUnit tests on Qwen3-VL moe can be ran via:
pytest tests/transformers/models/image_text_to_text/test_qwen3_vl_moe_disagg_blocked.pyUnit tests for head parallel softmax on causal models added to tests/transformers/models/causal_lm_models/test_causal_lm_blocking_hqkv.py