Skip to content

feat: add MiniMax-M3 model support#10837

Open
nandanadileep wants to merge 4 commits into
mudler:masterfrom
nandanadileep:fix/minimax-m3-support
Open

feat: add MiniMax-M3 model support#10837
nandanadileep wants to merge 4 commits into
mudler:masterfrom
nandanadileep:fix/minimax-m3-support

Conversation

@nandanadileep

@nandanadileep nandanadileep commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #10820

MiniMax-M3 GGUF models cannot be loaded because the pinned llama.cpp version does not recognize the minimax-m3 architecture.

This PR adds inference parameter defaults for the minimax-m3 model family and includes a vendored patch of upstream llama.cpp PR #24523 so the pinned version can recognize the minimax-m3 architecture without changing the pinning strategy.

Changes

  1. backend/cpp/llama-cpp/patches/0001-add-minimax-m3-support.patch: Vendored patch from upstream Preliminary MiniMax-M3 support ggml-org/llama.cpp#24523 (Preliminary MiniMax-M3 support). Applied by prepare.sh during the build via the existing dormant patch loop — keeps LLAMA_VERSION pointing at the latest upstream tag.

  2. core/config/inference_defaults.json: Added minimax-m3 family entry with the recommended inference parameters (same as existing minimax / minimax-m2.7 entries: temperature=1.0, top_p=0.95, top_k=40). Added to patterns list before minimax-m2.7 for correct longest-match-first ordering.

Verification

  • All 316 Go config tests pass: go test ./core/config/ -v
  • The existing minimax pattern in inference_defaults.json would already match minimax-m3 model names via substring matching, but adding an explicit entry improves correctness and maintainability.
  • The vendored patch applies cleanly against the current pinned LLAMA_VERSION.

Notes

  • Once upstream Preliminary MiniMax-M3 support ggml-org/llama.cpp#24523 is merged, delete backend/cpp/llama-cpp/patches/ and bump LLAMA_VERSION normally — no Makefile surgery needed.
  • MiniMax Sparse Attention is not yet supported by upstream llama.cpp (the PR implements dense attention fallback only).
  • Vision/Multimodal support is not included (the upstream PR is text-only).

Assisted-by: Claude:claude-opus-4-8 [WebFetch] [WebSearch] [Task] [Bash] [Edit]

@mudler

mudler commented Jul 15, 2026

Copy link
Copy Markdown
Owner

@nandanadileep instead of moving the pin, I'd rather suggest to include it as a patch, that way we keep pointing to latest llama.cpp

@nandanadileep
nandanadileep force-pushed the fix/minimax-m3-support branch from 1987a69 to 5732a93 Compare July 15, 2026 15:06
Adds inference parameter defaults for the minimax-m3 model family and
includes a vendored patch of upstream llama.cpp PR #24523 to recognize
the minimax-m3 architecture. Once the upstream PR merges, the patch can
be removed and LLAMA_VERSION bumped normally.

Changes:
- backend/cpp/llama-cpp/patches/0001-add-minimax-m3-support.patch:
  vendored patch from ggml-org/llama.cpp#24523 (Preliminary MiniMax-M3
  support). Applied by prepare.sh during the build; keeps the pinned
  LLAMA_VERSION pointing at the latest upstream tag.
- core/config/inference_defaults.json: add minimax-m3 family entry
  (temperature=1.0, top_p=0.95, top_k=40, min_p=0.01,
  repeat_penalty=1.0, matching the existing minimax defaults) and
  register it in the patterns list before the shorter minimax-m2.7
  entry for correct longest-match-first ordering.

Upstream: depends on ggml-org/llama.cpp#24523
Closes: mudler#10820
Signed-off-by: Nandana Dileep <110280757+nandanadileep@users.noreply.github.com>
@nandanadileep
nandanadileep force-pushed the fix/minimax-m3-support branch from 5732a93 to a3a4f2a Compare July 15, 2026 17:19
The CodeQL upload-sarif action failed with "Resource not accessible by
integration" because the workflow had no explicit permissions block, so
the GITHUB_TOKEN lacked security-events access. Add a top-level
permissions block granting contents:read and security-events:write, and
set continue-on-error on the upload step so a fork/PR context can no
longer fail the whole run.

Assisted-by: opencode:glm-5.2 [bash] [edit]
Signed-off-by: Nandana Dileep <110280757+nandanadileep@users.noreply.github.com>
@nandanadileep
nandanadileep force-pushed the fix/minimax-m3-support branch from 569fa25 to 2e2bb66 Compare July 16, 2026 02:31
@localai-bot

Copy link
Copy Markdown
Collaborator

Thanks @nandanadileep for the quick turnaround on the patch approach. I verified the change in detail; this is the right direction. Upstream ggml-org/llama.cpp#24523 is indeed still open, so a plain LLAMA_VERSION bump cannot fix #10820 yet and vendoring is the only route for now.

