Skip to content

feat(exl3): retain restart-idempotent projection and route ledgers - #3592

Merged
Qubitium merged 14 commits into
ModelCloud:mainfrom
tpurtell:upstream/12-exl3-error-ledgers-20261108
Nov 9, 2026
Merged

Qubitium merged 14 commits into
ModelCloud:mainfrom
tpurtell:upstream/12-exl3-error-ledgers-20261108

Conversation

@tpurtell

@tpurtell tpurtell commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Expose projection/family error records, natural-route evidence, provenance compaction, atomic ledger publication, and restart-idempotent journals. Processor and writer wiring follows in later layers.

This is layer 12/36, extracted from an already-used fork for initial maintainer feedback. It depends on #3591. Review only this feature; the cross-fork Files changed view is cumulative because the PR targets upstream main.

Incremental change: 4 files, +1998/−0 lines, including carried tests and the mechanism reference. No merge is automatic. Review value and API shape first; substantial rework can follow that feedback.

Flow and existing-code boundary

flowchart TD
    S0["build_projection_record"]
    S1["append_exl3_error_journal"]
    S2["write_exl3_error_ledger"]
    E["OSError, ValueError"]
    S0 -->|"raises on rejected input/state"| E
    S1 -->|"raises on rejected input/state"| E
    style E fill:#fee,stroke:#b22
Loading
Before this extraction layer Carried implementation
API absent in the previous stack layer (path/symbol checked) gptqmodel/utils/exl3_error_ledger.py:642: build_projection_record
API absent in the previous stack layer (path/symbol checked) gptqmodel/utils/exl3_error_ledger.py:929: append_exl3_error_journal
API absent in the previous stack layer (path/symbol checked) gptqmodel/utils/exl3_error_ledger.py:995: write_exl3_error_ledger

Committed reference: docs/exl3-error-ledgers.md, linked from README. Class entry points/calls and rejected-state paths describe code present in this branch, rather than planned integrations.

Validation

Carried test files: tests/test_exl3_error_ledger.py

This packaging pass checked Python parsing, whitespace, dependency order and balanced Mermaid blocks. The author reports successful prior use of these features. Per the requested resource limit and feedback-first scope, existing model quantization, GPU/ROCm tests, heavyweight CPU workloads and full model benchmarks were not rerun; no new performance or model-accuracy claim is made. Tests accompanying earlier stack layers retain their previously reported results.

Serialize configs without the empty state-dict cleanup path and replace completed shard files atomically. Keep live config fields authoritative and preserve source-only extensions. Retain the previous shard on write failures.
Extract the existing working fork feature for first maintainer feedback. Preserve carried code and tests; limit validation to lightweight structural checks. See the linked mechanism reference for actual API/call and failure paths.
Extract the existing working fork feature for first maintainer feedback. Preserve carried code and tests; limit validation to lightweight structural checks. See the linked mechanism reference for actual API/call and failure paths.
- _bind_record hashed an existing record_sha256 field, so re-appending a
  bound record wrote a line that failed its own digest check on the next
  index rebuild. Strip the field before hashing so replay is idempotent.
- Evidence validators now raise ValueError (not AttributeError) for
  non-mapping input, matching the documented failure contract.
- Sort imports for the ruff gate.
- Skip the three census tests that call EXL3Processor zero-route methods;
  the processor wiring lands in a later stack layer and those tests fail
  on this branch.
- Add regression tests for the journal replay and non-mapping input.

@Qubitium Qubitium left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review (layer 12 only)

Reviewed the incremental layer-12 commit (ae172a5a6, 4 files, +1998) rather than the cumulative 27-file view. The ledger API is coherent and the tests are thorough. I pushed a fix commit (d2cc4e15e) with the following.

