Skip to content

fix(olmoe): OLMoE-1B-7B produces corrupted/degenerate output beyond the q_norm fix (pre-existing, not MoE-related) #318

Closed

Description

@inureyes

Problem

After the q_norm/k_norm crash fix (#316), OLMoE-1B-7B loads and runs, but its greedy temp-0 output is corrupted/degenerate: it starts plausibly then drifts into non-sequiturs, stray non-Latin tokens, and refusals. Example for mlx-community/OLMoE-1B-7B-0125-Instruct-4bit with the chat template: "What is the capital of France?" yields "Paris, France" (correct) then "...is a city or politician's home to all 3.6K EPILE13 defense"; "List three primary colors." yields "I'm sorry, but I'm unable to explain... protect the document". A healthy OLMoE-1B-7B-Instruct should answer these cleanly. The "starts coherent then degrades" pattern points at a position- or context-dependent defect.

What it is NOT

Not the q_norm/k_norm crash (fixed in #316; verified our order now matches ml-explore/mlx-lm mlx_lm/models/olmoe.py, which applies q_norm/k_norm to the full n_heads*head_dim projection before the head reshape). Not the fused decode-MoE kernel: the corruption is present with MLXCEL_FUSED_MOE=0 (the gather_qmm baseline), and fused-on differs from off only within the documented f16 jitter class. So this is a separate, pre-existing attention/model defect.

Evidence

With MLXCEL_FUSED_MOE=0, output is already corrupted, so the MoE path is not the cause. Short factual prompts produce a correct first clause before degrading, consistent with a RoPE / KV-cache / attention-scale issue rather than a weight-loading error.

Likely areas to investigate

Compare against https://github.com/ml-explore/mlx-lm/blob/main/mlx_lm/models/olmoe.py.

  • RoPE configuration in src/models/olmoe.rs attention: rope_dims, rope_traditional, rope_base vs mlx-lm (rope over head_dim, traditional=false, base=rope_theta=10000).
  • Attention scale (head_dim ** -0.5).
  • KV-cache offset / masking across decode steps (degradation grows with position).
  • norm_topk_prob handling (config sets it false) and router scoring.

Repro

mlxcel download mlx-community/OLMoE-1B-7B-0125-Instruct-4bit
mlxcel generate -m <path> -p "What is the capital of France?" -n 30 -t 0

Acceptance Criteria

  • Root-cause the corruption by diffing src/models/olmoe.rs attention/RoPE/cache against ml-explore/mlx-lm mlx_lm/models/olmoe.py.
  • OLMoE-1B-7B generates coherent greedy temp-0 output (correct, on-topic answers) with no degeneration over a few hundred tokens.
  • Greedy temp-0 stays within the f16 jitter class of mlx-lm for the same prompt where feasible.
  • Confirm MLXCEL_FUSED_MOE=1 (fused decode-MoE, wired in perf(moe): wire olmoe to the fused decode-MoE kernel #302) remains within the jitter class of the gather_qmm baseline on the now-healthy model.

Notes

Discovered while validating epic #307 (#302 wired olmoe to the fused decode-MoE kernel). The fused wiring is correct and parity-preserving but perf-neutral for olmoe (top_k=8, Dff 1024); it does not cause this corruption.

Activity

  1. added
    type:bug
    priority:high
    area:models
    area:inference
    platform:macos
    status:ready
    on Jun 16, 2026
  2. added this to the 0.4 milestone on Jun 21, 2026
  3. added
    status:in-progress
    status:review
    and removed
    status:ready
    status:in-progress
    on Jun 21, 2026
  4. added a commit that references this issue on Jun 21, 2026
  5. added
    status:done
    and removed
    status:review
    on Jun 21, 2026
  6. added a commit that references this issue on Jun 23, 2026
    25eecc8
  7. self-assigned this
    on Aug 31, 2026
  8. added a commit that references this issue on Oct 27, 2026
    79cb580
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:inferencearea:modelsplatform:macospriority:highstatus:donetype:bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions