Skip to content

Add preliminary MiniMax-M3 support#1963

Merged
ikawrakow merged 3 commits into
ikawrakow:mainfrom
jkyamog:minimax-m3-support
Jun 15, 2026
Merged

Add preliminary MiniMax-M3 support#1963
ikawrakow merged 3 commits into
ikawrakow:mainfrom
jkyamog:minimax-m3-support

Conversation

@jkyamog

@jkyamog jkyamog commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Adds preliminary text-only MiniMax-M3 support to ik_llama.cpp, based on the public llama.cpp MiniMax-M3 implementation shape and adapted to ik's graph/tensor-loader structure.

This is intended as a basic enablement PR: load GGUF MiniMax-M3, run server inference, and support hybrid CPU/GPU expert placement. It does not attempt vision/MTP support or graph/attention split support for MiniMax-M3.

Main Changes

  • Adds LLM_ARCH_MINIMAX_M3 and architecture name mapping.
  • Adds MiniMax-M3 tensor-name mapping.
  • Adds MiniMax-M3 hparam loading for:
    • leading dense block count
    • expert FFN size
    • shared expert count
    • expert weight scale/norm/gating function
  • Adds MiniMax-M3 tensor creation:
    • per-head Q/K norms
    • leading dense FFN layers
    • routed experts
    • shared experts
  • Adds build_minimaxm3() graph:
    • RMS attention norm
    • Q/K per-head RMSNorm before partial RoPE
    • dense leading FFN via ggml_swiglu_oai
    • routed MoE via LLM_FFN_SWIGLU_OAI_MOE
    • shared expert FFN via ggml_swiglu_oai
  • Updates fused MoE helper routing so LLM_FFN_SWIGLU_OAI_MOE uses ggml_moe_up_gate_ext() instead of the unsupported fused path variant.

Validation Performed

  • CPU build of llama-server completed successfully.
  • Docker CUDA image built successfully from the patched tree.
  • MiniMax-M3 Q4 server loaded successfully with 128k context.
  • Using Pinchbench tasks (0-17 task) to verify it works.

Runtime Notes

On a single 32GB V100 with MiniMax-M3 Q4 and CTX_SIZE=131072:

  • All MoE on CPU works.
  • Partial GPU MoE requires disabling current fused MoE CUDA paths:
    • --no-fused-moe
    • --no-fused-up-gate
    • --no-fused-mul-multiadd
  • Without those flags, CUDA fused MoE hits an assertion because the current fused kernel path accepts SILU/RELU/GELU but not GGML_UNARY_OP_SWIGLU_OAI.
  • Two GPU expert layers fit at 128k context on this V100, ending around 30.4GB used / 2.1GB free.

Known Limitations

  • Text-only preliminary support.
  • Split mode graph/attention is not implemented in the MiniMax-M3 graph builder.
  • Fused CUDA MoE support for GGML_UNARY_OP_SWIGLU_OAI remains future work.

@jkyamog jkyamog marked this pull request as draft June 14, 2026 12:31
@jkyamog

jkyamog commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

This is just based on ggml-org/llama.cpp#24523 and I just pointed codex is implement m3 support for ik_llama.cpp. Please kindly test, I haven't extensively tested this yet but so far its seems to work.

@ikawrakow

Copy link
Copy Markdown
Owner

I tested quickly, it seems to work. One should change the graph building to use standard ik_llama.cpp facilities, but I can do that after merging. Why is the PR marked ad draft?

@jkyamog jkyamog force-pushed the minimax-m3-support branch from 41d8c56 to c538210 Compare June 15, 2026 01:58
@jkyamog jkyamog marked this pull request as ready for review June 15, 2026 02:42
@jkyamog

jkyamog commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

I tested quickly, it seems to work. One should change the graph building to use standard ik_llama.cpp facilities, but I can do that after merging. Why is the PR marked ad draft?

Thanks for testing. I haven't really coded in c++ for over 3 decades, I can just vaguely understand c++ but ik_llama.cpp code base is much more advance than what I am comfortable understanding fully. Anyway I have done more testing a few improvements since:

  • I added a working template, so Minimax 3 can use tools. After testing with openclaw I needed to get the tool call working.
  • I got your comment above and fed it to codex, it has now refactored to use the ik_llama.cpp facilities which in my opinion is much better. Hopefully this saves some time.

I have now set this PR for review.

@ikawrakow ikawrakow left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split mode graph does not work, but I'll fix it in a separate PR.

@ikawrakow ikawrakow merged commit 567854a into ikawrakow:main Jun 15, 2026
@jkyamog jkyamog deleted the minimax-m3-support branch June 21, 2026 09:43
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.

2 participants