Instructions to use unsloth/Kimi-K3 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use unsloth/Kimi-K3 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="unsloth/Kimi-K3", trust_remote_code=True) messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("unsloth/Kimi-K3", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use unsloth/Kimi-K3 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "unsloth/Kimi-K3" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "unsloth/Kimi-K3", "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/unsloth/Kimi-K3
- SGLang
How to use unsloth/Kimi-K3 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 "unsloth/Kimi-K3" \ --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": "unsloth/Kimi-K3", "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 "unsloth/Kimi-K3" \ --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": "unsloth/Kimi-K3", "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" } } ] } ] }' - Unsloth Studio
How to use unsloth/Kimi-K3 with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for unsloth/Kimi-K3 to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for unsloth/Kimi-K3 to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for unsloth/Kimi-K3 to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="unsloth/Kimi-K3", max_seq_length=2048, ) - Docker Model Runner
How to use unsloth/Kimi-K3 with Docker Model Runner:
docker model run hf.co/unsloth/Kimi-K3
Modeling code: 6 issues on CPU / transformers >= 5.15 (with workaround patch)
Found while building a small CPU test fixture for llama.cpp's Kimi K3 support (ggml-org/llama.cpp#26185). The released modeling code can't run on CPU or on current transformers main as shipped. Six concrete issues, all in modeling_kimi_linear.py unless noted:
The model constructor hard-forces flash_attention_2 and silently overrides whatever attn_implementation you request (the block around line 1114 logs a warning and replaces it). On a machine without flash-attn this makes eager/SDPA unusable without editing the file.
from transformers.utils.generic import OutputRecorderfails on transformers >= 5.15.0.dev0. OutputRecorder moved to transformers.utils.output_capturing._tied_weights_keysuses the old list-style API. transformers main expects a dict, so save_pretrained crashes with AttributeError: 'list' object has no attribute 'keys'. Not hit in normal from_pretrained use, but any fine-tune/save path hits it.create_causal_maskis called withinput_embeds=(transformers main spells itinputs_embeds) and withcache_position=, which the current signature doesn't take. Both raise TypeError.Under from_config (fresh init, e.g. for fine-tuning from scratch or building test models), some custom parameters stay as uninitialized torch.empty memory because _init_weights doesn't cover them: self_attn.dt_bias and block_sparse_moe.gate.e_score_correction_bias. I observed absmax ~1.9e37 in dt_bias and the forward pass returns NaN logits. from_pretrained is unaffected since the checkpoint overwrites them.
Minor, arguably by design: the fla KDA ops (chunk_kda, causal_conv1d, rms_norm_gated) are Triton-only, so there's no CPU path at all. I worked around it by rerouting to fla's own naive torch ops.
Workaround patch for 1-4 plus a re-init sweep for 5, and the CPU shim for 6: https://gist.github.com/SolshineCode/3115760b0c3b655563a3102ba897c426 (modeling_cpu.patch). With those applied, a 90M random-init structural clone of K3 runs on CPU and its greedy outputs match llama.cpp's implementation of the architecture token for token, so the patched path seems faithful.
Most of these probably apply to the upstream moonshotai repo too, since the modeling files look identical. Happy to split this into separate reports if that's easier to track.
AI usage disclosure: found and written up with Claude running on my machine; I approved and can rerun everything on request.