Skip to main content
Back

MiniCPM-SALA

MiniCPM Text Series

Prepare your runtime environment according to your context length and device, then choose either the Transformers or the SGLang route. The SGLang guide covers one-click installation, manual installation, and server configuration; before running it, check your CUDA, compiler, and related attention-kernel dependencies.

Hardware Requirements​

MiniCPM-SALA's hybrid attention architecture significantly reduces the VRAM required for long contexts:

Context lengthVRAM requiredReference device
32K~20 GBRTX 3090/4090
128K~24 GBRTX 3090/4090
1M~24 GBRTX 5090

A conventional full-attention 8B model needs 100+ GB of VRAM at 1M context; MiniCPM-SALA needs only 24 GB.

Model Inference​

Recommended inference parameters: Temperature=0.9

Hugging Face Transformers​

MiniCPM-SALA is compatible with Hugging Face Transformers. You can run inference with the following code:

Python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

model_path = "openbmb/MiniCPM-SALA"
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True, device_map="auto")
model.eval()

prompts = ["My name is", "The capital of China is"]
with torch.no_grad():
inputs = tokenizer(prompts, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs)
output_texts = tokenizer.batch_decode(outputs)
print(output_texts)

SGLang​

Requirements:

  • CUDA 12.x or later
  • gcc / g++ compilers
  • uv package manager (the script detects it automatically)

Option 1: One-click Installation​

Bash
# 克隆仓库
git clone -b minicpm_sala https://github.com/OpenBMB/sglang.git
cd sglang

# 一键安装(自动创建虚拟环境并编译所有依赖)
bash install_minicpm_sala.sh

# 或指定 PyPI 镜像源
bash install_minicpm_sala.sh https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple

The installation script automatically performs the following steps:

  1. Creates the sglang_minicpm_sala_env virtual environment (Python 3.12)
  2. Clones dependencies into the 3rdparty/ directory (infllmv2) and initializes submodules (sparse_kernel)
  3. Installs MiniCPM-SALA (the current repository)
  4. Compiles and installs infllmv2_cuda_impl
  5. Compiles and installs sparse_kernel
  6. Installs tilelang and flash-linear-attention

Option 2: Manual Installation​

If the one-click script doesn't meet your needs, you can run the steps individually:

Bash
# 0. 确保 uv 可用
pip install uv

# 1. 创建虚拟环境
uv venv --python 3.12 sglang_minicpm_sala_env
source sglang_minicpm_sala_env/bin/activate

# 2. 安装 SGLang
uv pip install --upgrade pip setuptools wheel
uv pip install -e ./python[all]

# 3. 编译安装 CUDA 扩展
# (确保依赖已克隆到 3rdparty/ 目录)
cd 3rdparty/infllmv2_cuda_impl && python setup.py install && cd ../..
cd 3rdparty/sparse_kernel && python setup.py install && cd ../..

# 4. 安装额外依赖
uv pip install tilelang flash-linear-attention

Usage​

Bash
# 激活环境
source sglang_minicpm_sala_env/bin/activate

# 启动推理服务(将 MODEL_PATH 替换为实际模型路径)
MODEL_PATH=/path/to/your/model

python3 -m sglang.launch_server \
--model ${MODEL_PATH} \
--trust-remote-code \
--disable-radix-cache \
--attention-backend minicpm_flashinfer \
--chunked-prefill-size 8192 \
--max-running-requests 32 \
--skip-server-warmup \
--port 31111 \
--dense-as-sparse

Parameters

ParameterDescription
--trust-remote-codeAllow loading the model's bundled custom code
--disable-radix-cacheDisable the RadixAttention prefix cache
--attention-backend minicpm_flashinferUse the MiniCPM FlashInfer attention backend
--chunked-prefill-size 8192Chunked prefill size
--max-running-requests 32Maximum number of concurrent inference requests
--skip-server-warmupSkip server warmup
--port 31111Server port
--dense-as-sparseUse dense-as-sparse mode

Developer Showcase

