Skip to content

8a: add CPU reference MoE FFN - #28

Merged
feitreim merged 2 commits into
mainfrom
issue-24-cpu-moe
Jul 18, 2026
Merged

feitreim merged 2 commits into
mainfrom
issue-24-cpu-moe

Conversation

@feitreim

Copy link
Copy Markdown
Owner

Summary

  • add a statically-shaped MoeFfn<N, D, FF, E, K, C> with fp32 softmax top-k routing, deterministic lower-index tie-breaking, Mixtral-style selected-probability renormalization, and first-come capacity dispatch
  • compose each capacity-padded expert from the existing Linear and SwiGlu leaves, with complete backward paths for expert parameters, combine gates, router parameters/input, and Switch-style auxiliary load balancing
  • add MoeLlama as a one-block CPU integration that substitutes the MoE module for the dense FFN and reports cross entropy plus the runtime-weighted auxiliary loss
  • mark SPEC milestone 8a complete

Correctness gates

  • finite-difference checks for input, router weight, and every gate/up/down expert matrix
  • no-drop, forced-drop, and underfull-expert configurations with asserted top-k margins away from routing discontinuities
  • isolated router gate-path check with the auxiliary coefficient set to zero
  • deterministic routing and lower-index tie behavior
  • auxiliary-loss imbalance flattening against a zero-coefficient control
  • tiny-batch one-block MoeLlama overfit with nonzero auxiliary coefficient

Verification

  • cargo test --workspace
  • cargo clippy --workspace --all-targets -- -D warnings

Closes #24

@feitreim
feitreim merged commit dd0108d into main Jul 18, 2026
@feitreim
feitreim deleted the issue-24-cpu-moe branch July 18, 2026 18:18
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.

8a — CPU reference MoE FFN: router, capacity dispatch, aux loss (crates/nn)

1 participant