Skip to content

fix(gptq): harden the failed-quantize Hessian release and run the #5026 guards - #5050

Closed
Qubitium wants to merge 1 commit into
mainfrom
root/fix-stale-del-g-h-5026
Closed

Qubitium wants to merge 1 commit into
mainfrom
root/fix-stale-del-g-h-5026

Conversation

@Qubitium

@Qubitium Qubitium commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #5040 / #5043 (both merged for #5026). Two problems remained on
main after those landed:

  1. 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 when g.quantize() raises, through
    g.release_hessian_state() — unconditionally. The lifetime probe
    (tests/test_gptq_processor_hessian_lifetime_5026.py) uses a
    SimpleNamespace task to count strong references, so the teardown raises
    AttributeError: 'SimpleNamespace' object has no attribute 'release_hessian_state' and replaces the _StopInQuantize the probe relies
    on:

    $ pytest tests/test_gptq_processor_hessian_lifetime_5026.py   # on main 139edadc0
    E  AttributeError: 'types.SimpleNamespace' object has no attribute 'release_hessian_state'
    1 failed
    
  2. 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_h from a duplicate PR could merge on top of the fix that removed the
    local, breaking every GPTQ/GPTAQ/FOEM quantize() with
    UnboundLocalError: cannot access local variable 'g_h' until it was found by
    hand. (origin/main no longer carries that line — it was hotfixed
    separately — so this PR does not re-touch it.)

What Changed

Tests

On unmodified origin/main (139edadc0, both files copied into a separate
worktree):

File Result
tests/test_gptq_processor_hessian_release_5026.py (5 nodes) 5 passed — the del g_h breakage is already hotfixed on main
tests/test_gptq_processor_hessian_lifetime_5026.py (1 node) 1 failed — AttributeError: 'SimpleNamespace' object has no attribute 'release_hessian_state'

On this branch: 6 passed.

Neighbouring suites (CPU):

Run Result
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 files 77 passed, 6 skipped, 1 failed

The 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 on main and unrelated.

ruff check clean on the changed Python file.

Notes

…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.
@Qubitium

Copy link
Copy Markdown
Collaborator Author

Superseded: main already carries this fix as f4511e735 ("drop a leftover del g_h that fails the ruff gate (#5026)", #5047), and origin/main is green on format/check.sh. This PR is now CONFLICTING against that commit — please close it rather than rebase.

@Qubitium

Copy link
Copy Markdown
Collaborator Author

Superseded: main already carries this fix as f4511e735 (PR #5047, merged 00:20Z). Closing to keep the board clean — nothing from this branch is needed.

@Qubitium Qubitium closed this Nov 18, 2026
@Qubitium Qubitium changed the title fix(gptq): drop the stale del g_h that breaks every GPTQ quantize (#5026) fix(gptq): harden the failed-quantize Hessian release and run the #5026 guards Nov 18, 2026
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.

1 participant