Skip to content

feat(exl3): integrate resumable distributed and mixed-tier execution - #3601

Merged
Qubitium merged 2 commits into
ModelCloud:mainfrom
tpurtell:upstream/21-exl3-durable-execution-20261108
Nov 9, 2026
Merged

Qubitium merged 2 commits into
ModelCloud:mainfrom
tpurtell:upstream/21-exl3-durable-execution-20261108

Conversation

@tpurtell

@tpurtell tpurtell commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Wire the preceding stores and policies into EXL3Processor: natural-route capture, batch/frontier restore, deterministic recovery, projection checkpoint hits, remote slots, inline tier upgrades, bounded runtime replay, and completed checkpoint-tree publication. This is the larger integration layer; the preceding feature APIs remain individually reviewable.

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

Incremental change: 8 files, +5392/−84 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["EXL3Processor"]
    M0_0["EXL3Processor.__init__"]
    M0_1["EXL3Processor.restore_subset_capture_batches"]
    M0_2["EXL3Processor.forward_committed_batch_indices"]
    S1["_EXL3NaturalRouteCapture"]
    M1_0["_EXL3NaturalRouteCapture.__init__"]
    M1_1["_EXL3NaturalRouteCapture.__enter__"]
    M1_2["_EXL3NaturalRouteCapture.capture_expert_input"]
    S2["clone_exllamav3_config_for_module"]
    E["NotImplementedError, RuntimeError, ValueError"]
    S0 -. "exposes" .-> M0_0
    S0 -. "exposes" .-> M0_1
    S0 -. "exposes" .-> M0_2
    S0 -->|"calls where selected"| S1
    S0 -->|"calls where selected"| S2
    S0 -->|"raises on rejected input/state"| E
    S1 -. "exposes" .-> M1_0
    S1 -. "exposes" .-> M1_1
    S1 -. "exposes" .-> M1_2
    S1 -->|"raises on rejected input/state"| E
    style E fill:#fee,stroke:#b22
Loading
Before this extraction layer Carried implementation
Previous stack layer: gptqmodel/looper/exllamav3_processor.py:91 gptqmodel/looper/exllamav3_processor.py:704: EXL3Processor
API absent in the previous stack layer (path/symbol checked) gptqmodel/looper/exllamav3_processor.py:268: _EXL3NaturalRouteCapture
Previous stack layer: gptqmodel/looper/exllamav3_processor.py:57 gptqmodel/looper/exllamav3_processor.py:668: clone_exllamav3_config_for_module

Committed reference: docs/exl3-durable-execution.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_projection_resume.py, tests/test_exl3_route_evidence.py, tests/test_exl3_hessian_owner_policy.py, tests/test_exllamav3.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.

tpurtell and others added 2 commits November 9, 2026 09:24
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.
- The processor imports QUANT_LOG_LOSS_KIND from models.writer, but that
  constant lands in a later layer; define it here so the module imports.
- Satisfy the ruff gate (import order, set comprehension).
@Qubitium
Qubitium force-pushed the upstream/21-exl3-durable-execution-20261108 branch from 2e03c40 to 7b13cb2 Compare November 9, 2026 09:25

@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 21)

Reviewed the incremental layer-21 commit (2e03c4054, 8 files, +5392/−84) after rebasing onto current main. This is the integration layer that wires the earlier ledger, capture-frontier, batch-spool, inline-mixed, router-candidate, and remote-worker pieces into EXL3Processor. I pushed a fix commit (7b13cb2f1).

Fixed

  1. Missing writer constant. exllamav3_processor.py imports QUANT_LOG_LOSS_KIND from models.writer, but that constant is introduced by layer 22, so the module (and all three new test files) failed to import. Defined QUANT_LOG_LOSS_KIND = "loss_kind" in this layer; layer 22's addition will be a no-op on rebase.
  2. Ruff gate (import ordering, set comprehension).
  3. The duplicate _default_cuda_workers hunk was dropped during the rebase because current main already has it from layer 20.

Verification

tests/test_exl3_hessian_owner_policy.py, tests/test_exl3_projection_resume.py, tests/test_exl3_route_evidence.py, tests/test_exllamav3.py: 42 passed, 2 skipped. ruff check clean.

Notes

  • The processor diff is ~3,770 lines in one layer. It works and is carried from the fork, but it is the hardest piece to review; a follow-up split (route/recovery wiring vs. checkpoint/resume wiring) would make future changes tractable.
  • The three new test files exercise the earlier layers' APIs end-to-end, which is valuable; they now pass on the rebased tree.

@Qubitium
Qubitium marked this pull request as ready for review November 9, 2026 09:25
@Qubitium
Qubitium merged commit f293733 into ModelCloud:main Nov 9, 2026
Qubitium added a commit that referenced this pull request Nov 17, 2026
…ract

Upstream moved under several MLX tests; repair the oracles that pinned the
retired behaviour instead of loosening them:

