Skip to content

feat(deepseek): carry V4.1 routed capture and adjacent recovery - #3614

Merged
Qubitium merged 1 commit into
ModelCloud:mainfrom
tpurtell:upstream/34-v41-routed-calibration-20261108
Nov 9, 2026
Merged

Qubitium merged 1 commit into
ModelCloud:mainfrom
tpurtell:upstream/34-v41-routed-calibration-20261108

Conversation

@tpurtell

@tpurtell tpurtell commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Carry bounded expert Hessian and natural-route capture, validated routed calibration batches, adjacent-router recovery, phase-specific frontier reuse, and packed selected-projection replay.

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

Incremental change: 6 files, +419/−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["V41Capture"]
    M0_0["V41Capture.__init__"]
    M0_1["V41Capture.__enter__"]
    M0_2["V41Capture.capture_routed"]
    S1["V41Recovery"]
    M1_0["V41Recovery.__init__"]
    M1_1["V41Recovery.__enter__"]
    S2["V41RoutedBatch"]
    M2_0["V41RoutedBatch.validate"]
    S3["install_projection"]
    E["Captured, RuntimeError, ValueError"]
    S0 -. "exposes" .-> M0_0
    S0 -. "exposes" .-> M0_1
    S0 -. "exposes" .-> M0_2
    S0 -->|"raises on rejected input/state"| E
    S1 -. "exposes" .-> M1_0
    S1 -. "exposes" .-> M1_1
    S1 -->|"raises on rejected input/state"| E
    S2 -. "exposes" .-> M2_0
    S2 -->|"raises on rejected input/state"| E
    S3 -->|"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/v41_capture.py:11: V41Capture
API absent in the previous stack layer (path/symbol checked) gptqmodel/utils/v41_recovery.py:15: V41Recovery
API absent in the previous stack layer (path/symbol checked) gptqmodel/utils/v41_routed_batch.py:10: V41RoutedBatch
API absent in the previous stack layer (path/symbol checked) gptqmodel/utils/v41_mixed_replay.py:10: install_projection

Committed reference: docs/v41-routed-calibration.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: No standalone test file existed in the fork for this helper; retained original implementation and documented the structural checks.

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.

V4.1 remains an explicit native calibration/replay API and is not added to MODEL_MAP. The source requires its native/reference implementation; upstream inventory documentation alone does not provide that runtime.

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.
@Qubitium
Qubitium force-pushed the upstream/34-v41-routed-calibration-20261108 branch from e34b9c8 to dbf2f72 Compare November 9, 2026 09:59

@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.

Reviewed against current main.

The routed-capture layer is correctly separated from post-quantization propagation:

  • V41RoutedBatch is an owned CPU frontier (hidden, logits, weights, indices) and validate checks matrix geometry, finite floating values, expert-index bounds, and duplicate assignments per row.
  • from_replay registers a gate hook, copies the gate output through owned_tree, then raises a private Captured exception to stop the block before any expert GEMMs; the hook is removed in finally and the frontier must be captured exactly once. That keeps every expert subset on identical normalized FFN inputs and natural routes.
  • v41_capture, v41_recovery, and v41_mixed_replay carry the adjacent-recovery and mixed-tier replay pieces without duplicating the source or replay modules.

Validation note: this layer adds no tests of its own. All four modules import cleanly on the installed stack, and cleanup was limited to dict(...)/dict.fromkeys style.

No blocking issues found.

@Qubitium
Qubitium marked this pull request as ready for review November 9, 2026 09:59
@Qubitium
Qubitium merged commit 376292a into ModelCloud:main Nov 9, 2026
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