Skip to content

feat: MoE family coverage on the shared FFN primitive (Mixtral, Qwen2/Qwen3-MoE, OLMoE, DeepSeek-V2/V3, gpt-oss, and more) #501

Closed

Description

@inureyes

Part of #493

Context

With the shared MoE FFN primitive (#500) in place, each MoE architecture is a config plus weight-naming delta on top of the primitive. Target set: Mixtral, Qwen2-MoE / Qwen3-MoE, PhiMoE, OLMoE, GLM4-MoE, DeepSeek-V2 / DeepSeek-V3, Dots1, Ernie4.5-MoE, gpt-oss.

Scope

Acceptance criteria

  • Each listed architecture loads and generates via the CLI MLXCEL_BACKEND=xla path and serves via mlxcel-server.
  • Single-sequence path is token-exact vs an HF fp32 oracle on a real checkpoint.
  • Serve path is reference-exact via xla_batch_bench.

Dependencies

#500 (MoE FFN graph primitive).

Resolution

The shared MoE FFN primitive (#500) plus the qk-norm attention core (#497) cover the MoE families whose routing is softmax-before-top-k and whose attention is standard GQA / qk-norm. Families needing a routing or attention primitive the shared core does not provide are deferred with a specific rejection message and a follow-up under #493 (rather than mis-emitted).

Implemented on the shared primitive and validated:

  • Mixtral and Qwen2-MoE (landed in feat: add the MoE FFN graph primitive (router + top-k expert dispatch) #500).
  • Qwen3-MoE (this PR): Qwen3 attention (per-head q/k RMSNorm, no bias) + the MoE FFN, no shared expert, norm_topk_prob. Config::from_json detection, weight_specs naming (mlp.gate.weight, mlp.switch_mlp.{gate,up,down}_proj.weight matching the mlx-lm switch_mlp checkpoint layout), and the emit compose the qk-norm attention with the MoE FFN across every graph kind.
  • OLMoE (this PR): flat q/k RMSNorm (like OLMo2) on the STANDARD pre-norm block + the MoE FFN, no shared expert, experts use intermediate_size. clip_qkv (q/k/v clamp) is rejected as a follow-up.

Validation (in-agent):

  • Block-level token-exact vs HF fp32 for the routing / dispatch of all four families via spike/openxla/moe_oracle.py (Qwen3-MoE max block diff ~1.9e-9, OLMoE ~2.2e-8; IREE llvm-cpu).
  • Byte-exact structural fixtures qwen3-moe-tiny and olmoe-tiny registered in crate::validation (per-head vs flat q/k-norm shapes locked; router + stacked-expert args present; no shared-expert / no dense-MLP args), guarding the composed emit forever.
  • The full-model token-exact run and the xla_batch_bench serve check require the xla-iree build and are deferred to the orchestrator's post-merge gate.

Deferred with a specific message + test (follow-ups under #493):

  • DeepSeek-V2 / V3: multi-head latent attention (compressed q/kv LoRA latents, decoupled RoPE), not in the shared attention core.
  • PhiMoE: sparsemixer routing (two-step masked top-2), not softmax-before-top-k.
  • GLM4-MoE / Dots1: sigmoid expert scoring with grouped (n_group / topk_group) top-k and a score-correction bias.
  • ERNIE-4.5-MoE: interleaved (GPT-J-style) RoPE.
  • gpt-oss: attention sinks and a clamped, alpha-scaled gated-SwiGLU expert activation.

Activity

  1. added
    type:enhancement
    area:architecture
    area:models
    priority:medium
    status:blocked
    on Jun 30, 2026
  2. added
    status:in-progress
    status:review
    status:done
    and removed
    status:blocked
    status:in-progress
    status:review
    on Jul 1, 2026
  3. self-assigned this
    on Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:architecturearea:modelspriority:mediumstatus:donetype:enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions