koboldcpp/conversion
timkhronos 3d1c3a8975
mtmd: Add Vision Support for Minimax-M3 (#25113)
* Add preliminary MiniMax-M3 support

Text-only port that re-uses existing components: MiniMax-M2 style GQA with
per-head QK-norm and partial rotary, DeepSeek-V3 style leading-dense and
routed/shared experts, and swigluoai activation. Sparse attention is not
yet supported (dense fallback); vision tower and MTP heads are dropped.

* MiniMax-M3 vision tower (mmproj + clip graph)

* Delete m3_vision_ref.py

* Update clip.cpp

* MSA

* Update constants.py

* Update minimax.py

* Cache creation. Working withotu flash attention

* Added flash attention for sparse layers

* Decomposed slow cpu OP into GPU + CPU ops. Massive speedup over long ctx

* Rewrote indexer op to be cuda native. Modified flash attention to match per group block picking

* Implement sparse attention calc out of stock ops.

* Fix a cache allocation and cont issue

* Fixed -fa auto crash, flagged debug spots

* Delete vocab.json

* Delete model.safetensors.index.json

* Delete generation_config.json

* Delete Minimax directory

* Handled multi stream case to fall back on Dense Attention

* Development scaffolding cleanup. No functional change to the decode or
4-way paths. Full debug harness remains at <8136a9c68ed7a5eb009aa67bba3fda8062f4648f> for reproducing the
selection-parity validation.

* Remove redundant comment from minimax-m3.cpp

* Changed 3 Gelu Ops for vision into Gelu_erf ops

* Assert that n_kv is multiple of 128

* Rename MSA index tensors to indexer convention

Note: All GGUFs generated before this change will need to be regenerated.

* Fix incorrect Assert

* Review driven changes (#3)

* Remove comment from conversion minimax.py

Co-authored-by: Sigbjørn Skjæret <1629204+CISC@users.noreply.github.com>

* Remove whitespaces from constants.py

Co-authored-by: Sigbjørn Skjæret <1629204+CISC@users.noreply.github.com>

* Tighten comment in minimax.py

Co-authored-by: Sigbjørn Skjæret <1629204+CISC@users.noreply.github.com>

* inherit MiniMax-M3 from MiniMax-M2

* drop dead text_config fallbacks

* Add indexer writer methods

* Reuse LLM_FFN_SWIGLU_OAI_MOE

* Remove duplicate  indexer setters, add only block_size/local_blocks, follow value naming convention

* Fix conversion error /gguf_writer.py

Co-authored-by: Sigbjørn Skjæret <1629204+CISC@users.noreply.github.com>

* Update gguf-py/gguf/gguf_writer.py

Co-authored-by: Sigbjørn Skjæret <1629204+CISC@users.noreply.github.com>

* Update gguf-py/gguf/tensor_mapping.py

Co-authored-by: Sigbjørn Skjæret <1629204+CISC@users.noreply.github.com>

* Update conversion/minimax.py

Co-authored-by: Sigbjørn Skjæret <1629204+CISC@users.noreply.github.com>

* Update conversion/minimax.py

Co-authored-by: Sigbjørn Skjæret <1629204+CISC@users.noreply.github.com>

* Remove whitespace in src/llama-kv-cache.cpp

Co-authored-by: Sigbjørn Skjæret <1629204+CISC@users.noreply.github.com>

* Remove Whitespace in Update src/llama-model.h

Co-authored-by: Sigbjørn Skjæret <1629204+CISC@users.noreply.github.com>

* Remove whitespace in src/llama-hparams.h

Co-authored-by: Sigbjørn Skjæret <1629204+CISC@users.noreply.github.com>

* Update minimax_m3.cpp

Rewrite code comment based on feedback and to better reflect the actual architecture, and reuse existing build_vit

* Rename minimax_m3.cpp to minimax-m3.cpp

* Update CMakeLists.txt

* Remove debug code from clip.cpp

* Update clip.cpp

* Update comments in tools/mtmd/models/minimax-m3.cpp

* Permute Q/K at conversion, drop precomputed sin/cos

* Log cache size on launch, block ctx shift, support prompt caching

Log indexer cache size on launch

Disallow ctx shift

Support prompt caching

* Update minimax-m3.cpp

* Optimize implementation, add multi stream support. 

Fully rewrote minimax-m3.cpp for speed and buffer size gains:

Unified the 4-way + decode, 1 FA call per layer instead of 4, with the groups mapped onto ne[3]

Custom CPU op now emits block-level mask, expanded on GPU, which causes CPU to GPU transfer to shrinks at prefill

Decode: ~25 nodes/layer vs ~50, no per-group concats/conts

Unified selection semantics, so both regimes rank bs + local bias (position-anchored local force), which means prefill/decode can no longer disagree on selection

can_reuse on the MSA bias input. Graph reuse at decode restored (was rebuilding the full graph every token)

In-place mask adds, shrinking compute buffer ~6.8 to ~4.2 GiB at ub2048/62k

Multi-stream: MSA now runs with -np N when kv_unified=false. Decode stays batched across streams (still 1 FA call), prefill loops per stream. dense fallback only for --kv-unified + multi-seq

Measured effect on expert offload bound setup: decode 6.2(4WAY)–7.15(MSA_decode) -> 7.7~7.8 t/s, flat from 5k to 60k+. prefill around 10% faster. buffer about 20% smaller, multi-user support.

* set default cache type to F32

* Fix potential DSA double indexer cache  allocation bug, only allocate in-cache k_idx for archs that opt in

* remove F16 downcasts in MSA attention, force F32 indexer score accum

* Add Minimax eos to llama vocab

* Guard edge case where idx cache can become stale after a tail trim

* Update llama-kv-cache.h

* Update llama-kv-cache.cpp

* Update llama-kv-cache.cpp

* Update llama-kv-cache.h

* Change resize Pad to none, resize alg to Bicubic Pillow

* Review driven changes

* Update llama-kv-cache.cpp

* rm unrotated pos_t

* fused rope w + pad

* rename merge --> merger for consistency

* add review skill for mtmd

* graph should use hparams n_merge

* fix lint

---------

Co-authored-by: Daniel Han <danielhanchen@gmail.com>
Co-authored-by: Sigbjørn Skjæret <1629204+CISC@users.noreply.github.com>
Co-authored-by: Xuan Son Nguyen <son@huggingface.co>
2026-07-27 01:44:41 +02:00
..
__init__.py mtmd: Add Vision Support for Minimax-M3 (#25113) 2026-07-27 01:44:41 +02:00
afmoe.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
arctic.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
baichuan.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
bailingmoe.py convert : more consistent handling of rope_parameters (#24833) 2026-06-20 13:42:36 +03:00
base.py model: Add MiniMax-M3 (MSA: MiniMax Sparse Attention) support (#24908) 2026-07-26 19:43:45 +02:00
bert.py conversion: fix non-MoE NomicBert GGUF conversion error (#25996) 2026-07-23 11:01:35 +08:00
bitnet.py conversion: accept BitNetForCausalLM architecture name (#25769) 2026-07-16 16:24:47 +03:00
bloom.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
chameleon.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
chatglm.py convert : more consistent handling of rope_parameters (#24833) 2026-06-20 13:42:36 +03:00
codeshell.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
cogvlm.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
command_r.py Add arch support for cohere2-MoE (#24260) 2026-06-13 19:49:00 +02:00
dbrx.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
deci.py convert : more consistent handling of rope_parameters (#24833) 2026-06-20 13:42:36 +03:00
deepseek.py DeepSeek V4 (#24162) 2026-06-29 16:58:51 +08:00
dots1.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
dotsocr.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
dream.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
ernie.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
exaone.py convert : more consistent handling of rope_parameters (#24833) 2026-06-20 13:42:36 +03:00
falcon.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
falcon_h1.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
gemma.py convert : more consistent handling of rope_parameters (#24833) 2026-06-20 13:42:36 +03:00
glm.py model: add GLM 5.2 Indexer support (#25407) 2026-07-24 20:55:56 +02:00
gpt2.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
gpt_oss.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
gptneox.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
granite.py model: Granite Speech Plus (#24818) 2026-06-23 12:03:31 +02:00
grok.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
grovemoe.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
hunyuan.py convert: fix handle HunyuanVL XD-RoPE config (#25514) 2026-07-22 00:42:35 +02:00
internlm.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
internvl.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
jais.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
jamba.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
januspro.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
kimi_linear.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
kimivl.py mtmd: add GLM-5.2-Vision (#26126) 2026-07-26 20:43:51 +02:00
laguna.py Add support for Laguna XS.2 & M.1 (#25165) 2026-07-22 09:54:08 +08:00
lfm2.py model : Add LFM2.5-ColBERT-350M and LFM2.5-Embedding-350M (#24913) 2026-06-24 09:49:46 +03:00
lighton_ocr.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
llada.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
llama.py dflash: refactor draft model conversion (#25110) 2026-06-28 20:31:48 +02:00
llama4.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
llava.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
maincoder.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
mamba.py mamba2: remove hardcoded 2x expansion factor and invalid d_inner % d_state check (#23082) 2026-06-26 08:50:54 +03:00
mellum.py model: add Mellum architecture (#23966) 2026-06-02 22:11:12 +03:00
mimo.py convert : more consistent handling of rope_parameters (#24833) 2026-06-20 13:42:36 +03:00
minicpm.py convert : more consistent handling of rope_parameters (#24833) 2026-06-20 13:42:36 +03:00
minimax.py mtmd: Add Vision Support for Minimax-M3 (#25113) 2026-07-27 01:44:41 +02:00
mistral.py convert : fix conversion for Mistral-Medium-3.5-128B (#24268) 2026-06-07 21:41:39 +02:00
mistral3.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
mpt.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
nemotron.py convert : more consistent handling of rope_parameters (#24833) 2026-06-20 13:42:36 +03:00
olmo.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
openelm.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
orion.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
pangu.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
phi.py convert : more consistent handling of rope_parameters (#24833) 2026-06-20 13:42:36 +03:00
pixtral.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
plamo.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
plm.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
qwen.py convert : fix dflash target tokenizer mismatch during conversion (#25733) 2026-07-16 15:19:47 +03:00
qwen3vl.py convert : fix Qwen3 ASR conversion (#23081) 2026-05-15 18:38:39 +02:00
qwenvl.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
refact.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
rwkv.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
sarashina2.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
smallthinker.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
smolvlm.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
stablelm.py convert : more consistent handling of rope_parameters (#24833) 2026-06-20 13:42:36 +03:00
starcoder.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
step3.py convert_hf_to_gguf: support split MTP export for HY V3 (#25641) 2026-07-14 11:43:15 +02:00
t5.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
talkie.py model : add support for talkie-1930-13b (#22596) 2026-05-26 07:57:38 +03:00
ultravox.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
wavtokenizer.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
xverse.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00
youtuvl.py Refactor: convert_hf_to_gguf.py (#17114) 2026-05-15 15:18:12 +02:00