- `test_mlx_exl3_pipeline.py`: #3601 removed `EXL3Processor`'s CPU/Metal MLX
  quantization branch and `models/base.py` already rejects EXL3 quantization
  without CUDA, so drop `test_exl3_processor_routes_cpu_quantization_through_mlx`
  and keep one contract test that a CPU target raises. The zero-Hessian
  fallback now reports the normalized reconstruction error as its proxy error,
  so compare it to the oracle (and assert both sides took the fallback) rather
  than asserting zero.
- `test_mlx_qwen38_27b_shapes.py`: the QQQ dynamic-input oracle narrowed BF16
  activations to FP16 and cast the epilogue early, which #4537/#4534 no longer
  do. Consume the resident inputs, cast once, and allow one output ULP of the
  activation dtype (8e-3 bf16 / 2e-3 fp16).
- `test_mlx_qqq_quantization.py`: `scale_extra` is fitted to the produced
  codes, so a documented one-step tie flip moves it by at most one group
  scale. Compare exactly on rows without code drift, bound the drift elsewhere,
  and require the exported scale to describe the emitted codes.
- `test_mlx_awq_variants.py`: the Torch GEMV_FAST/LLM_AWQ sources require
  group_size 128 and 128-aligned out_features (#3717); fall back to the MLX
  holder as the packed source for the combinations the Torch contract rejects,
  and allow one activation-dtype ULP (bf16 is 2**-7 relative, not 2e-3).
- `test_mlx_foem_quantization.py`: native processors read routing metadata from
  `NamedModule`, so wrap the probe layer.
- `test_mlx_qqq_processor.py`: `__init__` records the requested backend; set
  `BACKEND.AUTO` so the portable Torch holder is the expected macOS choice.
- `test_mlx_dense_methods.py` / `test_mlx_method_selection.py`: the MLX BNB
  holder reuses `BitsAndBytesLinear`'s dependency probe, so skip without
  `bitsandbytes` installed instead of failing on the import.

Full MLX suite (tests/test_*mlx*.py tests/test_q4_torch_apple.py
tests/test_pack_block_batched.py): 5377 passed, 83 skipped, 5 failed. The five
failures need `/monster/data/model/...` checkpoints that are absent here
(`test_mlx_generate` and the four `test_q4_torch_apple` generation tests) and
are unrelated to these changes.
Qubitium added a commit that referenced this pull request Nov 17, 2026
…aded weights (#4687)

* fix(paroquant): mirror the Torch affine grid fit in the MLX bridge

The MLX optimizer still fitted asymmetric qparams with `(max - min) / qmax`
and returned `minimum / scale` as the zero point, the formula the Torch
reference retired in #4160/#4165. A one-sided or constant group has no
representable zero point in that grid, so every value clipped onto code 0 or
qmax and the group collapsed to a single code. The optimizer could not repair
it: the affine straight-through gradient with respect to the zero point
cancels exactly, so the drift was silent.

Port `_calc_affine_qparams` line for line: include zero in the fitted range,
round the integer zero point onto that grid, re-fit the scale per side from the
remaining code budget, then clamp. The bridge keeps its existing contract of
returning `-zero_point`, which `_pseudo_quantize` and the runtime packer both
consume.

Tests (tests/test_mlx_paroquant_optimize.py):
- new `test_paroquant_mlx_affine_qparams_match_torch_reference[2,4,8]` fits
  positive-only, negative-only, balanced and constant groups, requires exact
  scale/zero parity with `_calc_affine_qparams`, exact `_pseudo_quantize`
  parity with `pseudo_quantize_dequant`, and asserts the one-sided groups use
  more than two codes;
- new `test_paroquant_mlx_affine_qparams_promote_low_precision_weights[fp16,bf16]`
  pins the fp32 promotion the callers rely on;
- the Qwen3.8 export oracle now derives its expected qparams from
  `_calc_affine_qparams` instead of re-deriving the retired formula, and the
  processor monkeypatches target the lazily imported
  `gptqmodel.quantization.mlx_paroquant_optimize` module;
- `test_paroquant_mlx_trained_quality_tracks_torch` now bounds the documented
  Adam `sqrt(v) + eps` amplification of a float32-noise-floor gradient entry
  instead of a flat 2e-3 maximum that failed on a single tie flip.

Red evidence with the retired fit restored: 5 failed, 49 deselected
(`-k affine_qparams`). Green after the fix: 5 passed; whole module 54 passed.

* fix(pack_block): accept inference-mode-loaded weights

`pack_block` slices the caller's weight, but a weight can arrive without a
version counter even though it is not flagged as an inference tensor:
`load_state_dict(assign=True)` under `torch.inference_mode()` followed by
`module.to(dtype)` materializes exactly that tensor on recent Torch. Slicing it
raises `RuntimeError: Inference tensors do not track version counter` and the
pack fails during quantization.

After moving the weight to the host, probe `_version` and materialize a copy
when the probe raises. `pack_block` already runs under `inference_mode()`, so
the copy follows the active mode and is sliceable; the caller's tensor is
never mutated.

Test: `test_pack_block_accepts_inference_mode_loaded_weights[2,3,4,8]` builds
the poisoned tensor through that loader transition, asserts the trigger
(`not is_inference()` yet `_version` raises), then requires bit-exact parity
with a version-tracked control and the independent word oracle, plus an
unchanged caller weight.

Red evidence with the guard removed: 4 failed, 50 deselected
(`-k inference_mode`). Green after the fix: module 54 passed.

* test(mlx): repair stale oracles, backend skips, and the EXL3 CPU contract

Upstream moved under several MLX tests; repair the oracles that pinned the
retired behaviour instead of loosening them:

- `test_mlx_exl3_pipeline.py`: #3601 removed `EXL3Processor`'s CPU/Metal MLX
  quantization branch and `models/base.py` already rejects EXL3 quantization
  without CUDA, so drop `test_exl3_processor_routes_cpu_quantization_through_mlx`
  and keep one contract test that a CPU target raises. The zero-Hessian
  fallback now reports the normalized reconstruction error as its proxy error,
  so compare it to the oracle (and assert both sides took the fallback) rather
  than asserting zero.
- `test_mlx_qwen38_27b_shapes.py`: the QQQ dynamic-input oracle narrowed BF16
  activations to FP16 and cast the epilogue early, which #4537/#4534 no longer
  do. Consume the resident inputs, cast once, and allow one output ULP of the
  activation dtype (8e-3 bf16 / 2e-3 fp16).
- `test_mlx_qqq_quantization.py`: `scale_extra` is fitted to the produced
  codes, so a documented one-step tie flip moves it by at most one group
  scale. Compare exactly on rows without code drift, bound the drift elsewhere,
  and require the exported scale to describe the emitted codes.
- `test_mlx_awq_variants.py`: the Torch GEMV_FAST/LLM_AWQ sources require
  group_size 128 and 128-aligned out_features (#3717); fall back to the MLX
  holder as the packed source for the combinations the Torch contract rejects,
  and allow one activation-dtype ULP (bf16 is 2**-7 relative, not 2e-3).
- `test_mlx_foem_quantization.py`: native processors read routing metadata from
  `NamedModule`, so wrap the probe layer.
- `test_mlx_qqq_processor.py`: `__init__` records the requested backend; set
  `BACKEND.AUTO` so the portable Torch holder is the expected macOS choice.
- `test_mlx_dense_methods.py` / `test_mlx_method_selection.py`: the MLX BNB
  holder reuses `BitsAndBytesLinear`'s dependency probe, so skip without
  `bitsandbytes` installed instead of failing on the import.

Full MLX suite (tests/test_*mlx*.py tests/test_q4_torch_apple.py
tests/test_pack_block_batched.py): 5377 passed, 83 skipped, 5 failed. The five
failures need `/monster/data/model/...` checkpoints that are absent here
(`test_mlx_generate` and the four `test_q4_torch_apple` generation tests) and
are unrelated to these changes.

* test(mlx): pin idempotent re-export of the Gemma 3 split

`normalize_mlx_rope_config` mutates in place and runs on every export, so a
config that was already translated must not accumulate `rope_scaling` or lose
`rope_local_base_freq` on the second pass. The existing idempotency test only
covered the flat Llama path; cover the split mapping too.
Qubitium added a commit that referenced this pull request Nov 29, 2026
#6399)

f293733 (#3601) carried a completed-checkpoint-tree restore layer from
the ds4rt working fork into EXL3Processor. The later looper and model
layers that were meant to call it never landed. Nothing in gptqmodel/,
scripts/, docs/ or tools/ calls it; only tests/test_exl3_projection_resume.py
did.

Removed from gptqmodel/looper/exllamav3_processor.py:
- completed_layer_checkpoint_entries, _completed_checkpoint_tree_entries
- restore_completed_checkpoint_tree_if_complete (built a processor with
  cls.__new__ and skipped __init__)
- restore_completed_layer_checkpoints, defer_completed_layer_checkpoints,
  offload_restored_layer_checkpoints
- release_host_memory and its only helper _malloc_trim, and
  discard_capture_frontiers_through
- the seven imports that only these methods used

Also removed: the seven tests that called these methods, the
release_host_memory tail of the capture-memory-summary test (the summary
assertions stay), and the "completed checkpoint-tree publication" phrase
in docs/exl3-durable-execution.md.

This does not touch the live EXL3 paths: projection-checkpoint hits in
_process_on_slot, capture frontiers, batch spool, inline mixed tiers,
zero-route recovery, remote slots and deferred runtime weights. The
quantization_layer_boundary_checkpoint protocol is also left alone; it
moves into LoopExtensions in a separate PR. In-tree runtime behaviour
does not change.

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

Development

Successfully merging this pull request may close these issues.

2 participants