Skip to content

fix(macaq): release dead rotation buffers before flip sweep (#4401) - #4431

Merged
Qubitium merged 1 commit into
mainfrom
fix/macaq-dead-copies
Nov 16, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/macaq-dead-copies

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Summary

macaq_quantize_weight kept the pre-scaled weight/hessian and the rotated Hessian alive through the flip sweep even though only the rotated copies are read afterwards. With every module of a layer quantizing concurrently that retained three extra C^2-sized fp32 copies per module.

Addresses the MACaQ item of #4401.

What Changed

  • gptqmodel/nn_modules/quantizer/macaq/...: drop the two pre-scaled locals after rotation and the rotated Hessian after the flip metric is cloned.
  • Packed codes and E8M0 exponents are unchanged; a CPU regression test pins the pre-fix packed bytes and asserts with weakrefs that the three buffers are dead when the sweep starts.

Tests

PYTHONPATH=/root/work-4401 /root/venv/bin/python -m pytest tests/ -k macaq -q
95 passed, 1 skipped
/root/venv/bin/python -m ruff check <changed files>
All checks passed!

Measured on the OLMoE repro: peak RSS down 7.2% (the retained copies are per-module, so the win scales with layer width).

Logic Flow Documentation

Not applicable — local lifetime shortening inside one function; no control-flow or resolution change.

Review Requirements

  • Reviewed; numerical output pinned bitwise by the new test.

`macaq_quantize_weight` kept the pre-scaled `weight`/`hessian` and the
rotated Hessian referenced through the flip sweep even though the rotated
copies are the only values read afterwards.  With every module of a layer
quantizing concurrently, that retained three extra C^2-sized fp32 copies
per module.

Drop the two pre-scaled locals after rotation and the rotated Hessian after
the flip metric is cloned.  The packed codes and E8M0 exponents are
unchanged; a CPU regression test pins the pre-fix packed bytes and asserts
with weakrefs that the three buffers are dead when the sweep starts.
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