Skip to content

[Model] Support MiniCPM-V 4.6#22529

Merged
CISC merged 18 commits into
ggml-org:masterfrom
tc-mb:Support-MiniCPM-V-4.6
May 6, 2026
Merged

[Model] Support MiniCPM-V 4.6#22529
CISC merged 18 commits into
ggml-org:masterfrom
tc-mb:Support-MiniCPM-V-4.6

Conversation

@tc-mb
Copy link
Copy Markdown
Contributor

@tc-mb tc-mb commented Apr 29, 2026

This PR adds support for MiniCPM-V 4.6.

  1. v4.6 reworks the vision tower — the resampler is replaced by a new merger structure, which improves ViT efficiency.
  2. The GGUF conversion is also folded into the standard convert_hf_to_gguf.py flow.

tc-mb added 2 commits April 29, 2026 23:32
Signed-off-by: tc-mb <tianchi_cai@icloud.com>
Signed-off-by: tc-mb <tianchi_cai@icloud.com>
@tc-mb tc-mb requested review from a team and CISC as code owners April 29, 2026 18:50
Signed-off-by: tc-mb <tianchi_cai@icloud.com>
@github-actions github-actions Bot added documentation Improvements or additions to documentation examples python python script changes labels Apr 29, 2026
Comment thread convert_hf_to_gguf.py Outdated
Comment thread convert_hf_to_gguf.py Outdated
Copy link
Copy Markdown
Contributor

@ngxson ngxson left a comment

Choose a reason for hiding this comment

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

please change the naming to minicpmv2_6 everywhere for consistency

Comment thread tools/mtmd/models/minicpmv.cpp Outdated
Comment thread tools/mtmd/models/models.h Outdated
Comment thread tools/mtmd/clip-model.h Outdated
Comment thread tools/mtmd/mtmd.cpp Outdated
tc-mb added 6 commits April 30, 2026 09:46
Signed-off-by: tc-mb <tianchi_cai@icloud.com>
Signed-off-by: tc-mb <tianchi_cai@icloud.com>
Signed-off-by: tc-mb <tianchi_cai@icloud.com>
Signed-off-by: tc-mb <tianchi_cai@icloud.com>
Signed-off-by: tc-mb <tianchi_cai@icloud.com>
Signed-off-by: tc-mb <tianchi_cai@icloud.com>
Comment thread tools/mtmd/mtmd-image.h Outdated
Comment thread tools/mtmd/mtmd-image.h Outdated
Comment thread convert_hf_to_gguf.py Outdated
Comment thread convert_hf_to_gguf.py Outdated
Comment thread convert_hf_to_gguf.py Outdated
Comment thread convert_hf_to_gguf.py Outdated
tc-mb added 3 commits May 1, 2026 23:38
Signed-off-by: tc-mb <tianchi_cai@icloud.com>
Signed-off-by: tc-mb <tianchi_cai@icloud.com>
Signed-off-by: tc-mb <tianchi_cai@icloud.com>
Copy link
Copy Markdown
Contributor

@ngxson ngxson left a comment

Choose a reason for hiding this comment

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

some style nits before I can approve this

Comment thread tools/mtmd/models/minicpmv.cpp Outdated
Comment thread tools/mtmd/models/minicpmv.cpp Outdated
Comment thread tools/mtmd/models/minicpmv.cpp Outdated
Signed-off-by: tc-mb <tianchi_cai@icloud.com>
@ngxson ngxson requested a review from CISC May 4, 2026 14:14
Signed-off-by: tc-mb <tianchi_cai@icloud.com>
Comment thread convert_hf_to_gguf.py Outdated
Comment thread convert_hf_to_gguf.py Outdated
tc-mb and others added 2 commits May 6, 2026 22:07
Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@scala.com>
Signed-off-by: tc-mb <tianchi_cai@icloud.com>
@CISC
Copy link
Copy Markdown
Member

