Skip to content

refactor(processors): share the stat-row recorder with eora, weight-only and exl3 - #6677

Merged
Qubitium merged 1 commit into
mainfrom
refactor/looper-stat-row-and-publisher
Dec 1, 2026
Merged

Qubitium merged 1 commit into
mainfrom
refactor/looper-stat-row-and-publisher

Conversation

@Qubitium

@Qubitium Qubitium commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

refactor(processors): share the stat-row recorder with eora, weight-only and exl3

PR #6429 (b0bf62dc2) already added the shared LoopProcessor.record_stat_row / build_quant_module / publish_quant_module helpers and moved GPTQ (GPTAQ/FOEM), QQQ, VPTQ, MACaQ, Paro, NFVP4, TETRA and TWLA onto them. That PR deliberately left four stat-row copies behind: EoRA (no loss columns), the weight-only processor (untracked rows, no dynamic column), EXL3 (private stats lock, extra workspace columns) and AWQ (different columns and config source; out of scope).

This PR finishes the three non-AWQ copies. The shared recorder now covers every in-tree processor except AWQ, and record_stat_row is the only place that builds, appends, tracks and prints a quantization row.

What Changed

  • LoopProcessor.record_stat_row gains two explicit variations and returns the row it published:
    • include_loss=False omits the loss/samples/damp columns (EoRA rows describe adapter fitting, not quantization loss). The identity, time, forward-time and extra columns keep their order.
    • track=False publishes the row without appending to durations, avg_losses or module_names (weight-only rows were never tracked).
  • EoraProcessor.process calls the recorder with include_loss=False and the measured (v)ram string as extra.
  • WeightOnlyProcessor.quantize_module calls the recorder with track=False, dynamic=False, and (v)ram/lifecycle as extra.
  • EXL3Processor.process builds its extra columns ((v)ram, loss_kind, the exl3_* provenance and the optional workspace columns) into one ordered dict, calls the recorder and returns the published row. The row append now uses the shared self.lock instead of the private _stats_lock; every other user of the row state (module_stat_row, restore_stat_row, telemetry) already uses self.lock, so the row is now guarded consistently. The two EXL3Processor.__new__ test fixtures that call process get a lock.
  • No create_quant_module kwargs, packing, numerics, checkpoint format or public API change. AWQ is untouched.

Key order is the quant_log.csv column order and is asserted per processor by the A/B below.

Tests

  • Unit tests have been executed and passed, or the reason they are not applicable is documented.
  • I added a new simple/fast unit test for this change, or documented why that is not applicable.

New tests in tests/test_quant_log_coverage_4321.py pin the two new recorder variations:

CUDA_VISIBLE_DEVICES="" PYTHONPATH=$PWD python -P -m pytest -q -p no:cacheprovider \
  tests/test_quant_log_coverage_4321.py tests/test_weight_only_looper.py tests/test_eora.py
# 49 passed, 1 skipped in 5.99s

EXL3 processor tests (GPU 4):

CUDA_DEVICE_ORDER=PCI_BUS_ID CUDA_VISIBLE_DEVICES=4 PYTHONPATH=$PWD python -P -m pytest -q \
  tests/test_exl3_zero_sample_fallback_4995.py
# 16 passed in 5.34s

CUDA_DEVICE_ORDER=PCI_BUS_ID CUDA_VISIBLE_DEVICES=4 PYTHONPATH=$PWD python -P -m pytest -q \
  tests/test_exl3_projection_resume.py
# 7 passed in 6.84s

Other affected tests (CPU):

CUDA_VISIBLE_DEVICES="" PYTHONPATH=$PWD python -P -m pytest -q -p no:cacheprovider \
  tests/test_module_looper_quant_log_4321.py tests/test_writer_quant_log.py \
  tests/test_writer_dynamic_order.py tests/test_benchmark_submodule_finalize.py tests/test_eora_weight_lifecycle.py
# 35 passed, 3 skipped in 5.51s

Map test list (CPU; VPTQ files include their GPU/model-gated nodes):

