Skip to content

Epic: Engine Inference Core Stage E - MoE + hybrid families #56

Description

@tlkahn

Epic: Stage E - MoE + hybrid families

The two non-dense forward paths from the reference: forwardMoeWith (expert dispatch via mlx_gather_qmm/mlx_gather_mm) and forwardHybridWith (conv/SSM layers with their own cache entries). Green + demoable: all remaining generate families pass parity gates.

Spec: doc/plans/engine-inference-core.md § Stage E

Part of: #51
Depends on: Stage D (#55, done)

Decision 5 superseded (2026-07-20): mlx-lm implements DeepSeek V3/V3.2/V4 natively on MLX using safetensors with standard mlx ops - no GGUF or ds4 engine needed. Port from mlx-lm's deepseek_v3.py / deepseek_v32.py + mla.py, not from ds4.zig. Target checkpoint: mlx-community/DeepSeek-V4-Flash-4bit. The Stage A safetensors loader works. Also: qwen3_5_moe is the separate MODEL_QWEN3_5_MOE enum value from Stage A1. See spec - Resolved design decisions.

Decision 11 (2026-07-20): do not collapse DeepSeek variants into MODEL_DEEPSEEK_V4. mlx-lm keeps separate modules; V3.2 adds a DSA Indexer + dual cache (real forward/cache fork). Enum grain:

  • deepseek_v3 -> MODEL_DEEPSEEK_V3 (MLA + MoE)
  • deepseek_v3_2 / deepseek_v32 -> MODEL_DEEPSEEK_V32 (MLA + MoE + DSA)
  • deepseek_v4 -> MODEL_DEEPSEEK_V4 (own value; characterize Flash before any alias)

Shared code is primitives (fwd_mla_*, MoE gate, sanitize), not one family tag. A1 interim debt still maps all four strings to MODEL_DEEPSEEK_V4 - correct before or at start of E2 (#109). Reject messages must name the actual family.


Phases

E1 - MoE infrastructure

E2 - DeepSeek V3 / V3.2 / V4 (MLA + MoE; separate families)

E3 - qwen3_5_moe, lfm2, nemotron_h


Dependency sketch

E1 (#104)
 ├─ #107 fwd_moe
 └─ #108 DeepSeek MoE gate
        │
        ▼
E2 (#105) ─────────────────────────────────────┐
 ├─ #109 family split + config (first)          │
 ├─ #110 MultiLinear ──► #111 MLA+cache         │
 ├─ #112 sanitize                               │
 ├─ #113 V3 forward ◄── E1, #111, #112          │
 ├─ #114 V3.2 DSA ◄── #111, #113                │
 ├─ #115 V4 ◄── #113 (+ characterization)       │
 └─ #116 parity ◄── as families land            │
                                                 │
E3 (#106)  (MoE part needs E1; hybrid is local) │
 ├─ #117 hybrid cache + gate unify              │
 ├─ #118 qwen3_5_moe ◄── E1, #117               │
 ├─ #119 lfm2 ◄── #117                          │
 ├─ #120 nemotron_h ◄── #117                    │
 └─ #121 parity ◄── as families land            │

Tracking notes (from prior #56 comments)

Out of scope (still under #51, not Stage E)

Metadata

Metadata

Assignees

Labels

engine-inferenceEngine inference core (issue #51) feature areaenhancementNew feature or requestepic

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions