Repository navigation
fix(awq): pick a device-capable AWQ GEMM pack kernel off CUDA - #3271
Merged
Merged
Conversation
Data-driven AWQ quantization with `format=FORMAT.GEMM` and the default
`backend=BACKEND.AUTO` aborted on ROCm/gfx950:
ValueError: AWQ: failed to build torch.ops JIT extension: ...
`GPTQModel.quantize()` hard-coded `BACKEND.AWQ_GEMM` for the GEMM export
lifecycle, and `AwqGEMMLinear` needs the native AWQ extension, whose sources
include `cusparse.h` and CUDA-only inline asm. That extension never builds
on ROCm, so the run died after a wasted ~7s compile attempt.
Route the choice through a new `awq_gemm_pack_backend()` helper: keep the
native kernel on real CUDA devices, and pack with the portable torch kernel
everywhere else (ROCm/XPU/NPU/CPU) plus for weight-only exports. The
portable kernel emits the identical AWQ GEMM layout for in-range codes, and
the loader already selects `AWQ_TORCH` for AWQ checkpoints, so the exported
weights stay interoperable.
`AwqGEMMLinear.validate_once()` now reports the ROCm gap with an actionable
message instead of triggering a doomed JIT build.
Validated on MI355X (gfx950): `method=AWQ, format=GEMM, backend=AUTO` now
quantizes end-to-end (4.0s on the tiny qwen2 fixture, was a hard failure);
the packing kernel is selected as `AwqTorchLinear`.
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.
Problem
Data-driven AWQ quantization with
format=FORMAT.GEMMand the defaultbackend=BACKEND.AUTOaborts on ROCm/gfx950:GPTQModel.quantize()hard-codedBACKEND.AWQ_GEMMfor the GEMM export lifecycle, andAwqGEMMLinearrequires the native AWQ extension whose sources includecusparse.hand CUDA-only inline asm (nv_bfloat16,"l"/"=f"asm constraints, 32-bit__shfl_down_syncmasks). That extension never builds on ROCm, so the run died after a wasted ~7s compile attempt.Fix
Route the choice through a new
awq_gemm_pack_backend()helper:AWQ_GEMMkernel;AWQ_TORCH).The portable kernel emits the identical AWQ GEMM layout for in-range codes, and the loader already selects
AWQ_TORCHfor AWQ checkpoints (gptqmodel/models/auto.py), so exported weights stay interoperable.AwqGEMMLinear.validate_once()now reports the ROCm gap with an actionable message instead of triggering a doomed JIT build.Validation (MI355X / gfx950)
method=AWQ, format=GEMM, backend=AUTOnow quantizes end-to-end:OK quantize 4.01son the tiny qwen2 fixture (previously a hard failure); packing kernel selected asAwqTorchLinear.tests/test_awq_cuda_contract.py: portable-backend selection matrix, CUDA-only device contract, and the ROCmvalidate_once()message.pytest -q tests/test_backend_naming.py tests/test_weight_only_config.py tests/test_awq_cuda_contract.py→ 45 passed, 2 skipped.