TutorialMarch 6, 2026|25 min read|by gpuLabs Team

How to Run Kimi K2.5 Locally on Ubuntu

Kimi K2.5 is the flagship open-source multimodal model from Moonshot AI — 1 trillion total parameters, 32 billion active per forward pass, 256K context window. This guide covers three deployment paths on Ubuntu 22.04/24.04.

Expert1Expert2Expert3Expert4Expert5Expert6MIXTURE-OF-EXPERTS ARCHITECTURE384 experts · 32B active · 1T total parametersKimi K2.5by Moonshot AI

1. Model Overview and Benchmark Results

Kimi K2.5, released January 27, 2026 under Modified MIT License by Moonshot AI, is a Mixture-of-Experts (MoE) model with a 384-expert architecture, MLA attention, and a 256K context window. Only 3.2% of parameters activate during each inference pass, making the model surprisingly efficient despite the 1T total parameter count.

Kimi K2.5 Architecture

Input Tokens

256K context

MLA Attention

61 layers

MoE Router

384 experts

32B Active

3.2% of 1T

Output

Text + Vision

Architecture specifications

Total Parameters1 trillion (1T)
Active Parameters32 billion (32B)
ArchitectureMoE, 384 experts, 61 layers
Context Window256K tokens
AttentionMulti-head Latent (MLA)
OptimizerMuonClip
ModesInstant + Thinking (CoT)
ModalitiesText + Vision
LicenseModified MIT (commercial OK)
Training15.5T tokens

Benchmark results vs closed-source models

BenchmarkKimi K2.5GPT-5.2Claude Opus 4.5
Humanity's Last Exam50.2%41.7%32.0%
BrowseComp (web agent)60.254.924.1
SWE-Bench Verified (coding)76.8%80.9%
LiveCodeBench v683.187.064.0
AIME 2025 (math)96.1%100%
Tool-use improvement+20.1 pp+11.0 pp+12.4 pp
i
Note

Kimi K2.5 autonomously spawns up to 100 sub-agents executing in parallel, handling up to 1,500 tool calls without human intervention. Complex research tasks complete up to 4.5x faster than sequential approaches.

2. Hardware Requirements per Quantization Level

Kimi K2.5 is a 1T-parameter model. Running the full BF16 version requires 2.05 TB of storage and multiple high-end GPUs. Quantized GGUF versions from Unsloth reduce this significantly.

Disk Size by Quantization Level

1.8-bit
240 GB
2-bit
374 GB
3-bit
490 GB
4-bit
621 GB
6-bit
843 GB
8-bit
1.09 TB
BF16
2.05 TB
QuantizationDisk SizeMin Memory (RAM+VRAM)Expected Speed
UD-TQ1_0 (1.8-bit)240 GB256 GB unified~5-10 tok/s
UD-IQ1_S (1-bit)276 GB290 GB unified~5 tok/s
Q2_K (2-bit)374 GB390 GB unified~8 tok/s
UD-Q2_K_XL (2-bit XL)375 GB390 GB unified~10 tok/s
Q3_K_M (3-bit)490 GB510 GB unified~12 tok/s
Q4_K_M (4-bit)621 GB640 GB unified~15 tok/s
Q6_K (6-bit)843 GB870 GB unified~18 tok/s
Q8_0 (8-bit)1.09 TB1.1 TB unified~20 tok/s
BF16 (full precision)2.05 TB2.1 TB unified~25 tok/s

Minimum Setup

Budget Inference

  • 1x GPU with 24GB VRAM
  • 256GB system RAM
  • 240GB NVMe SSD
  • 5-10 tokens/second

Recommended

Production Setup

  • 2x H100 80GB or 8x A100 80GB
  • 512GB+ system RAM
  • 2TB+ NVMe SSD
  • 50-100 tokens/second

3. Method 1: Ollama (Cloud-Backed, Easiest)

Ollama provides the simplest path. The kimi-k2.5:cloud tag routes inference through Moonshot's cloud backend while using the familiar Ollama CLI and API. No GPU required locally.

*
Tip

This method requires an internet connection. For fully offline / self-hosted inference, use Method 2 or Method 3.

1Install Ollama

bash
# Install Ollama on Ubuntu
curl -fsSL https://ollama.com/install.sh | sh

# Verify installation
ollama --version

