Repository navigation
fix(awq,requantize): pick the AWQ packer by width and rehome packed payloads - #6143
Merged
Merged
Conversation
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.
Summary
Fixes #6135
Fixes #6132
#6135 — AWQ GEMM AUTO pack backend ignored the global width
awq_gemm_pack_backend()returnedBACKEND.AWQ_GEMMfor every CUDA run, so the model-wideselect_quant_linear(..., pack=True)gate validatedAwqGEMMLinear(4-bit only) forAWQConfig(bits=8)/AWQConfig(bits=3)and raised before calibration. The function now takesthe global width and returns
AWQ_TORCHfor non-4-bit GEMM;AWQ_GEMMis unchanged for 4-bitCUDA, and the ROCm/CPU/weight-only paths still return
AWQ_TORCH.#6132 —
requantize()placement snapshot saw the CPUqzeros_formatmarker_snapshot_module_placement()/_embedding_endpoint_state()usedget_device(module), whichreturns the first buffer. Every
BaseQuantLinearregisters the CPU-created persistentqzeros_formatmarker first, so a CUDA-residentTritonV2Linearwas recorded as CPU and thepost-run rehome left its packed payload on CPU (
Expected a cuda device, but got: cpu). Thesnapshot and rehome now use the real checkpoint payload device (first parameter, else first
non-marker buffer).
For the layer-wise dispatch case,
StageInputsCapturenow materializes a module on its residentaccelerate hook's execution device instead of forcing CPU, so the hook no longer moves inputs to
one device while the weight sits on another. Offload hooks are left untouched.
What Changed
gptqmodel/utils/backend.py:awq_gemm_pack_backend(..., bits)selectsAWQ_TORCHfor 2/3/8-bit GEMM.gptqmodel/models/base.py: passruntime_bitsto the pack-backend resolver; add_module_payload_device()and use it for the requantize placement snapshot/rehome.gptqmodel/looper/stage_inputs_capture.py: honor resident accelerate dispatch hook executiondevices when materializing capture layers and base modules.
tests/test_awq_cuda_contract.pyandtests/test_requant_embed_endpoint_5116.py.Tests
All commands run with
CUDA_VISIBLE_DEVICES=1andPYTHONPATH=<clone>:<clone>/testsfrom<clone>/tests:Red evidence at base
43b999585test_awq_cuda_contract.py::test_awq_gemm_non_4bit_global_width_quantizes_with_default_backend[8]fails with:
ValueError: <class 'gptqmodel.nn_modules.qlinear.gemm_awq.AwqGEMMLinear'> only supports [4] bits: actual bits = 8test_requantize_default_loaded_checkpoint_runs_in_session[output]fails at the payload-deviceassertion after
requantize(): everyq_projbuffer is still CPU.The same script's in-session
generate()raisedValueError: Expected a cuda device, but got: cpu.test_requantize_keeps_a_resident_dispatch_hook_module_in_placefails withRuntimeError: Expected all tensors to be on the same device, but got index is on cuda:0, different from other tensors on cpu.Green at
27c5a3e0fAwqTorchLinear, and the existing 4-bit AWQ GEMMend-to-end test still loads
AwqGEMMLinearand generates.OUTPUT,BOTH) rehome everyq_projbuffer to CUDA,generate in-session, save, reload, and generate again.
Skips / limits
test_awq_cuda_contract.pywere skipped: this worker only has onevisible GPU assigned. The 2-GPU
requantizevariant was therefore not run end to end; thehook path is covered by the single-GPU resident-hook regression above.
test_norm_requant.py's two failures are pre-existing at43b999585(verified in a cleanworktree) and unrelated to this diff.