Skip to content

feat(moe): expose ranked router candidates for route recovery - #3596

Merged
Qubitium merged 17 commits into
ModelCloud:mainfrom
tpurtell:upstream/16-exl3-router-recovery-20261108
Nov 9, 2026
Merged

Qubitium merged 17 commits into
ModelCloud:mainfrom
tpurtell:upstream/16-exl3-router-recovery-20261108

Conversation

@tpurtell

@tpurtell tpurtell commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Preserve native live top-k choices at tied boundaries while exposing ranked softmax and grouped-sigmoid candidates for bounded recovery. Model bindings are introduced with the model integrations.

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

Incremental change: 4 files, +421/−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["learned_router_ranked_choices"]
    S1["bind_softmax_router_recovery"]
    S2["bind_sigmoid_grouped_router_recovery"]
    E["RuntimeError, ValueError"]
    S0 -->|"raises on rejected input/state"| E
    S1 -->|"raises on rejected input/state"| E
    S2 -->|"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_router_candidates.py:79: learned_router_ranked_choices
API absent in the previous stack layer (path/symbol checked) gptqmodel/utils/exl3_router_candidates.py:225: bind_softmax_router_recovery
API absent in the previous stack layer (path/symbol checked) gptqmodel/utils/exl3_router_candidates.py:238: bind_sigmoid_grouped_router_recovery

Committed reference: docs/exl3-router-recovery.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_router_candidates.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.
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.
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.

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

Reviewed the incremental layer-16 commit (d27c77f53, 4 files, +421). The fail-closed score-function binding, live top-k verification, and tied-boundary handling are correct; the live selection is used as the authoritative prefix and only the remaining experts are ranked. No implementation bugs found, so I did not push code changes.

Verification

tests/test_exl3_router_candidates.py: 6 passed. ruff check clean.

Notes (not changed)

  • selected_indices is validated for dtype/shape but not range; an out-of-range live index would surface as IndexError from gather rather than the module's RuntimeError. A min()/max() check would keep the failure contract consistent.
  • _apply_group_policy assumes GLM's top-2-per-group score; that is correct for the bound router but is not parameterized by the policy contract.
  • has_learned_router_recovery requires a correction bias for grouped routers; a grouped router without one would be reported as unsupported even if it binds a score function.

@Qubitium
Qubitium marked this pull request as ready for review November 9, 2026 09:02
@Qubitium
Qubitium merged commit 4e87213 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