Skip to content

refactor(exl3): drop the EXL3 error ledger and projection journal - #6423

Merged
Qubitium merged 1 commit into
mainfrom
refactor/exl3-drop-error-ledger
Nov 29, 2026
Merged

Qubitium merged 1 commit into
mainfrom
refactor/exl3-drop-error-ledger

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Summary

Drops the EXL3 error ledger and the per-projection error journal. Nothing in the repository reads either of them back.

Before this PR, every EXL3 quantize wrote two kinds of side file:

  • The journal. Each projection appended one canonical-JSON record, with an fsync per record, to logs/<processor>_log_<id>_time_<ts>.exl3-error-ledger.jsonl. That path is relative to the current working directory, unless GPTQMODEL_EXL3_ERROR_JOURNAL was set. Fifteen of these files had been committed under tests/logs/ by accident. They are deleted here.
  • The ledger. Every save wrote ds4rt-exl3-error-ledger.jsonl and ds4rt-exl3-error-ledger.manifest.json into the model directory. They hold projection records, w1/w2/w3 expert-family aggregates and a digest manifest.

quant_log.csv already records layer, module, loss, loss kind, sample count, damp and time for every method.

Behaviour change: the side files are no longer written. Tensors, quantize_config.json, config.json and the quant_log.csv columns are unchanged. The GPU A/B below shows them byte-identical.

Net diff: 41 files changed, 1204 insertions(+), 2441 deletions(-), so -1237 lines.

  • Production: +621 / -1244. About 530 of the + lines are a verbatim move (see "Kept").
  • Tests: +569 / -1163, including -175 for the committed journals. About 400 of the + lines are kept tests moved to a new file.
  • Docs: +14 / -34.

To see the moves, run git diff --color-moved=zebra origin/main...refactor/exl3-drop-error-ledger.

What Changed

Removed

  • gptqmodel/utils/exl3_error_ledger.py: build_projection_record, provenance compaction (compact_projection_*), family aggregation (derive_family_records), the journal (append_exl3_error_journal and its index) and write_exl3_error_ledger.
  • EXL3Processor.__init__: the journal path, exllamav3_processor.py:955 on main.
  • EXL3Processor.process: the record build (:2899), the record rebuild-and-compare on a projection-checkpoint hit (:2953-2985), the journal append (:2994), and the stat keys exl3_error_ledger_record, exl3_error_journal and exl3_error_record_sha256 (:3036-3038).
  • writer.py: the ledger write (:2706 on main) and its import.
  • Tests: tests/test_exl3_error_ledger.py (915 lines), the committed tests/logs/*.exl3-error-ledger.jsonl, and docs/exl3-error-ledgers.md with its index link.

Kept, because a live path still uses it

  • The ledger module also held route contracts that other paths use: routed_expert_identity, routed_expert_processor_layer, the natural-route evidence contract (ROUTE_EVIDENCE_*, route_evidence_required, validate_route_evidence) and the zero-route recovery recipe, authorization and validators.
  • Their users are route capture, zero-route recovery, projection-checkpoint request identity, capture frontiers and the DS4 recovery context.
  • They move verbatim into gptqmodel/utils/exl3_router_candidates.py, next to the router ranking they serve. The only edit: the JSON guard's two error messages say "route value" instead of "ledger value".
  • Route-evidence capture is not deleted. It feeds the zero-route census and the projection-checkpoint request hash. Only its copy into the ledger record goes.
  • Tests of the kept code move into tests/test_exl3_route_recovery_contracts.py.
    • The identity, recipe, census and validator tests are carried over unchanged.
    • Three tests reached the validators through build_projection_record. They now call validate_route_evidence / validate_zero_route_recovery directly, with the same accept/reject cases.

Re-pointed: two live checks read module names from the ledger record

Check Before (main) After
_validate_exllamav3_publication_modules: every module in the quant log must be packed before META sync. Runs on every EXL3 save. writer.py:1673 reads entry["exl3_error_ledger_record"]["module"] writer.py:1672 reads entry["exl3_module"]
DeepSeekV4QModel.attach_mtp_quantization_model: MTP coverage and collision check deepseek_v4.py:1710 reads record["block_namespace"] == "mtp" and record["module"] deepseek_v4.py:1712 reads entry["exl3_module"]; namespace from routed_expert_identity(name), the same regex the record used
Source of the module name exl3_error_ledger_record.module new stat key exl3_module: module.full_name (exllamav3_processor.py:2957)

Projection checkpoints

  • On a hit, process() used to require result["ledger_record"] and rebuild it for comparison.
  • New results no longer store a ledger_record.
  • Results committed by older builds still carry one. It is ignored, so those checkpoints still hit (exllamav3_processor.py:2906). A cross-tree check proves this; see below.

Retired switches (warn once, no effect)

  • meta["ds4rt_error_ledger"] itself stays. Its family_join and run.projection_checkpoint entries still drive route recovery, capture frontiers and projection checkpoints.
  • ds4rt_error_ledger.run.projection_checkpoint_seed was read only by the ledger's provenance compaction. It joins _RETIRED_META_KEYS, so to_dict() drops it.
  • GPTQMODEL_EXL3_ERROR_JOURNAL joins _RETIRED_KERNEL_ENV_VARS with no replacement.
  • Docs: docs/looper-checkpoint-redesign.md (retired switches table), docs/kernel-config.md, the docs/exl3-durable-execution.md process diagram, docs/native-checkpoint-export.md, and docs/exl3-router-recovery.md (new home of the contracts; line refs updated).

Other observable changes

  • The per-module stat dicts that quantize() returns, also shown as columns in the CLI table, lose the three ledger/journal keys and gain exl3_module.
  • The ledger's JSON serialization also rejected non-finite quantizer metrics, so a NaN/inf metric used to abort the run there. That rejection goes away. validate_exl3_hessian_metrics still requires a finite selected scale, scale-search MSE, diagonal addend and symmetry correction. On a configured projection-checkpoint store, the stored result is still finite-checked.
  • Under the non-default family_join.route_evidence_contract switch, build_projection_record re-validated route and recovery evidence once more at quantize time. validate_subset_capture_readiness already validates the same evidence before fan-out, and that check remains.

Out of scope (follow-ups)

  • The route capture, zero-route recovery, projection checkpoints and capture frontiers themselves (ds4rt map E1/G3).
  • Renaming the ds4rt_error_ledger meta key. It is a saved public key, and its name no longer matches its content.

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 or changed regressions, with red evidence from a disposable worktree:

  • tests/test_exl3_projection_resume.py::test_process_resumes_from_packed_checkpoint_without_requantizing[current|legacy] (GPU).
    • legacy rewrites the committed manifest to carry a ledger_record, as older builds stored it, and asserts a hit with no requantization.
    • Mutation A reinstates not isinstance(result.get("ledger_record"), dict): [current] fails with "result is malformed".
    • Mutation B rejects the legacy key: [legacy] fails.
  • tests/test_deepseek_v4_support.py::test_deepseek_v4_mtp_quantization_adapter_replays_one_exact_block: a target-namespace module in the MTP log must raise "coverage mismatch". Dropping the namespace check gives DID NOT RAISE.
  • tests/test_exl3_zero_sample_fallback_4995.py::test_unrouted_expert_is_packed_end_to_end (GPU): runs process() from an empty cwd, asserts nothing is written there, and asserts stat["exl3_module"].
  • tests/test_writer_attention.py::test_save_quantized_writes_unambiguous_csv_and_no_exl3_ledger: the save directory holds only quant_log.csv, and the CSV rows are unchanged.
  • tests/test_writer_state_overlay.py::test_exl3_publication_guard_*: the publication guard on exl3_module.
  • tests/test_exllamav3.py::test_retired_ds4rt_meta_keys_warn_once_and_are_not_saved[exl3|gptq]: now covers run.projection_checkpoint_seed.

Per-node A/B of the touched families, base = origin/main a4471c5, new = this branch. junit_cmp.py compares the junit xml node by node.

# CPU (CUDA_VISIBLE_DEVICES=""), each tree with PYTHONPATH=<tree>, python -P (gptqmodel.__file__ printed per tree)
pytest -q -rs tests/test_exl3_*.py tests/test_exllamav3*.py tests/test_qwen4_exp_exl3_contracts.py tests/test_writer_*.py \
  tests/test_deepseek_v4_support.py tests/test_deepseek_v4_local_port.py tests/test_glm5_next_support.py \
  tests/test_glm_moe_dsa_support.py tests/test_docs_contract_refs.py tests/test_cpu_policy_4396.py \
  tests/test_runtime_config_4448.py tests/test_module_looper_quant_log_4321.py tests/test_quantize_config_offload_tempdir.py \
  tests/test_looper_processor_capabilities.py tests/test_mlx_exl3_pipeline.py tests/test_shared_input_hessian_dedup_methods.py \
  tests/module_tree/test_dots3_note_fork_plan.py tests/module_tree/test_deepseek_v4_local_port.py tests/test_config_only_export.py \
  tests/test_split_by_layer_save.py tests/test_offload_files.py tests/test_gguf_load_policy_env_removal.py tests/test_rco_formats.py
# base: 1292 passed, 655 skipped      new: 1280 passed, 656 skipped
# common nodes 1920, identical outcome 1920, changed: none
# only in base: 25 test_exl3_error_ledger nodes + the renamed writer_attention test
# only in new: 13 test_exl3_route_recovery_contracts nodes + the renamed writer_attention test

# CUDA (CUDA_DEVICE_ORDER=PCI_BUS_ID CUDA_VISIBLE_DEVICES=<one RTX 4090>)
pytest -q -rs tests/test_exl3_*.py tests/test_exllamav3*.py tests/kernels/test_exllamav3_kernel.py \
  tests/test_qwen4_exp_exl3_contracts.py tests/test_writer_attention.py tests/test_writer_state_overlay.py \
  tests/test_deepseek_v4_support.py tests/test_glm_moe_dsa_support.py tests/test_quantize_config_offload_tempdir.py \
  tests/test_mlx_exl3_pipeline.py
# base: 1264 passed, 14 skipped      new: 1253 passed, 14 skipped
# common nodes 1251, identical outcome 1251, changed: none
# only in new: the resume test's [current] and [legacy] params + the 13 moved contract tests + the renamed writer test

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

Skips:

  • The 14 CUDA-run skips are the same on both trees and leave these paths unverified:
    • PYTHON_GIL=0 subprocess tests (no free-threaded build);
    • the two-GPU data-parallel Hessian tests and the cuda:1 workspace/RNG tests (only one GPU used);
    • ROCm, and MLX/Metal;
    • the owner=False capture-source reduction;
    • BF16 CPU-bridge variants that dispatch native on CUDA.
  • The CPU-run skips are the CUDA-only nodes, which the CUDA run covers, plus docs examples and other platform gates. They are identical on both trees except the one extra [legacy] resume param, which the CUDA run covers.

GPU A/B (required: the quantize and save path is touched).

  • Setup: EXL3Config() defaults (bits=4, mcg) on Qwen/Qwen2.5-0.5B-Instruct, 64 wikitext-2 rows, seed 0, one RTX 4090.
  • Each run uses a fresh empty cwd. Base and new each run with offload_to_disk=False and True.
  • Script: gpu_ab.py quant <out> <0|1> then gpu_ab.py compare <base_out> <new_out>.
offload_to_disk model.safetensors config / quantize_config / generation_config / tokenizer jsons quant_log.csv (layer, module, loss, loss_kind, samples, damp) file-list difference *.jsonl in cwd
False bit-identical (sha256 40ac554a…) all byte-identical identical row set, 168 rows only ds4rt-exl3-error-ledger.{jsonl,manifest.json}, missing on new base: logs/exl3_log_…exl3-error-ledger.jsonl; new: none
True bit-identical (sha256 102b029b…) all byte-identical identical row set, 168 rows same base: one journal; new: none

quant_log.csv row order differs between runs. Rows are appended by parallel module workers, so the comparison uses the row set.

Cross-tree checkpoint compatibility (GPU).

  • cross_tree_checkpoint.py drives the resume test's processor helper.
  • The base tree quantizes one 128×128 projection with a projection-checkpoint store. Its result keys include ledger_record.
  • The new tree then processes the same projection with quantize_exl3 replaced by a function that raises. The result is hit True, and the replay weight is bit-identical to the base tree's.

Measured Impact

Not applicable: no claimed issue. Peak CUDA allocation was 1388 MiB on both trees in all four A/B runs. The per-projection journal fsync and the save-time ledger write are gone; neither was timed.

Model Support / Module Plan

Not applicable: no MODEL_MAP, definition, module plan or fusion change. deepseek_v4.py changes only the MTP attach coverage check's input, covered above.

Model test node IDs and results (or "not applicable"): not applicable.

AWQ onboarding safety

Not applicable: AWQ grouping, search, replay and folding are untouched.

Logic Flow Documentation

  • This change does not alter a major logic flow, or the required diagrams and docs page are included below.
  • New-flow Mermaid diagram(s) describe the shipped code using real symbol names.
  • The removed/replaced mechanism is shown or tabulated with file:line evidence.
  • Failure and ambiguity paths are marked and visually distinct from success.
  • A reference page under docs/ repeats the diagrams, titled for the mechanism, and is linked from README.md.

This removes a persisted side effect and changes where the publication guard gets its module names. The process diagram in docs/exl3-durable-execution.md drops the journal node. The old/new source table is under "Re-pointed" above.

flowchart TD
    P["EXL3Processor.process"] --> S{"projection checkpoint store"}
    S -->|"none, the default"| Q["quantize_exl3"]
    S -->|"hit; an old ledger_record key is ignored"| L["reuse packed tensors"]
    Q --> C["store.commit if configured<br/>result has no ledger_record"]
    C --> T["_stage_runtime_weight<br/>stat row with exl3_module"]
    L --> T
    T --> W["ModelWriter.save_quantized"]
    W --> G["_validate_exllamav3_publication_modules<br/>reads exl3_module"]
    G -->|"a named module is not packed"| X["RuntimeError: publication tree is missing packed modules"]
    G --> CSV["quant_log.csv; no ledger files"]
    style X fill:#fee,stroke:#b22
Loading

Review Requirements

  • 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, dispatch or packing change. The packed tensors are bit-identical in the GPU A/B.

Notes

  • Saved EXL3 models that contain ds4rt-exl3-error-ledger.* still load: no loader reads those files.
  • Old quantize_config.json files whose meta.ds4rt_error_ledger.run has projection_checkpoint_seed warn once. Re-saving drops that entry.
  • Out-of-tree tooling that read the ledger, the journal, or the three removed stat keys will no longer find them. The maintainer approved dropping the ledger.

🤖 Generated with Claude Code

Every EXL3 quantize wrote two side files that nothing in the repository reads
back:

- each projection appended a canonical-JSON record to
  logs/<processor>.exl3-error-ledger.jsonl (relative to the current working
  directory, or GPTQMODEL_EXL3_ERROR_JOURNAL), with an fsync per record;
- every save wrote ds4rt-exl3-error-ledger.jsonl plus a
  ds4rt-exl3-error-ledger.manifest.json (projection records, w1/w2/w3
  expert-family aggregates and a digest manifest) into the model directory.

quant_log.csv already records layer, module, loss, loss kind, sample count,
damp and time for every method.

Removed: utils/exl3_error_ledger.py's record builder, provenance compaction,
family aggregation, journal and ledger writer; the processor's journal path,
journal append and record build/compare on projection-checkpoint hits; the
writer's ledger write. Fifteen journal files committed under tests/logs go too.

Kept, because live paths still use them: routed_expert_identity, the
natural-route evidence contract and the zero-route recovery recipe and
validators. Route capture, recovery, projection checkpoints and capture
frontiers depend on them, so they move verbatim (two error messages lose the
word "ledger") into utils/exl3_router_candidates.py, next to the router
ranking they serve.

Two live checks read module names from the ledger record. The writer's
_validate_exllamav3_publication_modules (run on every EXL3 save) and the DS4
attach_mtp_quantization_model coverage check now read the new exl3_module
quant-log key, the full module name, instead.

Projection checkpoints: new results no longer store a ledger_record. Results
committed by older builds still carry one; it is ignored, so they still hit.

meta: ds4rt_error_ledger itself stays, because family_join and
run.projection_checkpoint still drive recovery and checkpoints.
run.projection_checkpoint_seed only fed the ledger, so it joins
_RETIRED_META_KEYS. GPTQMODEL_EXL3_ERROR_JOURNAL joins
_RETIRED_KERNEL_ENV_VARS. Both warn once.

Tensors, quantize_config.json and the quant_log.csv columns are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Qubitium
Qubitium marked this pull request as ready for review November 29, 2026 20:15
@Qubitium
Qubitium merged commit 0d0b42a into main Nov 29, 2026
6 checks passed
@Qubitium
Qubitium deleted the refactor/exl3-drop-error-ledger branch November 29, 2026 20:15
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