CUDA_VISIBLE_DEVICES="" PYTHONPATH=$PWD python -P -m pytest -q -p no:cacheprovider \
  tests/test_quant_telemetry.py tests/test_awq_qqq_pack_shape_4567.py \
  tests/test_vptq.py tests/test_vptq_codebook_sum_5609.py tests/test_vptq_memory_4391.py \
  tests/test_vptq_outlier_bounds.py tests/test_vptq_segment_sum_repeatability.py \
  tests/test_checkpoint_resume_nf12_macaq_4792.py \
  "tests/test_run_exit_recovery_contract_5060.py::test_pack_fault_leaves_no_half_built_kernel" tests/test_eora.py
# 306 passed, 110 skipped in 80.44s

E2 base vs branch (189 test files, CPU, CUDA_VISIBLE_DEVICES=""):

CUDA_VISIBLE_DEVICES="" PYTHONPATH=$PWD python -P -m pytest -q -p no:cacheprovider $(cat e2_files.txt)
# base 0127a0313: 1 failed, 6772 passed, 758 skipped, 3 xfailed in 2471.91s
# branch:         1 failed, 6772 passed, 758 skipped, 3 xfailed in 2266.83s

The one base failure is environmental: tests/test_local_model_loading.py::test_bypass_requires_explicit_trust_and_is_rechecked_on_retry cannot create the Transformers dynamic-module directory under the read-only $HF_HOME/modules cache (OSError: [Errno 30] Read-only file system). It fails before any looper code runs.

bash format/check.sh (ruff 0.14.2): All checks passed!

Measured Impact

CPU A/B (same tiny 2-layer Llama fixture, seed 0, calibration seed 7), old (main 0127a0313) vs new:

Processor Rows Row key order Values (time/measured excluded) durations module_names avg_losses installed state
weight-only RTN 14 identical identical 0 = 0 0 = 0 [] = [] 63 saved tensors bit-identical, jsons equal
EoRA + GPTQ control 14 + 14 identical identical 14 = 14 14 = 14 GPTQ list equal 63 saved + 28 adapter tensors bit-identical; adapter_config differs only in the output path and target_modules list order
EXL3 (stubbed quantizer) 1 identical identical 1 = 1 1 = 1 [0.01] = [0.01] 4 staged tensors identical; returned stat identical

Row order is scheduling-dependent on both revisions: two runs of the same main tree emitted the GPTQ rows in different orders. The comparison therefore keys rows by (layer, module) and compares each row's ordered key list; time, fwd_time and the live (v)ram measurement are excluded. The CSV A/B is likewise row-keyed.

GPU 4, unsloth/Llama-3.2-1B-Instruct, bf16, seed 0, 128x512 batch 8 (MACaQ 32x128 batch 4), main vs branch, saved checkpoints compared bit-for-bit:

Method Saved tensors config jsons quant_log.csv Processor rows
GPTQ 482 bit-identical equal 112 rows identical except time 112 rows identical
QQQ 370 bit-identical equal 112 rows identical except time 112 rows identical
MACaQ 258 bit-identical equal 112 rows identical except time 112 rows identical

Model Support / Module Plan

Not applicable: no model, alias, definition or module tree change.

AWQ onboarding safety

Not applicable: AWQ is out of scope and untouched.

Logic Flow Documentation

  • This change alters how one log row is assembled for three processors; the diagram and old-vs-new table are below.
  • New-flow Mermaid diagram uses real symbol names.
  • The replaced mechanism is tabulated with file:line evidence.
  • Failure paths are marked.
flowchart TD
    A["Processor.process / quantize_module"] --> B["LoopProcessor.record_stat_row"]
    B --> C{"include_loss?"}
    C -- "yes" --> D["identity, loss, samples, damp"]
    C -- "no (EoRA)" --> E["identity only"]
    D --> F["time, fwd_time"]
    E --> F
    F --> G["extra columns in caller order<br/>(v)ram, loss_kind, exl3_*, workspace_*, lifecycle"]
    G --> H{"dynamic and qcfg.dynamic?"}
    H -- "yes" --> I["dynamic column last"]
    H -- "no" --> J["row complete"]
    I --> J
    J --> K{"track?"}
    K -- "yes" --> L["lock: durations, avg_losses, module_names, log"]
    K -- "no (weight-only)" --> M["lock: log only"]
    L --> N["log_new_row(row)"]
    M --> N
    N --> O["return row"]
    style O fill:#e8ffe8,stroke:#338833
