Repository navigation
Conversation
Reuse intentionally holds compressed state while speculative query positions advance. Rejecting any prefix older than the current query incorrectly disables otherwise valid MTP chains. Keep metadata bounds and reject future prefixes, using 64-bit length arithmetic. Files: onnxruntime/contrib_ops/cuda/sparse/packed_sparse_attention_indexer_impl.cu; onnxruntime/test/contrib_ops/packed_sparse_attention_indexer_op_test.cc. Verify the regression fails before the fix and passes afterward. Validate 24 ORT CUDA tests and all 114 GenAI Engine tests on A100 without skips; run existing lintrunner on Windows. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 71f338fc-57ae-4336-8b1a-1ccf6d2ff1f7
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The review reports no active issues for the CUDA QSA held-prefix reuse change.
No open issues 🎉
What changed in this PR
Fixes CUDA QSA IndexShare reuse so a captured compressed-state prefix remains valid as speculative query positions advance, supporting GenAI’s multi-token prediction flow.
Changes:
- Replaces exact state-position matching with a 64-bit check that the held prefix is not ahead of the query, preserving other validation and CSA behavior.
- Extends reuse regression coverage across query past lengths 5–8, including negative lengths, invalid buffer lengths, and future-state rejection.
| File | Description |
|---|---|
| onnxruntime/test/contrib_ops/packed_sparse_attention_indexer_op_test.cc | Expands held-prefix reuse and invalid-state test scenarios. |
| onnxruntime/contrib_ops/cuda/sparse/packed_sparse_attention_indexer_impl.cu | Allows older QSA prefixes while rejecting state ahead of the query. |
Review effort: Balanced
Read verification counters back on their CUDA stream and report through host stdout so Windows CI can capture both FC stages without relying on device printf. Keep strict zero-miss checks and refresh operator documentation from the failing CI artifact. Files changed: - onnxruntime/contrib_ops/cuda/moe/qmoe_int3_tc.cuh - onnxruntime/test/python/transformers/test_qmoe_shared_direct.py - docs/OperatorKernels.md Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9a5970c4-dcda-48fb-91b5-0d4e93005a46
This branch has not been deployed
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.
Description
Allow QSA IndexShare reuse to retain its captured compressed-state prefix while speculative query positions advance. Validate that the held prefix does not lie ahead of the current query, using 64-bit arithmetic, instead of requiring its key/buffer lengths to exactly describe the current query position.
All existing capacity, buffer geometry, negative-length, merged-count, cumulative-length, and status checks remain enforced. Refresh-mode validation and CSA behavior are unchanged.
Extend the existing CUDA regression across query past lengths 5-8 with the same held prefix and add negative/future-state cases. The former invalid case with an older prefix is legal in hold mode; replace its input with an out-of-range buffer length without weakening its rejection assertion.
Motivation and Context
Unblocks microsoft/onnxruntime-genai#2942. Matching the Python ORT binding and CUDA plugin to the native CI runtime exposed 14 IndexShare MTP failures previously hidden by missing schemas/kernels. After three failures, GenAI safely disables MTP and falls back to target-only decoding.
A standalone operator reproduction on A100 confirms the producer issue independently of GenAI: held state
[0,1]passes at query past length 1 but is rejected at past length 2, even thoughComputeReuseintentionally copies that state unchanged and performs no key projection.Validation
git diff --checkpass on Windows.CUDA execution was verified on an idle A100 (sm80), using an offline build with QUICK_BUILD enabled. Windows CUDA build/runtime verification remains for CI; no local Windows CUDA toolchain is available.