## Fix GPTQ producing invalid QArray when subchannel quantization not specified#198
Merged
copybara-service[bot] merged 1 commit intomainfrom Jan 22, 2026
Merged
## Fix GPTQ producing invalid QArray when subchannel quantization not specified#198copybara-service[bot] merged 1 commit intomainfrom
copybara-service[bot] merged 1 commit intomainfrom
Conversation
9b946ec to
04b2f75
Compare
04b2f75 to
2ddf53f
Compare
… specified ### Summary Fixes a bug where `gptq_core.quantize_weight` creates inadvertent subchannel quantization that can produce invalid QArrays, even when the user did not request subchannel quantization. ### Problem When subchannel quantization is not specified (`tiled_axes` is empty), `quantize_weight` defaults the groupsize to `rows`: ```python groupsize = how.tiled_axes.get(1, rows) ``` This causes scales to be computed every `rows` columns, creating `ceil(columns/rows)` scale groups. When `columns` is not evenly divisible by `rows`, this produces an invalid QArray because the resulting scale shape violates the QArray contract (`all(qvalue_dim % scale_dim == 0 for each axis)`) When subchannel quantization is not specified, the scale should have shape `(rows, 1)` (per-channel quantization), not `(rows, num_groups)` (sub-channel). ### Solution This change modifies the default groupsize from `rows` to `columns`: ```python groupsize = how.tiled_axes.get(1, columns) ``` This ensures: - If subchannel is specified: use the user's groupsize - If subchannel is not specified: use `columns` as groupsize, producing per-channel quantization with `scale.shape = (rows, 1)` PiperOrigin-RevId: 859455381
2ddf53f to
0684523
Compare
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.
Fix GPTQ producing invalid QArray when subchannel quantization not specified
Summary
Fixes a bug where
gptq_core.quantize_weightcreates inadvertent subchannel quantization that can produce invalid QArrays, even when the user did not request subchannel quantization.Problem
When subchannel quantization is not specified (
tiled_axesis empty),quantize_weightdefaults the groupsize torows:This causes scales to be computed every
rowscolumns, creatingceil(columns/rows)scale groups. Whencolumnsis not evenly divisible byrows, this produces an invalid QArray because the resulting scale shape violates the QArray contract (all(qvalue_dim % scale_dim == 0 for each axis))When subchannel quantization is not specified, the scale should have shape
(rows, 1)(per-channel quantization), not(rows, num_groups)(sub-channel).Solution
This change modifies the default groupsize from
rowstocolumns:This ensures:
columnsas groupsize, producing per-channel quantization withscale.shape = (rows, 1)