Repository navigation
Conversation
…5026) Two independent fixes for #5026 were rebased on top of each other: #5040 removed the caller's `g_h` local and reads `g.H.device` instead, then #5043 added `del g_h` inside that same block. The merge kept both, so `g_h` is deleted where it is no longer bound: UnboundLocalError: cannot access local variable 'g_h' where it is not associated with a value gptqmodel/looper/gptq_processor.py:880 Every GPTQ/GPTAQ/FOEM module that has a Hessian hits that line, so `GPTQModel.quantize()` fails on the first projection on `main`. The line is a no-op now that the local does not exist, so remove it (and its duplicate comment). Also make the failure-path release defensive: the accumulator is released through `release_hessian_state()` only when the task provides it, and a teardown error is logged instead of replacing the exception that ended `quantize()`. Both #5026 regression files now pass (`test_gptq_processor_hessian_release_5026.py` and `test_gptq_processor_hessian_lifetime_5026.py`, 6 nodes). They were not run by any workflow, which is why the composition break merged: the AWQ CPU `unit` lane now runs them, and its path filter covers `gptqmodel/looper/**` and `gptqmodel/quantization/**`, so a change to either file triggers the lane.
Collaborator
Author
Collaborator
Author
|
Superseded: |
del g_h that breaks every GPTQ quantize (#5026)
This was referenced Nov 18, 2026
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
Follow-up to #5040 / #5043 (both merged for #5026). Two problems remained on
mainafter those landed:A [MEM] GPTQProcessor.process() keeps the task Hessian alive across g.quantize() (local g_h): GPTAQ/FOEM peak VRAM +784 MiB per layer on Llama-3.1-8B (6280 -> 5496 MiB with del g_h, bitwise identical) #5026 regression file fails on
main.process()releases the task's[C, C]accumulator wheng.quantize()raises, throughg.release_hessian_state()— unconditionally. The lifetime probe(
tests/test_gptq_processor_hessian_lifetime_5026.py) uses aSimpleNamespacetask to count strong references, so the teardown raisesAttributeError: 'SimpleNamespace' object has no attribute 'release_hessian_state'and replaces the_StopInQuantizethe probe relieson:
Neither [MEM] GPTQProcessor.process() keeps the task Hessian alive across g.quantize() (local g_h): GPTAQ/FOEM peak VRAM +784 MiB per layer on Llama-3.1-8B (6280 -> 5496 MiB with del g_h, bitwise identical) #5026 test file is run by any workflow. That is how a stale
del g_hfrom a duplicate PR could merge on top of the fix that removed thelocal, breaking every GPTQ/GPTAQ/FOEM
quantize()withUnboundLocalError: cannot access local variable 'g_h'until it was found byhand. (
origin/mainno longer carries that line — it was hotfixedseparately — so this PR does not re-touch it.)
What Changed
gptqmodel/looper/gptq_processor.py: the failure-path release goes throughrelease_hessian_state()only when the task provides it, and a teardown erroris logged instead of propagated, so the exception that ended
quantize()isalways the one the caller sees. No change to the success path or the numerics.
.github/workflows/awq_cpu.yml: theunitlane runs both [MEM] GPTQProcessor.process() keeps the task Hessian alive across g.quantize() (local g_h): GPTAQ/FOEM peak VRAM +784 MiB per layer on Llama-3.1-8B (6280 -> 5496 MiB with del g_h, bitwise identical) #5026 regressionfiles, and the pull-request path filter gains
tests/test_gptq_processor_hessian_*.py. The lane already triggers ongptqmodel/looper/**andgptqmodel/quantization/**, so a change to eitherfile now runs the guards that cover it.
Tests
On unmodified
origin/main(139edadc0, both files copied into a separateworktree):
tests/test_gptq_processor_hessian_release_5026.py(5 nodes)del g_hbreakage is already hotfixed on maintests/test_gptq_processor_hessian_lifetime_5026.py(1 node)AttributeError: 'SimpleNamespace' object has no attribute 'release_hessian_state'On this branch: 6 passed.
Neighbouring suites (CPU):
test_gptq_hessian_memory,test_gptq_shared_hessian,test_gptq_workspace_release,test_gptaq_foem_batch,test_gptaq_shuffle_pairing_4869,test_fallback_hessian_release,test_failed_run_model_state_5009,test_docs_contract_refs+ both #5026 filesThe single failure is the pre-existing
test_fallback_hessian_release.py::TestFallbackReleasesPartials::test_shared_input_fallback_releases_adopted_source_before_clone(
IndexError: list index out of range), identical onmainand unrelated.ruff checkclean on the changed Python file.Notes
ruffdoes report the staledel g_hasF821 Undefined name 'g_h'on thebroken revision, so the lint lane covers this class of breakage too — the gap
this PR closes is the test lane, which had neither file.
[MEM] GPTQProcessor.process() keeps the task Hessian alive across g.quantize() (local g_h): GPTAQ/FOEM peak VRAM +784 MiB per layer on Llama-3.1-8B (6280 -> 5496 MiB with del g_h, bitwise identical) #5026 and were rebased onto each other instead of one being closed, which is
how two halves of one statement ended up merged. Closing the duplicate before
merging avoids that class of breakage entirely.