2Pull and run Kimi K2.5

bash
# Pull the cloud-backed model
ollama pull kimi-k2.5:cloud

# Run in interactive chat mode
ollama run kimi-k2.5:cloud

# Run with a single prompt
ollama run kimi-k2.5:cloud "Explain the difference between LoRA and QLoRA"

# Run with a system prompt
ollama run kimi-k2.5:cloud --system "You are a senior Python developer" \
  "Write a FastAPI endpoint for file upload"

3Use via API

bash
# Ollama exposes an OpenAI-compatible API on port 11434
curl http://localhost:11434/api/generate -d '{
  "model": "kimi-k2.5:cloud",
  "prompt": "Write a bash script to monitor GPU temperature",
  "stream": false,
  "options": {
    "temperature": 0.7,
    "num_ctx": 65536
  }
}'

4. Method 2: llama.cpp + GGUF (Self-Hosted)

This method runs Kimi K2.5 entirely on local hardware using llama.cpp and quantized GGUF weights from Unsloth. Best for single-machine setups with large RAM.

1Install build dependencies

bash
sudo apt-get update
sudo apt-get install -y pciutils build-essential cmake curl libcurl4-openssl-dev git

2Build llama.cpp with CUDA support

bash
git clone https://github.com/ggml-org/llama.cpp
cd llama.cpp

# Build with CUDA (requires NVIDIA GPU + CUDA toolkit)
cmake -B build \
  -DBUILD_SHARED_LIBS=OFF \
  -DGGML_CUDA=ON

cmake --build build --config Release -j$(nproc) --clean-first \
  --target llama-cli llama-server llama-gguf-split

# Copy binaries to the llama.cpp root for convenience
cp build/bin/llama-* .

# For CPU-only builds, replace -DGGML_CUDA=ON with -DGGML_CUDA=OFF

3Download GGUF model weights

Unsloth provides quantized GGUF variants. Choose based on available memory. The recommended starting point is UD-Q2_K_XL (375 GB, best quality-to-size ratio at 2-bit).

bash
pip install -U huggingface_hub

# Download the 1.8-bit quant (240 GB, minimum size)
huggingface-cli download unsloth/Kimi-K2.5-GGUF \
  --local-dir Kimi-K2.5-GGUF \
  --include "*UD-TQ1_0*"

# Or download the 2-bit XL quant (375 GB, recommended)
huggingface-cli download unsloth/Kimi-K2.5-GGUF \
  --local-dir Kimi-K2.5-GGUF \
  --include "*UD-Q2_K_XL*"

# Or download the 4-bit quant (621 GB, near-lossless)
huggingface-cli download unsloth/Kimi-K2.5-GGUF \
  --local-dir Kimi-K2.5-GGUF \
  --include "*Q4_K_M*"

4Run in CLI mode (interactive chat)

bash
export LLAMA_CACHE="Kimi-K2.5-GGUF"

LLAMA_SET_ROWS=1 ./llama-cli \
  --model Kimi-K2.5-GGUF/UD-TQ1_0/Kimi-K2.5-UD-TQ1_0-00001-of-00005.gguf \
  --temp 1.0 \
  --min-p 0.01 \
  --top-p 0.95 \
  --ctx-size 16384 \
  --seed 3407

5Run as OpenAI-compatible API server

bash
LLAMA_SET_ROWS=1 ./llama-server \
  --model Kimi-K2.5-GGUF/UD-TQ1_0/Kimi-K2.5-UD-TQ1_0-00001-of-00005.gguf \
  --special \
  --alias "kimi-k2.5" \
  --min_p 0.01 \
  --ctx-size 16384 \
  --port 8001 \
  --host 0.0.0.0 \
  --kv-unified

# Server starts at http://0.0.0.0:8001
# OpenAI-compatible endpoint: http://localhost:8001/v1/chat/completions

6Layer offloading for limited VRAM

When VRAM is insufficient for the full model, offload MoE expert layers to system RAM. This slows inference but allows running on a single 24GB GPU.

!
Warning

Offloading all expert layers to CPU will reduce speed to 2-5 tok/s. For acceptable performance, keep at least the gate layers in VRAM.

