Skip to content

Fix CUDA GatherBlockQuantized block indexing - #32665

Open
Tianlei Wu (tianleiwu) with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-gatherblockquantized-cuda-kernel
Open

Tianlei Wu (tianleiwu) with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-gatherblockquantized-cuda-kernel

Conversation

Copilot AI commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Description

  • Compute block IDs per quantized-axis row:
    block_id = row * blocks_per_row + column / block_size;
  • Add CUDA regression coverage for a 4-bit, non-block-aligned quantized axis.

Motivation and Context

CUDA previously derived the scale and zero-point block from the flat data index. Non-block-aligned quantized axes therefore crossed row boundaries and silently produced incorrect results.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Co-authored-by: tianleiwu <30328909+tianleiwu@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix GatherBlockQuantized CUDA kernel block ID calculation Fix CUDA GatherBlockQuantized block indexing Sep 17, 2026
@tianleiwu
Tianlei Wu (tianleiwu) requested a balanced review from Copilot September 17, 2026 08:35

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.

🟡 Changes recommended

Packed zero-point indexing remains incorrect for rows with a non-pack-aligned block count, and the CUDA test can silently run on CPU.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Fixes CUDA block indexing for non-aligned quantized-axis rows and adds regression coverage.

Changes:

  • Computes scale block IDs per quantized-axis row.
  • Passes the unpacked quantized-axis dimension to the CUDA kernel.
  • Adds a 4-bit CUDA regression test.
File summaries
File Description
gather_block_quantized.cc Supplies the logical quantized-axis dimension.
gather_block_quantized.cu Corrects row-aware block indexing.
gather_block_quantized.cuh Updates CUDA kernel parameters.
gather_block_quantized_op_test.cc Adds non-aligned-axis coverage.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread onnxruntime/contrib_ops/cuda/quantization/gather_block_quantized.cu Outdated
Comment thread onnxruntime/test/contrib_ops/gather_block_quantized_op_test.cc Outdated
Co-authored-by: tianleiwu <30328909+tianleiwu@users.noreply.github.com>
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.

GatherBlockQuantized CUDA kernel uses the flat index for the block id, giving wrong results when the quantized axis is not a multiple of block_size

4 participants