CISC commented May 6, 2026

Something is wrong with GitHub, can't comment directly on code in this PR any more...

It looks like they updated the tokenizer (see #22700), but we want to keep the old hash so please revert the change of the original chkhsh in convert_hf_to_gguf.py.

Signed-off-by: tc-mb <tianchi_cai@icloud.com>
@tc-mb
Copy link
Copy Markdown
Contributor Author

tc-mb commented May 6, 2026

chkhsh

ok,fixed

@CISC
Copy link
Copy Markdown
Member

CISC commented May 6, 2026

To fix https://github.com/ggml-org/llama.cpp/actions/runs/25452560865/job/74674331069?pr=22529

    gguf_writer: gguf.GGUFWriter
    rope_parameters: dict

    def set_gguf_parameters(self):
        super().set_gguf_parameters()  # ty: ignore[unresolved-attribute]
        if "mrope_section" not in self.rope_parameters:
            self.gguf_writer.add_rope_dimension_sections(self._QWEN35_DEFAULT_MROPE_SECTION)

Signed-off-by: tc-mb <tianchi_cai@icloud.com>
@tc-mb
Copy link
Copy Markdown
Contributor Author

tc-mb commented May 6, 2026

To fix https://github.com/ggml-org/llama.cpp/actions/runs/25452560865/job/74674331069?pr=22529

    gguf_writer: gguf.GGUFWriter
    rope_parameters: dict

    def set_gguf_parameters(self):
        super().set_gguf_parameters()  # ty: ignore[unresolved-attribute]
        if "mrope_section" not in self.rope_parameters:
            self.gguf_writer.add_rope_dimension_sections(self._QWEN35_DEFAULT_MROPE_SECTION)

ok, fixed

@CISC CISC merged commit 2496f9c into ggml-org:master May 6, 2026
49 of 50 checks passed
@tc-mb tc-mb deleted the Support-MiniCPM-V-4.6 branch May 6, 2026 19:59
cetarthoriphros pushed a commit to cetarthoriphros/llama.cpp that referenced this pull request May 9, 2026
* Support MiniCPM-V 4.6 in new branch

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* fix code bug

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* fix pre-commit

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* fix convert

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* rename clip_graph_minicpmv4_6

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* use new TYPE_MINICPMV4_6

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* use build_attn to allow flash attention support

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* no use legacy code, restored here.

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* use the existing tensors name

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* unused ctx->model.hparams.minicpmv_version

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* use n_merge for slice alignment

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* borrow wa_layer_indexes for vit_merger insertion point

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* fix code style

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* Update convert_hf_to_gguf.py

Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@scala.com>

* use filter_tensors and add model.vision_tower

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* fix chkhsh

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* fix type check

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

---------

Signed-off-by: tc-mb <tianchi_cai@icloud.com>
Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@scala.com>
meh pushed a commit to meh/llama.cpp that referenced this pull request May 10, 2026
* Support MiniCPM-V 4.6 in new branch

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* fix code bug

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* fix pre-commit

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* fix convert

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* rename clip_graph_minicpmv4_6

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* use new TYPE_MINICPMV4_6

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* use build_attn to allow flash attention support

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* no use legacy code, restored here.

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* use the existing tensors name

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* unused ctx->model.hparams.minicpmv_version

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* use n_merge for slice alignment

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* borrow wa_layer_indexes for vit_merger insertion point

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* fix code style

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* Update convert_hf_to_gguf.py

Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@scala.com>

* use filter_tensors and add model.vision_tower

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* fix chkhsh

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

* fix type check

Signed-off-by: tc-mb <tianchi_cai@icloud.com>

---------

Signed-off-by: tc-mb <tianchi_cai@icloud.com>
Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@scala.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation examples python python script changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Misc. bug: convert_hf_to_gguf.py - The BPE pre-tokenizer was not recognized” - Qwen3.5-4B-Base

3 participants