Repository navigation
refactor(processors): share the stat-row recorder with eora, weight-only and exl3 - #6677
Merged
Merged
Conversation
…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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
refactor(processors): share the stat-row recorder with eora, weight-only and exl3PR #6429 (
b0bf62dc2) already added the sharedLoopProcessor.record_stat_row/build_quant_module/publish_quant_modulehelpers 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_rowis the only place that builds, appends, tracks and prints a quantization row.What Changed
LoopProcessor.record_stat_rowgains two explicit variations and returns the row it published:include_loss=Falseomits the loss/samples/damp columns (EoRA rows describe adapter fitting, not quantization loss). The identity, time, forward-time andextracolumns keep their order.track=Falsepublishes the row without appending todurations,avg_lossesormodule_names(weight-only rows were never tracked).EoraProcessor.processcalls the recorder withinclude_loss=Falseand the measured(v)ramstring asextra.WeightOnlyProcessor.quantize_modulecalls the recorder withtrack=False,dynamic=False, and(v)ram/lifecycleasextra.EXL3Processor.processbuilds its extra columns ((v)ram,loss_kind, theexl3_*provenance and the optional workspace columns) into one ordered dict, calls the recorder and returns the published row. The row append now uses the sharedself.lockinstead of the private_stats_lock; every other user of the row state (module_stat_row,restore_stat_row, telemetry) already usesself.lock, so the row is now guarded consistently. The twoEXL3Processor.__new__test fixtures that callprocessget alock.create_quant_modulekwargs, packing, numerics, checkpoint format or public API change. AWQ is untouched.Key order is the
quant_log.csvcolumn order and is asserted per processor by the A/B below.Tests
New tests in
tests/test_quant_log_coverage_4321.pypin the two new recorder variations:EXL3 processor tests (GPU 4):
Other affected tests (CPU):
Map test list (CPU; VPTQ files include their GPU/model-gated nodes):
E2 base vs branch (189 test files, CPU,
CUDA_VISIBLE_DEVICES=""):The one base failure is environmental:
tests/test_local_model_loading.py::test_bypass_requires_explicit_trust_and_is_rechecked_on_retrycannot create the Transformers dynamic-module directory under the read-only$HF_HOME/modulescache (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: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_timeand the live(v)rammeasurement 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:timetimetimeModel 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
file:lineevidence.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:#338833eora_processor.py:365-408self.lockblocks, no loss columnsrecord_stat_row(..., include_loss=False)weight_only_processor.py:192-217logappend onlyrecord_stat_row(..., track=False, dynamic=False)exllamav3_processor.py:2920-2999_stats_lockappend, returns statextra+record_stat_row(shared lock), returns statloop_processor.py:1046include_loss/trackflags, returns the rowReview 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:
Kernel Accuracy Requirements
Not applicable: no kernel, packer or dispatch change.
Notes
#6429landed 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.defer_statsbranch no longer exists on main (removed by#6413), so EXL3 uses the recorder unconditionally; there is no deferred row path to keep.tests/test_exl3_zero_sample_fallback_4995.py), so the EXL3 A/B stubsquantize_exl3and compares the processor row, the staged tensors and the returned stat. A real EXL3 quantization is not run.self.lockinstead of_stats_lock._stats_lockstill guards the EXL3 checkpoint-store and deferred-state caches; the row lists are only appended by the recorder and are read underself.lock.🤖 Generated with Claude Code