Skip to content

fix(gptq): drop the stale del g_h that broke main's lint gate - #5048

Merged
Qubitium merged 3 commits into
mainfrom
fix/g-h-nameerror
Nov 18, 2026
Merged

Qubitium merged 3 commits into
mainfrom
fix/g-h-nameerror

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

What broke

#5043 (squash 297a5c4c) replaced the g_h = g.H local with a read through the task but left the matching del g_h in GPTQProcessor.process(). That is

  • F821 Undefined name 'g_h' from ruff — the lint gate is red on main for every worktree that merged it, and
  • a NameError on every GPTQ/GPTAQ/FOEM module processed with a Hessian present (i.e. all of them).

tests/test_gptq_processor_hessian_release_5026.py was 5/5 red on main:

ruff check gptqmodel/looper/gptq_processor.py -> F821 line 880
pytest tests/test_gptq_processor_hessian_release_5026.py -> 5 failed

Fix

  1. Delete the stale del g_h and replace the comment that described it. The device assert still reads g.H without binding it, so nothing pins the accumulator across quantize() ([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/fix(gptq): stop pinning the task Hessian across quantize() (#5026) #5040 stay satisfied).
  2. tests/test_gptq_processor_hessian_lifetime_5026.py was written against fix(gptq): stop holding the task Hessian across g.quantize() (#5026) #5043's branch, which predates fix(gptq): stop pinning the task Hessian across quantize() (#5026) #5040's task.release_hessian_state() call on the failure path. Its SimpleNamespace double now supplies a no-op hook so the probe measures the reference count again instead of raising AttributeError.

The two commits are a semantic merge conflict between #5040 and #5043 that squash-merging did not catch.

Verification

ruff check gptqmodel tests                                    -> All checks passed
pytest test_gptq_processor_hessian_lifetime_5026.py \
       test_gptq_processor_hessian_release_5026.py \
       test_gptq_hessian_pipeline.py                           -> 22 passed

tests/test_gptq_hessian_memory.py::test_hessian_inverse_inverse_step_failure_is_a_candidate_failure fails identically on pristine main 236f31b0 (verified in a detached worktree); it is unrelated to this change.

Fixes the main-is-red regression from #5043.

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

#5040 made `process()` call `task.release_hessian_state()` when
`quantize()` raises; #5043's probe double predates that helper, so the
probe fails with AttributeError instead of measuring the reference count.
That leaves `tests/test_gptq_processor_hessian_lifetime_5026.py` red on
main after #5047 removed the stale `del g_h`.

Give the double a no-op hook.
@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

Copy link
Copy Markdown
Collaborator Author

Reopening: this is not a duplicate of #5047. #5047 fixed the library half (del g_h); the test half is still red on main @ 7fea6705 (verified just now in a detached worktree):

tests/test_gptq_processor_hessian_lifetime_5026.py::test_process_does_not_hold_the_task_hessian
E   AttributeError: 'types.SimpleNamespace' object has no attribute 'release_hessian_state'
gptqmodel/looper/gptq_processor.py:902
1 failed

Cause: tests/test_gptq_processor_hessian_lifetime_5026.py was written on #5043's branch, which predates #5040's task.release_hessian_state() call on the quantize() failure path. The probe's SimpleNamespace task double therefore lacks the hook the real GPTQ task implements. This PR adds a no-op hook; the refcount assertion is unchanged, so the probe still fails if a caller local pins the Hessian.

Scoped to one test file — no library changes, no overlap with #5047.

@Qubitium Qubitium reopened this Nov 18, 2026
@Qubitium
Qubitium merged commit 340083b into main Nov 18, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/g-h-nameerror branch November 18, 2026 00:40
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