bash
# Offload all MoE expert layers to CPU (minimum VRAM usage)
LLAMA_SET_ROWS=1 ./llama-server \
  --model Kimi-K2.5-GGUF/UD-TQ1_0/Kimi-K2.5-UD-TQ1_0-00001-of-00005.gguf \
  -ot ".ffn_.*_exps.=CPU" \
  --ctx-size 16384 \
  --port 8001

# Offload only up/down projection MoE (keep gate in VRAM, faster)
LLAMA_SET_ROWS=1 ./llama-server \
  --model Kimi-K2.5-GGUF/UD-TQ1_0/Kimi-K2.5-UD-TQ1_0-00001-of-00005.gguf \
  -ot ".ffn_(up|down)_exps.=CPU" \
  --ctx-size 16384 \
  --port 8001

# Auto-fit: let llama.cpp decide optimal layer distribution
LLAMA_SET_ROWS=1 ./llama-server \
  --model Kimi-K2.5-GGUF/UD-TQ1_0/Kimi-K2.5-UD-TQ1_0-00001-of-00005.gguf \
  --fit on \
  --ctx-size 16384 \
  --port 8001

5. Method 3: vLLM (Production Multi-GPU)

vLLM is the recommended engine for production deployments on multi-GPU servers. Supports tensor parallelism, tool calling, vision inputs, and reasoning mode out of the box.

1Install vLLM nightly

bash
pip install uv
uv pip install -U vllm --pre \
  --extra-index-url https://wheels.vllm.ai/nightly/cu129

2Launch the model server

Requires 8x H100/H200 or equivalent for full BF16. Tensor parallelism (-tp) splits the model across GPUs.

bash
vllm serve moonshotai/Kimi-K2.5 \
  -tp 8 \
  --mm-encoder-tp-mode data \
  --compilation_config.pass_config.fuse_allreduce_rms true \
  --tool-call-parser kimi_k2 \
  --reasoning-parser kimi_k2 \
  --enable-auto-tool-choice \
  --trust-remote-code

vLLM flag reference

FlagPurpose
-tp 8Tensor parallelism across 8 GPUs
--mm-encoder-tp-mode dataVision encoder in data-parallel mode
--tool-call-parser kimi_k2Parse tool/function calls from output
--reasoning-parser kimi_k2Extract chain-of-thought reasoning
--enable-auto-tool-choiceAuto-select tools during generation
--trust-remote-codeAllow running custom model code from HF

3Benchmark the deployment

bash
vllm bench serve \
  --backend openai-chat \
  --endpoint /v1/chat/completions \
  --model moonshotai/Kimi-K2.5 \
  --dataset-name hf \
  --dataset-path lmarena-ai/VisionArena-Chat \
  --num-prompts 1000 \
  --request-rate 20

6. API Integration (Python / OpenAI SDK)

All three methods expose an OpenAI-compatible API. Use the standard OpenAI Python SDK or raw HTTP requests.

Python with OpenAI SDK

python
from openai import OpenAI

# Connect to local llama.cpp server (port 8001)
# Or Ollama (port 11434) or vLLM (port 8000)
client = OpenAI(
    base_url="http://127.0.0.1:8001/v1",
    api_key="sk-no-key-required",
)

response = client.chat.completions.create(
    model="kimi-k2.5",
    messages=[
        {"role": "system", "content": "You are a helpful coding assistant."},
        {"role": "user", "content": "Write a Python function to detect GPU memory leaks"},
    ],
    temperature=0.7,
    max_tokens=2048,
)
print(response.choices[0].message.content)

Python with requests (streaming)

python
import requests
import json

url = "http://localhost:11434/api/generate"
payload = {
    "model": "kimi-k2.5:cloud",
    "prompt": "Explain CUDA unified memory in detail",
    "stream": True,
    "options": {"temperature": 0.7, "num_ctx": 32768}
}

response = requests.post(url, json=payload, stream=True)
for line in response.iter_lines():
    if line:
        data = json.loads(line)
        print(data.get("response", ""), end="", flush=True)

cURL (works with any backend)

bash
curl http://localhost:8001/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kimi-k2.5",
    "messages": [
      {"role": "user", "content": "How does MoE routing work in transformer models?"}
    ],
    "temperature": 0.7,
    "max_tokens": 1024
  }'

7. Performance Optimization and Tuning

Sampling parameters

Moonshot AI recommends the following parameters for best results:

