Instructions to use moonshotai/Kimi-K3.1-Pro with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use moonshotai/Kimi-K3.1-Pro with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="moonshotai/Kimi-K3.1-Pro", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForSeq2SeqLM model = AutoModelForSeq2SeqLM.from_pretrained("moonshotai/Kimi-K3.1-Pro", trust_remote_code=True, device_map="auto") - Inference
- HuggingChat
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use moonshotai/Kimi-K3.1-Pro with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "moonshotai/Kimi-K3.1-Pro" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "moonshotai/Kimi-K3.1-Pro", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/moonshotai/Kimi-K3.1-Pro
- SGLang
How to use moonshotai/Kimi-K3.1-Pro with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "moonshotai/Kimi-K3.1-Pro" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "moonshotai/Kimi-K3.1-Pro", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "moonshotai/Kimi-K3.1-Pro" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "moonshotai/Kimi-K3.1-Pro", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use moonshotai/Kimi-K3.1-Pro with Docker Model Runner:
docker model run hf.co/moonshotai/Kimi-K3.1-Pro
[Deployment Guide] Single-Node 8x NVIDIA HGX B300 (1,048,576 Context) -NVLS Multicast & CUDA 13.1 JIT Reference
Overview
Outside of next-generation Vera Rubin rack-scale systems, a single 8× NVIDIA HGX B300 (288 GB HBM3e per GPU; 2,304 GB total VRAM) node is the primary conventional 4U server class capable of holding Kimi K3.1 Pro's full MXFP4 weights (~1.56 TB across 96 shards) alongside a full 1,048,576-token (1M) KV cache in a single TP=8 NVLink domain.
We brought up Kimi K3.1 Pro on a bare-metal Supermicro H14 4U HGX B300 system and documented three field blockers—and their exact fixes—so Moonshot's engineering team and other single-node B300 operators can deploy cleanly out of the box.
Verified Hardware & Software Baseline
- System: Supermicro H14 4U GPU System with NVIDIA HGX B300 8-GPU Baseboard
- GPUs: 8× NVIDIA B300 (288 GB HBM3e per GPU, 2,304 GB total HBM, NVLink 5 / 4th-Gen NVSwitch)
- CPUs: Dual AMD EPYC 9575F 64-Core (128 cores / 256 threads)
- RAM: 3,072 GB DDR5-6000 MT/s (24× 128 GB Micron, 24-channel)
- Storage: 8× Samsung 7.68 TB PCIe 5.0 NVMe SSDs + 2× Samsung 960 GB NVMe M.2
- OS / Stack: Ubuntu 24.04 LTS, NVIDIA Container Toolkit, CUDA 13.1, vLLM + FlashInfer
- Model Footprint:
195 GB/GPU base weights (1,560 GB total), leaving93 GB/GPU (744 GB node-wide) for KV cache, activations, and CUDA graphs atmax_model_len=1048576.
Field Blockers & Exact Fixes
1. CUDA error 401 on Blackwell NVLS Multicast Binding (latent_moe_tail)
- Issue: On HGX B300 baseboards, NVSwitch multicast tables can remain uninitialized after warm boots even when
nvidia-fabricmanageris version-matched and active. Because K3.1's Blackwell Latent-MoE Tail Fusion (torch.distributed._symmetric_memory) auto-engages on SM100/SM103 with no env-var bypass (NCCL_NVLS_ENABLE=0does not disable custom symmetric-memory multicast kernels),cuMulticastBindMemfails withCUDA error 401. - Fix: Perform an in-band GPU + NVSwitch reset before launching the container:
sudo systemctl stop nvidia-fabricmanager sudo nvidia-smi -r sudo systemctl start nvidia-fabricmanager - Model/Runtime Suggestion: Add a multicast capability probe before committing to
latent_moe_tailfusion, with a graceful fallback to unfused collectives if multicast binding is unavailable.
2. Driver-Only Host Images Fail FlashInfer Blackwell JIT (nvcc + ninja)
- Issue: Enterprise HGX B300 nodes commonly ship with matched GPU drivers +
nvidia-fabricmanageronly (omitting the CUDA Toolkit to prevent driver/FM drift). FlashInfer's SM100/SM103 NVLS all-reduce and MXFP4 MoE kernels requirenvcc(CUDA 13.1+) andninjaat runtime, aborting after loading all 96 shards (~1.56 TB). - Fix: Install driver-pinned
cuda-toolkit-13-1andninja-build, exposeCUDA_HOME/nvccto the container, and mount~/.cache/flashinferto NVMe to persist compiled cubins.
3. fastsafetensors (nogds) Device Desync After nvidia-smi -r
- Issue: Running
nvidia-smi -rinvalidates existing NVIDIA Container Toolkit UVM/device-cgroup handles for active container runtimes, causingfastsafetensors(nogds) to miss the GPUs. - Fix: Restart Docker (
sudo systemctl restart docker) afternvidia-smi -r, or fall back to standardsafetensors(~1.2 shards/s on PCIe 5.0 NVMe).
Validation Gates & Sanity Results
- Fabric State:
Completed / Successacross all 8 GPUs; zeroXiderrors indmesg -T. - Memory Balance: ~195 GB/GPU base MXFP4 weights + full
1,048,576context window verified. - Step 1 Benchmark (1M Context Capable Config):
[TBD: Insert TTFT ms and Decode tok/s here]
Update: Confirmed Live Bring-Up (All Gates Passed)
Following the steps above, Kimi K3.1 Pro (full 96 MXFP4 shards, max_model_len=1048576) is now live and serving cleanly on our single-node 8× NVIDIA HGX B300 system:
- Memory Footprint: Balanced at 208 GB/GPU across all 8 B300s (
1,664 GB total weights + workspace), leaving **80 GB/GPU (~640 GB node-wide)** of HBM3e headroom for the 1M-token KV cache and CUDA graphs. - NVLS Multicast & Kernel JIT: Resetting the NVSwitch multicast tables (
nvidia-smi -r+nvidia-fabricmanagercycle) resolvedCUDA error 401, and installing driver-pinned CUDA 13.1 (nvcc) +ninjaallowed FlashInfer's Blackwell SM100/SM103 NVLS all-reduce and MXFP4 MoE kernels to compile cleanly and complete CUDA graph capture. - Hardware Health: Zero
Xiderrors indmesg -Tacross shard load, JIT build, graph capture, and live inference.