Loading
Site (main) Before After
eora_processor.py:365-408 inline dict, two self.lock blocks, no loss columns record_stat_row(..., include_loss=False)
weight_only_processor.py:192-217 inline dict, log append only record_stat_row(..., track=False, dynamic=False)
exllamav3_processor.py:2920-2999 inline dict, _stats_lock append, returns stat ordered extra + record_stat_row (shared lock), returns stat
loop_processor.py:1046 fixed loss columns, always tracks, no return include_loss/track flags, returns the row

Review Requirements

AI-assisted code is welcome. Open the PR as a draft. Mark it ready only after
review and after GitHub confirms the pushed head has no conflicts with the
current remote base.

I or an AI agent (such as Codex or Claude) have:

  • Reviewed this PR.
  • Checked that the code matches existing project structure, APIs, and conventions.
  • Avoided unnecessary monkeypatching and used the project's normal extension points where possible.
  • Minimized and compacted the impacted code surface.
  • Considered and eliminated potential regressions.

Kernel Accuracy Requirements

Not applicable: no kernel, packer or dispatch change.

Notes

  • #6429 landed the bulk of the map item (record_stat_row, build_quant_module, publish_quant_module). This PR is the follow-up for the three stat rows that PR left out; the publisher half is already shared.
  • The map's EXL3 defer_stats branch no longer exists on main (removed by #6413), so EXL3 uses the recorder unconditionally; there is no deferred row path to keep.
  • EXL3's native trellis extension cannot be built in this image (same limitation as tests/test_exl3_zero_sample_fallback_4995.py), so the EXL3 A/B stubs quantize_exl3 and compares the processor row, the staged tensors and the returned stat. A real EXL3 quantization is not run.
  • The EXL3 row append now takes self.lock instead of _stats_lock. _stats_lock still guards the EXL3 checkpoint-store and deferred-state caches; the row lists are only appended by the recorder and are read under self.lock.
  • VPTQ and Paro were not run on GPU (MACaQ was the third method); they already used the shared helper before this PR.
  • AWQ keeps its own row and is not touched (W1 owns AWQ code).

🤖 Generated with Claude Code

…nly and exl3

PR #6429 added `LoopProcessor.record_stat_row`, `build_quant_module` and
`publish_quant_module` and moved GPTQ (GPTAQ/FOEM), QQQ, VPTQ, MACaQ, Paro,
NVFP4, TETRA and TWLA onto them. It left four stat-row copies behind: EoRA
(no loss columns), the weight-only processor (untracked rows, no dynamic
column), EXL3 (private stats lock, extra workspace columns) and AWQ (different
columns and config source; out of scope).

Finish the three non-AWQ copies:

- `record_stat_row` gains `include_loss=False` (EoRA rows describe adapter
  fitting and have no loss/samples/damp columns) and `track=False`
  (weight-only rows are published without appending to durations,
  avg_losses or module_names), and returns the row it published (EXL3
  returns its stat).
- EoRA passes the measured `(v)ram` as `extra` with `include_loss=False`.
- Weight-only passes `(v)ram`/`lifecycle` as `extra` with `track=False` and
  `dynamic=False`.
- EXL3 builds its `(v)ram`, `loss_kind`, `exl3_*` and optional workspace
  columns into one ordered `extra` dict and appends the row under the shared
  `self.lock` instead of `_stats_lock`; every other reader and writer of the
  row state already uses `self.lock`. The two `__new__` test fixtures that
  call `process` get a lock. The map's EXL3 `defer_stats` branch no longer
  exists (removed by #6413), so there is no deferred path to keep.

Key order, row values (except time and the live memory measurement),
`durations` length, `module_names` and the installed/saved state are
unchanged. The CPU A/B covers weight-only RTN, EoRA plus the GPTQ control and
an EXL3 stubbed-quantizer run; the GPU 4 A/B on Llama-3.2-1B GPTQ, QQQ and
MACaQ is bit-identical and quant_log.csv is identical except the time column.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Qubitium
Qubitium marked this pull request as ready for review December 1, 2026 17:48
@Qubitium
Qubitium merged commit 695ea96 into main Dec 1, 2026
6 checks passed
@Qubitium
Qubitium deleted the refactor/looper-stat-row-and-publisher branch December 1, 2026 17:48
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