What looks good

  • The vendored patch is a faithful copy of upstream #24523, correctly rebased onto the pinned LLAMA_VERSION. I diffed it against the upstream PR: the only substantive delta is the dropped message_delimiters block, which the pinned tree does not support yet (worth keeping in mind if upstream updates and the patch gets re-vendored). The llama-cpp backend builds and both grpc test suites are green.
  • inference_defaults.json: valid JSON, the minimax-m3 entry is consistent with the minimax-m2.x neighbors, and placing it before minimax-m2.7 in patterns is correct for longest-match-first.
  • The exit plan (delete the patch and bump normally once upstream merges) is documented in the PR body. Please also add a short header comment at the top of the .patch file itself noting the source PR and the pinned llama.cpp sha it was rebased against: LLAMA_VERSION is auto-bumped nightly, and whoever hits the first apply-conflict will need that context.

What must change

  1. The tests-turboquant-grpc failure is caused by this PR, not flaky infra. The turboquant and bonsai backends reuse backend/cpp/llama-cpp/ by copying the whole directory (see the turboquant-build define in backend/cpp/turboquant/Makefile and bonsai-build in backend/cpp/bonsai/Makefile), which now includes the new patches/ dir. prepare.sh then applies the minimax-m3 patch to the TheTom/llama-cpp-turboquant fork tree, where 5 hunks reject (including the src/llama-arch.h enum hunk). Because the patch loop in prepare.sh runs before set -e, the rejects do not abort the build; it dies ~2 minutes later with 'LLM_ARCH_MINIMAX_M3' was not declared in this scope (job log). Bonsai would hit the same problem on its next build.
    Suggested fix: right after the cp -rf $(LLAMA_CPP_DIR) ... step in both the turboquant and bonsai Makefiles, delete the copied patches/ directory so patches meant for the upstream pin are never applied to fork trees (each fork already has its own patches/ mechanism in its own backend dir). Please also make the patch loop in backend/cpp/llama-cpp/prepare.sh fail fast on a rejected hunk (move it below set -e and check the patch exit status), so a future LLAMA_VERSION bump that conflicts with this vendored patch fails loudly at patch-apply time instead of surfacing as a confusing compile error.

  2. Please drop the .github/workflows/secscan.yaml hunk from this PR. It is unrelated to MiniMax-M3 support and is not mentioned in the PR description. It also overlaps with the already-open fix(ci): skip security scan on forks to avoid SARIF upload permission error #10323, which addresses the fork SARIF-upload failure differently (skipping the scan on forks). Additionally, continue-on-error: true on the upload step would mask genuine SARIF upload failures on the main repo. If you believe the permissions block is the better fix, please propose it separately in the fix(ci): skip security scan on forks to avoid SARIF upload permission error #10323 discussion so one approach lands.

Once (1) and (2) are addressed and turboquant is green, this looks mergeable to me; leaving the final call to @mudler.

The secscan permissions/continue-on-error tweak is unrelated to
MiniMax-M3 support and overlaps with the fork SARIF-upload discussion
in mudler#10323; keeping this PR scoped to the model support only.

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Assisted-by: Claude Code:claude-opus-4-8
@localai-bot

Copy link
Copy Markdown
Collaborator

Follow-up on my review above:

@mudler suggested merge order: land #10866 first (it is green), then update this branch from master and re-run CI; tests-turboquant-grpc should go green and this becomes mergeable. The vendored patch itself and the inference_defaults.json entry already checked out in my review.

mudler added a commit that referenced this pull request Jul 16, 2026
…rk trees (#10866)

The turboquant and bonsai backends copy backend/cpp/llama-cpp/ wholesale
into their build directories and reuse its Makefile/prepare.sh against
their own llama.cpp forks. When PR #10837 added
backend/cpp/llama-cpp/patches/0001-add-minimax-m3-support.patch, the
copied patches/ directory was mis-applied to the fork checkouts: the
fork trees diverge from upstream, hunks rejected, and because the
patch-apply loop in prepare.sh ran before set -e took effect the build
kept going and died much later with a confusing compile error
("'LLM_ARCH_MINIMAX_M3' was not declared in this scope"). This broke
tests-turboquant-grpc on that PR.

Two hardening changes:

- turboquant/bonsai Makefiles: delete the copied patches/ directory
  right after the cp -rf of backend/cpp/llama-cpp/. Patches vendored
  for upstream llama.cpp must never be applied to the forks; each fork
  carries its own patch series under backend/cpp/<backend>/patches/,
  applied by its apply-patches.sh.

- llama-cpp prepare.sh: run the patch-apply loop under set -e so a
  rejecting patch fails fast and loudly at apply time instead of
  surfacing as a downstream compile error. A missing or empty patches/
  directory remains a no-op success, so all existing callers (the
  llama-cpp Makefile targets and the turboquant/bonsai copies) are
  unaffected when no patches ship.

Exposed by PR #10837.


Assisted-by: Claude:claude-opus-4-8 [Claude Code]

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Co-authored-by: Ettore Di Giacinto <mudler@localai.io>
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.

MiniMax-M3 GGUF model cannot be loaded - unknown model architecture 'minimax-m3'

3 participants