Skip to content

Use native block tables for 128-token XQA pages - #32127

Merged
Baiju Meswani (baijumeswani) merged 1 commit into
mainfrom
baijumeswani/xqa-native-page-table
Aug 17, 2026
Merged

Baiju Meswani (baijumeswani) merged 1 commit into
mainfrom
baijumeswani/xqa-native-page-table

Conversation

@baijumeswani

Copy link
Copy Markdown
Contributor

Avoid expanding the PagedAttention block table when its block size already matches XQA’s 128-token page size.

For 128-token blocks, the existing block table is passed directly to XQA. Larger block sizes continue using the existing expanded page-table path.

This removes an unnecessary temporary allocation and conversion kernel from each eligible XQA invocation.

Copilot AI left a comment

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.

Pull request overview

Optimizes CUDA PagedAttention by passing native 128-token block tables directly to XQA.

Changes:

  • Skips page-table allocation and expansion for 128-token blocks.
  • Adds debug telemetry distinguishing native and expanded paths.
  • Adds parity tests and documentation.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
onnxruntime/contrib_ops/cuda/bert/paged_attention.cc Conditionally allocates expansion scratch.
onnxruntime/contrib_ops/cuda/bert/paged_attention_impl.cu Passes native tables directly to XQA.
onnxruntime/contrib_ops/cuda/bert/attention_data.h Renames expansion scratch field.
onnxruntime/contrib_ops/cuda/bert/attention_kernel_options.h Adds page-table debug state.
onnxruntime/contrib_ops/cuda/bert/attention_kernel_options.cc Prints the selected table mode.
onnxruntime/test/python/transformers/test_paged_attention.py Tests native/expanded parity and dispatch.
docs/contrib_ops/cuda/paged_attention.md Documents the optimized path.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@tianleiwu Tianlei Wu (tianleiwu) left a comment

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.

LGTM

@baijumeswani
Baiju Meswani (baijumeswani) merged commit fab4691 into main Aug 17, 2026
89 checks passed
@baijumeswani
Baiju Meswani (baijumeswani) deleted the baijumeswani/xqa-native-page-table branch August 17, 2026 16:43
@baijumeswani

Copy link
Copy Markdown
Contributor Author

Thank you for the review.

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