Skip to content

8b: add deterministic GPU MoE routing - #29

Merged
feitreim merged 1 commit into
mainfrom
issue-25-gpu-moe-routing
Jul 18, 2026
Merged

feitreim merged 1 commit into
mainfrom
issue-25-gpu-moe-routing

Conversation

@feitreim

Copy link
Copy Markdown
Owner

Summary

  • add fp32 router logits, per-token softmax/top-k with lower-index tie-breaking, and Mixtral-style selected-probability renormalization to gpu/llama-ops
  • add deterministic token-order capacity assignment using one serial scan per expert, avoiding atomic slot claims and preserving CPU drop/slot decisions
  • add capacity-bin scatter, gated expert-output combine, expert-output-gradient scatter with gate dots, and expert-input-gradient gather
  • add routing backward through top-k renormalization and softmax with the runtime Switch-style auxiliary-loss coefficient, plus router input/weight backward kernels
  • expose CPU expert outputs to the GPU parity oracle and mark SPEC milestone 8b complete

Parity gates

The llama-ops harness now checks:

  • router logits, probabilities, selected experts, and gate weights against MoeFfn
  • exact deterministic slot/drop assignments with forced capacity overflow and an underfull expert
  • lower-index tie selection and token-order capacity behavior
  • scatter contents, zero-filled unused bins, scatter/gather round trips, and exact zero output for fully dropped tokens
  • expert-output gradient scatter, per-pair gate gradients, and expert-input gradient gather
  • router weight gradients including a nonzero auxiliary coefficient, plus router input gradients

Verification

  • cargo test --workspace
  • cargo clippy --workspace --all-targets -- -D warnings
  • B200: ./run.sh llama-ops — all forward/backward parity checks passed (Modal run)

SANITIZE=memcheck ./run.sh llama-ops was also attempted, but the sanitizer build is blocked before execution by cuda-oxide's existing legacy-NVVM inability to legalize the pre-existing embedding_backward_scatter atomic RMW (src/lib.rs:580). The normal Blackwell PTX build and parity run pass.

Closes #25

@feitreim
feitreim merged commit 3c085a2 into main Jul 18, 2026
@feitreim
feitreim deleted the issue-25-gpu-moe-routing branch July 18, 2026 18:31
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.

8b — GPU routing: fp32 top-k select + capacity-bin scatter/gather (gpu/llama-ops)

1 participant