Fixed

  1. Journal replay could write an unverifiable line. _bind_record hashed an existing record_sha256, so re-appending a record read back from the journal produced a line that failed its own digest check on the next index rebuild:

    ValueError: EXL3 error journal record 2 failed its digest
    

    It now strips the field before hashing, so replay is idempotent. Regression test added.

  2. Validators raised AttributeError for non-mapping input. validate_route_evidence, validate_zero_route_recovery, and validate_zero_route_recovery_authorization now raise ValueError per the documented failure contract. Test added.

  3. Ruff I001 (import order) in both new files.

  4. Three tests fail on the PR head. tests/test_exl3_error_ledger.py calls EXL3Processor.plan_subset_zero_route_recovery, finish_subset_zero_route_recovery, and validate_subset_capture_readiness; none exist in this branch or main. Since the PR says processor wiring lands in a later layer, they are now skipped with a reason — please move them to the wiring layer rather than leaving them here.

Verification

tests/test_exl3_error_ledger.py: 22 passed, 3 skipped. ruff check clean on both files.

Remaining questions (not changed)

  • validate_zero_route_recovery_authorization only binds authorization_sha256 for immutable-family-join (it must equal the family-join digest). For content-bound-execution-upgrade it accepts any 64-hex value, so that kind is not actually content-bound. Is the digest meant to bind the authorization payload or an external upgrade artifact? If the former, the validator should recompute it.
  • write_exl3_error_ledger publishes the ledger and then the manifest as two separate atomic writes, with no directory fsync. A crash between them leaves a manifest pointing at a replaced ledger. Consider fsyncing the directory and defining the recovery contract.
  • _JOURNAL_INDEX is process-local; the file-identity cache can go stale if another process appends between the write and the post-write stat, which can duplicate a record. Is cross-process concurrent append in scope?
  • The PR is dirty against main; conflicts are expected for the cumulative stack, but the head no longer merges cleanly.

Nits

  • _finite_json_value stringifies dict keys, so {1: ...} and {"1": ...} silently collide.
  • _family_record assumes every projection has quantizer_metrics["reconstruction"]; write_exl3_error_ledger raises KeyError rather than a clear validation error when it is absent.

The branch predates the merge of layer 11 and other main work. Take main's
tree for the shared files and keep only the layer-12 ledger, docs, tests and
README reference.
@Qubitium
Qubitium marked this pull request as ready for review November 9, 2026 08:50
@Qubitium
Qubitium merged commit 9b15543 into ModelCloud:main Nov 9, 2026
Qubitium added a commit that referenced this pull request Nov 17, 2026
) (#4991)

Seven EXL3 tests carried an unconditional module-level
``pytest.mark.skip`` with "lands in a later stack layer" reasons from
#3592/#3594/#3599. That wiring landed long ago, so shipped code paths had
tests that pass but nobody ever ran.

- test_exl3_capture_frontier.py / test_exl3_error_ledger.py: drop the
  ``_processor_wiring_pending`` skip and its decorators; all four tests
  run and pass.
- test_quantize_config_offload_tempdir.py: drop two ``pytest.mark.skip``
  decorators; widen the two tiny ``nn.Linear(16, ...)`` layers to 128
  because EXL3 requires in_features to be a multiple of 128.
- kernels/test_kernel_compile_levels_quant.py: gate the Paro cases on
  ``awq_runtime_available()``/``awq_runtime_error()`` instead of
  ``CUDA_HOME`` plus an ``nvcc``-on-PATH probe, which misreported the
  runtime as available.
- Add tests/test_exl3_skip_reasons_4981.py, an AST guard that fails if
  any EXL3 test reintroduces an unconditional ``pytest.mark.skip``. A
  real precondition belongs in ``skipif`` with a precise reason.

The Machete JIT gate in test_machete_jit.py is deliberately left alone:
swapping the ``nvcc``-on-PATH probe for
``cuda_source_build_available()`` turns a skip into a failure on hosts
whose toolkit and headers disagree, which is worse than the status quo.

Fixes #4981
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.

2 participants