Skip to content

feat(models): expose Dots3 Note routed experts individually - #3605

Merged
Qubitium merged 1 commit into
ModelCloud:mainfrom
tpurtell:upstream/25-dots3-separate-experts-20261108
Nov 9, 2026
Merged

Qubitium merged 1 commit into
ModelCloud:mainfrom
tpurtell:upstream/25-dots3-separate-experts-20261108

Conversation

@tpurtell

@tpurtell tpurtell commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Register Dots3 Note with separate per-expert checkpoint names, native top-k scatter, auxiliary tensor passthrough, and grouped-router recovery. Preserve the existing model adapter; do not refactor the expert implementation in this extraction.

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

Incremental change: 8 files, +195/−1 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["Dots3NoteQModel"]
    M0_0["Dots3NoteQModel.before_model_load"]
    M0_1["Dots3NoteQModel.after_model_load"]
    M0_2["Dots3NoteQModel.zero_route_recovery_context"]
    S1["_SeparateDots3Experts"]
    M1_0["_SeparateDots3Experts.__init__"]
    M1_1["_SeparateDots3Experts.forward"]
    E["IndexError, RuntimeError"]
    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
    style E fill:#fee,stroke:#b22
Loading
Before this extraction layer Carried implementation
API absent in the previous stack layer (path/symbol checked) gptqmodel/models/definitions/dots3_note.py:44: Dots3NoteQModel
API absent in the previous stack layer (path/symbol checked) gptqmodel/models/definitions/dots3_note.py:13: _SeparateDots3Experts

Committed reference: docs/dots3-separate-experts.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/module_tree/test_dots3_note_fork_plan.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.

New registrations include explicit module-plan inventory entries, targeted plan tests and unqualified fusion entries. Three model-specific plan tests plus the selected registry/consumer metadata cases passed as part of the 10-test CPU metadata group; actual checkpoint/hardware tests were not rerun.

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/25-dots3-separate-experts-20261108 branch from 53677b6 to 5b50937 Compare November 9, 2026 09:47

@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 separate-expert adapter is sound:

  • _SeparateDots3Experts replaces the upstream stacked projection with one Dots3NoteTextMLP per routed expert, so named_modules() exposes .experts.<id>.<proj> and each expert can own its Hessian/EXL3 payload. The forward scatters only the experts the router actually selected (torch.unique(top_k_index)), which keeps a 256-expert calibration forward bounded, and it validates out-of-range ids.
  • before_model_load swaps the Transformers class and guards _init_weights for the already-initialized per-expert Linears; after_model_load binds learned-router recovery and fails closed when the patched router count does not match the sparse layer count.
  • out_of_model_tensors retains the vision/audio/MTP and extra-layer tensors that the text-only calibration shell does not instantiate, which is required for a usable vLLM export.
  • The module_tree entry uses experts: {"#": (...)}, matching the per-expert layout, and the registered-plan/fusable fixtures were updated consistently.

Cleanup: import ordering in the new definition.

Environment note (non-blocking): transformers.models.dots3_note is not present in the installed Transformers 5.22.1, so the definition is forward-looking for the Transformers version that ships this model. The module-tree plan tests do not import it and pass.

Validation: ruff check clean; pytest tests/module_tree/test_dots3_note_fork_plan.py tests/module_tree/test_registered_module_plans.py tests/module_tree/test_fusable_models.py reports 769 passed.

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