[PR #12546] convert: add MiniCPM3-4B model support #76163

Open
opened 2026-05-05 08:39:26 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/12546
Author: @MyoungHaSong
Created: 10/9/2025
Status: 🔄 Open

Base: mainHead: add-minicpm3-support


📝 Commits (1)

  • 4b8460d convert: add MiniCPM3-4B model support

📊 Changes

8 files changed (+178270 additions, -0 deletions)

View changed files

📝 convert/convert.go (+2 -0)
convert/convert_minicpm3.go (+118 -0)
📝 convert/convert_test.go (+1 -0)
convert/testdata/minicpm3-4b.json (+39 -0)
convert/testdata/minicpm3-4b/config.json (+42 -0)
convert/testdata/minicpm3-4b/model.safetensors (+0 -0)
convert/testdata/minicpm3-4b/tokenizer.json (+177952 -0)
convert/testdata/minicpm3-4b/tokenizer_config.json (+116 -0)

📄 Description

Summary

This PR adds support for converting MiniCPM3-4B models from safetensors format.

MiniCPM3-4B is a popular 4B parameter model with 20,594 monthly downloads on HuggingFace, featuring:

  • LoRA-based attention mechanism with Q/KV LoRA ranks
  • LongRoPE scaling for 32k context length
  • Grouped Query Attention (GQA)

Changes

  • Add convert/convert_minicpm3.go implementing MiniCPM3 converter
  • Register MiniCPM3ForCausalLM architecture in convert/convert.go
  • Add test case and test data for MiniCPM3-4B

Implementation Details

  • Supports LoRA attention parameters (q_lora_rank, kv_lora_rank)
  • Implements RoPE scaling factors (rope_factors_long, rope_factors_short)
  • Handles unique tensor naming for LoRA projections (q_a_proj, q_b_proj, kv_a_proj_with_mqa, kv_b_proj)

Testing

  • Unit tests pass
  • Safetensors → GGUF conversion verified
  • Compatible with official GGUF files (openbmb/MiniCPM3-4B-GGUF)

Closes #6722
Related to #6721


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/12546 **Author:** [@MyoungHaSong](https://github.com/MyoungHaSong) **Created:** 10/9/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `add-minicpm3-support` --- ### 📝 Commits (1) - [`4b8460d`](https://github.com/ollama/ollama/commit/4b8460d1a774143838859a82374c08f85f2485f9) convert: add MiniCPM3-4B model support ### 📊 Changes **8 files changed** (+178270 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `convert/convert.go` (+2 -0) ➕ `convert/convert_minicpm3.go` (+118 -0) 📝 `convert/convert_test.go` (+1 -0) ➕ `convert/testdata/minicpm3-4b.json` (+39 -0) ➕ `convert/testdata/minicpm3-4b/config.json` (+42 -0) ➕ `convert/testdata/minicpm3-4b/model.safetensors` (+0 -0) ➕ `convert/testdata/minicpm3-4b/tokenizer.json` (+177952 -0) ➕ `convert/testdata/minicpm3-4b/tokenizer_config.json` (+116 -0) </details> ### 📄 Description ## Summary This PR adds support for converting MiniCPM3-4B models from safetensors format. MiniCPM3-4B is a popular 4B parameter model with 20,594 monthly downloads on HuggingFace, featuring: - LoRA-based attention mechanism with Q/KV LoRA ranks - LongRoPE scaling for 32k context length - Grouped Query Attention (GQA) ## Changes - Add `convert/convert_minicpm3.go` implementing MiniCPM3 converter - Register `MiniCPM3ForCausalLM` architecture in `convert/convert.go` - Add test case and test data for MiniCPM3-4B ## Implementation Details - Supports LoRA attention parameters (`q_lora_rank`, `kv_lora_rank`) - Implements RoPE scaling factors (`rope_factors_long`, `rope_factors_short`) - Handles unique tensor naming for LoRA projections (q_a_proj, q_b_proj, kv_a_proj_with_mqa, kv_b_proj) ## Testing - ✅ Unit tests pass - ✅ Safetensors → GGUF conversion verified - ✅ Compatible with official GGUF files (openbmb/MiniCPM3-4B-GGUF) Closes #6722 Related to #6721 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-05 08:39:26 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#76163