ParameterInstant ModeThinking Mode
temperature0.61.0
top_p0.950.95
min_p0.010.01
repeat_penalty1.0 (disabled)1.0 (disabled)

Environment variables for llama.cpp

bash
# Speed boost for MoE models
export LLAMA_SET_ROWS=1

# Set model cache directory
export LLAMA_CACHE="/path/to/models"

Multi-GPU setup with Ollama

bash
# Expose all 8 GPUs to Ollama
export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7

# Allow 4 parallel requests
export OLLAMA_NUM_PARALLEL=4

# Keep only 1 model loaded (saves VRAM)
export OLLAMA_MAX_LOADED_MODELS=1

# Restart Ollama with new settings
sudo systemctl restart ollama

Docker deployment

yaml
# docker-compose.yml
version: '3.8'
services:
  ollama:
    image: ollama/ollama:latest
    volumes:
      - ollama_data:/root/.ollama
    ports:
      - '11434:11434'
    environment:
      - OLLAMA_NUM_PARALLEL=4
      - CUDA_VISIBLE_DEVICES=0,1,2,3
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 4
              capabilities: [gpu]

volumes:
  ollama_data:

8. Troubleshooting Common Issues

Out of memory (OOM)

!
Warning

If you see CUDA out of memory, try these fixes in order:

  • Reduce --ctx-size from 16384 to 8192 or 4096
  • Use a smaller quantization (UD-TQ1_0 instead of Q4_K_M)
  • Offload MoE layers to CPU: -ot ".ffn_.*_exps.=CPU"
  • Enable KV cache unification: --kv-unified

Slow inference (1-2 tok/s)

  • Increase system RAM — more layers stay in VRAM when RAM handles the rest
  • Use NVMe SSD instead of SATA for model file reads
  • Set LLAMA_SET_ROWS=1 environment variable
  • Use --fit on flag for automatic layer placement

Model download fails or is slow

bash
# Install Xet for faster Hugging Face downloads
pip install huggingface_hub[hf_xet]

# Resume interrupted downloads
huggingface-cli download unsloth/Kimi-K2.5-GGUF \
  --local-dir Kimi-K2.5-GGUF \
  --include "*UD-TQ1_0*" \
  --resume-download

CUDA not detected

bash
# Verify CUDA installation
nvidia-smi
nvcc --version

# If nvcc is missing, install CUDA toolkit
sudo apt-get install -y nvidia-cuda-toolkit

# Rebuild llama.cpp with CUDA
cd llama.cpp
cmake -B build -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=ON
cmake --build build --config Release -j$(nproc) --clean-first

Vision/multimodal not working in llama.cpp

i
Note

GGUF format does not currently support vision inputs. For multimodal (text + image), use vLLM with the full moonshotai/Kimi-K2.5 weights from Hugging Face.

9. Running Kimi K2.5 on gpuLabs Cloud GPUs

For users without local hardware meeting the requirements, gpuLabs provides on-demand GPU instances with pre-installed CUDA. Launch an H100 or A100, SSH in, and follow Method 2 or Method 3 above.

bash
# Create an 8x H100 instance for full BF16 vLLM deployment
curl -X POST https://api.gpulabs.cloud/gpu/instances \
  -H "Authorization: Bearer sk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "offerId": "h100-sxm-80gb-8x",
    "sshKeyId": "your-ssh-key-id",
    "name": "kimi-k25-production"
  }'

# SSH into the instance
ssh root@<instance-ip>

# Follow Method 3 (vLLM) from this guide
pip install uv
uv pip install -U vllm --pre --extra-index-url https://wheels.vllm.ai/nightly/cu129
vllm serve moonshotai/Kimi-K2.5 -tp 8 --trust-remote-code

Or use a single RTX 4090 / A100 with llama.cpp and GGUF quantization for budget-friendly inference:

bash
# Create a single A100 80GB instance
curl -X POST https://api.gpulabs.cloud/gpu/instances \
  -H "Authorization: Bearer sk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "offerId": "a100-80gb-sxm",
    "sshKeyId": "your-ssh-key-id",
    "name": "kimi-k25-gguf"
  }'

# SSH in and run llama.cpp with 1.8-bit quant
# Follow Method 2 steps 1-5 from this guide

New to gpuLabs?

Pay-as-you-go GPU cloud. Deploy Kimi K2.5 in under 5 minutes.

Create Free Account