Skip to content

Optimize GDN state updates for decode - #1429

Merged
Rishin Raj (quic-rishinr) merged 2 commits into
qualcomm:release/v1.23.0from
quic-mkshirsa:fix/qwen3-5-moe-bsz1-decode-state-update
Oct 13, 2026
Merged

Rishin Raj (quic-rishinr) merged 2 commits into
qualcomm:release/v1.23.0from
quic-mkshirsa:fix/qwen3-5-moe-bsz1-decode-state-update

Conversation

@quic-mkshirsa

@quic-mkshirsa quic-mkshirsa commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Generalizes Qwen3.5-MoE GDN retained-state updates to support full-batch kv_headpar decode for batch sizes 1, 2, 4, 8, and larger.

Problem

For kv_headpar decode, the compute batch covers the complete KV-cache batch. The gather/scatter operations are therefore unnecessary and cause compilation failures
for BS2 and BS4.

Solution

  • Reorder full-batch inputs into physical cache-slot order once at the decoder boundary.
  • Clear batch_index before cache updates so every layer replaces its complete retained state directly.
  • Restore final outputs to logical request order.
  • Preserve the existing gather/scatter path when the compute batch covers only part of the cache.
  • Permit full-state decode when full_batch_size == kv_cache_batch_size.
  • Update ONNX dynamic axes and dummy inputs for full-batch export.
  • Preserve existing singleton prefill and kv_batch_fold behavior.

Validation

  • Verified full-state and routed-state parity for decode BS1, BS2, and BS4 with permuted batch_index.
  • Verified full-state compile modes for BS1, BS2, BS4, and BS8.
  • Verified partial-batch updates preserve inactive cache rows.
  • Verified prefill and decode ONNX Runtime parity.
  • Verified exported full-state graphs contain no retained-state CB gather/scatter operations.
  • 18 targeted tests passed.
  • 33 broader Qwen3.5 tests passed.

@quic-mkshirsa
quic-mkshirsa marked this pull request as ready for review October 9, 2026 19:03
@quic-mkshirsa
quic-mkshirsa force-pushed the fix/qwen3-5-moe-bsz1-decode-state-update branch from b7ce44c to 7170ef3 Compare October 9, 2026 19:18
Reorder full-batch inputs into physical cache-slot order once at the decoder boundary and restore logical output order afterward.

Signed-off-by: Mrunal Kshirsagar <mkshirsa@qti.qualcomm.com>
@quic-mkshirsa
quic-mkshirsa force-pushed the fix/qwen3-5-moe-bsz1-decode-state-update branch from 7170ef3 to bd914d1 Compare October 9, 2026 20:18
@quic-mkshirsa quic-mkshirsa changed the title Optimize GDN state updates for singleton decode Optimize GDN state updates for decode Oct 9, 2026
@quic-rishinr

Copy link
Copy Markdown
Contributor

Please add a reproducer config test for this issue, use qwen3.6 dummy random model for the test

Signed-off-by: vbaddi <vbaddi@qti.qualcomm.com>
@vbaddi

Copy link
Copy Markdown
Contributor

CI-Ready

@quic-mkshirsa
quic-mkshirsa force-pushed the fix/qwen3-5-moe-bsz1-decode-state-update branch from 6ef0a56 to 92ec9a3 Compare October 13, 2026 14:59
@quic-rishinr
Rishin Raj (quic-rishinr) merged commit dfc9156 into qualcomm:release/v1.23.0 Oct 13, 2026
19 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