View all →
MiniCPM TextVoxCPM SpeechESP32 Radar Tower: AI ATC CalloutsA round-AMOLED tower radar announcing flights in a cloned ATC voiceMiniCPM TextSelf-Evolving Catgirl: Reasoning via On-Policy Self DistillationNo teacher, no new base model: math reasoning emerges from self-distillationMiniCPM TextReJev: Decision-Model Post-TrainingLoRA post-training MiniCPM5-2B: 51.1% → 80.5% on a sealed holdoutMiniCPM TextBMB Agent: a MiniCPM-powered Personal AssistantLetting a 2B on-device model take over schedules and todos, with real-world lessonsMiniCPM TextMetaCog: Judge-Steered ReasoningAn inference-time loop where a judge scores parallel thought pathsMiniCPM TextMiniCPM News Desk: Local Daily BriefA local-first daily brief where MiniCPM5-2B picks exact source passagesMiniCPM TextWebGPU Pi: In-Browser Coding AgentMiniCPM5-2B running a coding agent fully in-browser via WebGPUMiniCPM TextMiniCPM5-1B Tool-Use: Offline Function CallsA 1B GGUF function-calling model (SFT + GRPO) that runs offline on CPUMiniCPM Textdeku: A Trustworthy Local Task AgentCode plans, MiniCPM5-1B answers briefly or refusesMiniCPM TextMiniCPM5-1B: LiteRT & Iberian EvalsINT8 LiteRT-LM build plus Spanish, Catalan, Basque and Galician evalsMiniCPM TextMiniCPM-V MultimodalMiniCPM Agent Gateway: Edge-Cloud RoutingLocal MiniCPM classifies each request so sensitive data stays on-deviceMiniCPM TextToneBridge: Context-Aware Mandarin CoachCorrects Mandarin sentences by context and tone, with pinyin and audioMiniCPM TextMiniCPM5-1B FP8: Faster NVIDIA InferenceFP8 vLLM profile hitting 248 decode tok/s on RTX 3060, 1.5× BF16MiniCPM TextAUGURY: Reading Soil Health from WeedsMaps weed species to soil-health indicators; phone-deployable, no cloudMiniCPM Textgmgn-minicpm: Local Crypto Research AgentA read-only GMGN crypto research agent powered by a local 1B modelMiniCPM TextMiniCPM-V MultimodalLost & Found Desk: Small-Model Item ReturnMiniCPM-V captions items, MiniCPM5 guides claims, staff confirm every handoffMiniCPM TextMiniCPM-V MultimodalVoxCPM SpeechCoreAI Model Zoo: MiniCPM on iPhoneCore AI builds of MiniCPM5 and MiniCPM-V 4.6 running natively on iPhone and MacMiniCPM TextMiniCPM-V MultimodalViva Mais: Local WhatsApp CRM CopilotA travel-agency copilot that turns WhatsApp chats into a local-first CRMMiniCPM TextTianwen: BaZi & I-Ching ReflectionA 1B model that turns BaZi and I-Ching readings into self-reflectionMiniCPM TextWanderLust: Mood-Driven Discovery WalksPlans exploratory A-to-B walking routes based on your moodMiniCPM TextNIGHTWAVE: 1970s Radio Hosted by a 1B ModelA 1970s late-night radio with a 1B-model DJ who takes live callsMiniCPM Text6ixPulse: Agentic Toronto Rent MapAgents compare Toronto neighborhoods, citing a source for every claimMiniCPM TextWall Street of AI AgentsFour small-model AI traders roam a pixel office and trade on their ownMiniCPM TextHackathon Advisor: Idea Map & CoachMaps hackathon ideas and coaches you toward more original projectsMiniCPM TextLLM Cinema: AI-Directed ASCII FilmsA small model writes and directs ASCII-art films in the browserMiniCPM Texttiny-llm: A Pure-Rust Inference EngineA from-scratch, CPU-only Rust inference engine for MiniCPM5-1B with a TUIMiniCPM TextDocument Field Agent: Batch OCR & ExtractionA workbench for batch document OCR and structured field extractionMiniCPM TextMiniCPM-V MultimodalWhen a Catgirl Learns to Think, on Your PhoneWas this model made for catgirls? An on-device deployment testMiniCPM TextMiniCPM-V MultimodalMaking a 1B Model a Good Math AgentTeXada’s on-device MiniCPM practice and lessonsMiniCPM TextORG-2: A Workbench for Coding AgentsAn organizational workbench to orchestrate and manage multiple coding agentsMiniCPM TextEdgeHome HarnessA replayable, evaluable local control loop for a 1B on-device model, built in RustMiniCPM TextSqueezing a NAS: Hooking Up WorkBuddyRunning local AI on an N150 CPU: real-world uses and lessons learned