feat(moe): NSP-blocked expert dispatch for Qwen3MOE and GPT-OSS prefill#935
Open
vbaddi wants to merge 13 commits into
Open
feat(moe): NSP-blocked expert dispatch for Qwen3MOE and GPT-OSS prefill#935vbaddi wants to merge 13 commits into
vbaddi wants to merge 13 commits into
Conversation
ochougul
reviewed
Apr 23, 2026
Add expert-blocked NSP-parallel prefill forward to QEffPrefillChunkedQwen3MoeSparseMoeBlock and QEffPrefillOnlyChunkedGptOssMLP. Controlled via EXPERT_BLOCKING_NUM_NSP env var. Fix CtxScatterFunc3D/CtxGatherFunc3D eager forward for INT32_MAX sentinel handling. Add disagg-mode tests for both models with tiny configs. Signed-off-by: vbaddi <vbaddi@qti.qualcomm.com>
Signed-off-by: vbaddi <vbaddi@qti.qualcomm.com>
Signed-off-by: vbaddi <vbaddi@qti.qualcomm.com>
Signed-off-by: vbaddi <vbaddi@qti.qualcomm.com>
Signed-off-by: vbaddi <vbaddi@qti.qualcomm.com>
…prefill Signed-off-by: vbaddi <vbaddi@qti.qualcomm.com>
a0fe82c to
6b049bc
Compare
Signed-off-by: vbaddi <vbaddi@qti.qualcomm.com>
- Root cause: CtxGather3D ONNX symbolic expanded ctx_indices to Shape(data)[:2] ([batch, seq_len]), which is wrong for packed dispatch.
- In expert-blocked MoE prefill, ctx_indices is intentionally [batch, packed_chunk_size] (e.g. [16, 256]) while data stays [batch, seq_len, ...] (e.g. [16, 512, ...]).
- This caused invalid Expand attempts ([16,256] -> [16,512]) and QAIC compile/runtime failure on /model/layers.0/mlp/CtxGather3D/....
Fix:
- Update CtxGather3D expand target to:
- batch dim from data
- index-seq dim from ctx_indices
- New expand shape is [batch_size(data), idx_seq_len(ctx_indices)], preserving packed chunk length.
Signed-off-by: vtirumal <vtirumal@qti.qualcomm.com>
…port Add missing CustomOpTransform mappings for CtxScatterFunc3DInt and generalized 3D scatter/gather ops, plus a prefill-only subfunction export regression test to verify the ONNX graph includes the required CtxScatter3DInt/CtxScatter3D/CtxGather3D ops. Signed-off-by: vbaddi <vbaddi@qti.qualcomm.com>
…on export Replace MoE prefill sum reductions with equivalent einsum forms and rewrite int32 clamp bounds using where to avoid QAIC subfunction compile failures for GPT-OSS and Qwen3-MoE. Signed-off-by: vbaddi <vbaddi@qti.qualcomm.com>
Trace chunked prefill exports with the requested prefill_seq_len so packed MoE dispatch unrolls all packed chunks, restore torch.full_like index init, and add ONNX coverage for the second packed chunk slice. Signed-off-by: vbaddi <vbaddi@qti.qualcomm.com>
Move MoE prefill blocking from env vars to compile/export API. Derive packed chunk iterations from compile prefill_seq_len while keeping ONNX export tracing small, and make the optimized GPT-OSS/Qwen3-MoE chunked forward path default. Update tests and examples for the new API. Signed-off-by: vbaddi <vbaddi@qti.qualcomm.com>
Use API-driven packed chunk config, align Qwen3/GPT-OSS MoE prefill scatter-gather flow with benchmark, and update disagg examples for PL512/packed256. Signed-off-by: vbaddi <vbaddi@qti.qualcomm.com>
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.
Adds NSP-parallel expert-blocked dispatch to the chunked prefill MoE path for Qwen3MOE and GPT-OSS, replacing the sequential per-expert loop with a batched packed-prefix approach.
Falls back to the original per-expert loop if
num_experts % EXPERT_BLOCKING_NUM_NSP !=0.EXPERT_BLOCKING_NUM_NSP=2 pytest tests/transformers/models/test_moe_prefill_blocked.py -vUpdate (0429):
export EXPERT_BLOCKING_PACKED_CHUNK_SIZE=256for chunk PL of 512Update (0525):
Configuration is now compile-API driven:
Example:
Notes:
Validation:
Also verified tiny non-subfunction QAIC compile for Qwen3-MoE and GPT-OSS with: