Skip to content

fix(looper): dedup shared-input Hessians for QQQ/VPTQ/MACaQ/EXL3 and GPTAQ/FOEM (#4401, #4391) - #4514

Merged
Qubitium merged 3 commits into
mainfrom
fix/sibling-hessian-dedup-4401
Nov 17, 2026
Merged

Qubitium merged 3 commits into
mainfrom
fix/sibling-hessian-dedup-4401

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Summary

Fixes #4401 item 3 and #4391 item 4 (second half).

  • QQQ/VPTQ/MACaQ/EXL3: sibling modules fed by the same source activation now share the input Hessian (and dXXT where accumulated) instead of each building an identical copy. GPTQ already had this dedup; these methods were excluded because they "also consume outputs", which is not true of their add_batch Hessian accumulation.
  • GPTAQ/FOEM: followers adopt the leader's H and dXXT at bs>1 instead of accumulating identical matrices per sibling (q/k/v ×3, gate/up ×2), and the stale comment is corrected.

Validation

  • pytest tests/test_shared_input_hessian_dedup_methods.py -q → 14 passed
  • pytest tests/test_gptaq_foem_batch.py tests/test_native_sibling_input_sharing.py -q → 22 passed
  • The new tests assert bitwise-identical quantized output versus the non-dedup path and that storage is actually shared (identity/adoption), not just that the code runs.
  • CPU-only environment; no CUDA numerical qualification.

Resolves #4401 (item 3) and the remaining item of #4391.

Comment thread gptqmodel/looper/qqq_processor.py Fixed
Comment thread gptqmodel/looper/vptq_processor.py Fixed
Add SharedInputCaptureProcessor(SharedInputCaptureMixin, LoopProcessor) that
explicitly delegates begin_shared_input_capture/end_shared_input_capture to
the mixin, and have QQQ, VPTQ, MACaQ and EXL3 inherit that single base. This
removes the conflicting inherited attributes flagged by code quality while
preserving the mixin's leader election and adoption behavior. LoopProcessor
keeps its no-op defaults for every other processor.

Add tests asserting the four processors resolve the wrapper methods, that the
wrappers delegate to the mixin (non-empty leaders, verified telemetry), and
that a bare LoopProcessor still returns {} / None.
@Qubitium
Qubitium merged commit 01b2c48 into main Nov 17, 2026
9 checks passed
@Qubitium
Qubitium deleted the fix/sibling-hessian-dedup-4401 branch November 17, 2026 00:55
Qubitium added a commit that referenced this pull request Nov 29, 2026
…s private copy

GPTQProcessor carried its own copy of the shared-input leader election
(_resolve_shared_input_plan, begin/end_shared_input_capture,
shared_input_leader and the inline election loop). #4514 introduced
SharedInputCaptureMixin with the same algorithm for QQQ, VPTQ, MACaQ and EXL3
but left the GPTQ copy in place.

GPTQProcessor now derives from SharedInputCaptureProcessor and keeps only
its GPTQ-specific parts as mixin hooks:

- _shared_input_task_enabled: the per-task hessian.dedup_shared_inputs check.
- _shared_input_task_signature: the former _hessian_capture_signature
  (GPTQ/ADMM-Q, GPTAQ, FOEM and JointQ cohorts), renamed.
- _shared_input_begin_cohort: clears the plain-GPTQ factor caches of the
  subset. The mixin hook now also receives subset_names, because GPTQ only
  clears tasks in the subset.
- _shared_input_task_adopt: adopts the Hessian, then attaches one
  SharedHessianFactorCache per plain-GPTQ leader. The leader's cache was
  cleared when the cohort began, so its first follower creates the cache
  and the rest join it. That matches the old per-call dict without the
  processor holding a reference to cached factors after the pass ends.

Shared-input dedup decides which modules share a Hessian, so the leaders,
telemetry, per-task H/dXXT/quantized weights and factor-cache identity
graph were compared against origin/main on CPU fixtures. GPTQ and GPTAQ
quantization of Qwen2.5-0.5B-Instruct and of a tiny random Mixtral (a
shared-input verified MoE, so expert gate/up share a Hessian) were also
compared on GPU, together with the sorted quant-log rows and dedup
telemetry. All of them are bit-identical.

Two observable differences remain. The generation counter now also advances
when a model has no shared-input plan; no factor cache exists then, and every
cache that is created keeps the same generation as before. The mismatch
warning says "accumulation settings" instead of "capture settings".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Qubitium added a commit that referenced this pull request Nov 29, 2026
…s private copy (#6428)

GPTQProcessor carried its own copy of the shared-input leader election
(_resolve_shared_input_plan, begin/end_shared_input_capture,
shared_input_leader and the inline election loop). #4514 introduced
SharedInputCaptureMixin with the same algorithm for QQQ, VPTQ, MACaQ and EXL3
but left the GPTQ copy in place.

GPTQProcessor now derives from SharedInputCaptureProcessor and keeps only
its GPTQ-specific parts as mixin hooks:

- _shared_input_task_enabled: the per-task hessian.dedup_shared_inputs check.
- _shared_input_task_signature: the former _hessian_capture_signature
  (GPTQ/ADMM-Q, GPTAQ, FOEM and JointQ cohorts), renamed.
- _shared_input_begin_cohort: clears the plain-GPTQ factor caches of the
  subset. The mixin hook now also receives subset_names, because GPTQ only
  clears tasks in the subset.
- _shared_input_task_adopt: adopts the Hessian, then attaches one
  SharedHessianFactorCache per plain-GPTQ leader. The leader's cache was
  cleared when the cohort began, so its first follower creates the cache
  and the rest join it. That matches the old per-call dict without the
  processor holding a reference to cached factors after the pass ends.

Shared-input dedup decides which modules share a Hessian, so the leaders,
telemetry, per-task H/dXXT/quantized weights and factor-cache identity
graph were compared against origin/main on CPU fixtures. GPTQ and GPTAQ
quantization of Qwen2.5-0.5B-Instruct and of a tiny random Mixtral (a
shared-input verified MoE, so expert gate/up share a Hessian) were also
compared on GPU, together with the sorted quant-log rows and dedup
telemetry. All of them are bit-identical.

Two observable differences remain. The generation counter now also advances
when a model has no shared-input plan; no factor cache exists then, and every
cache that is created keeps the same generation as before. The mismatch
warning says "accumulation settings" instead of "capture settings".

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant