Text Generation
Transformers
Safetensors
deepseek_v3
conversational
custom_code
text-generation-inference
quark
Instructions to use amd/Kimi-K2-Thinking-W4A8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use amd/Kimi-K2-Thinking-W4A8 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="amd/Kimi-K2-Thinking-W4A8", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("amd/Kimi-K2-Thinking-W4A8", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("amd/Kimi-K2-Thinking-W4A8", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use amd/Kimi-K2-Thinking-W4A8 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "amd/Kimi-K2-Thinking-W4A8" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "amd/Kimi-K2-Thinking-W4A8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/amd/Kimi-K2-Thinking-W4A8
- SGLang
How to use amd/Kimi-K2-Thinking-W4A8 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 "amd/Kimi-K2-Thinking-W4A8" \ --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": "amd/Kimi-K2-Thinking-W4A8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "amd/Kimi-K2-Thinking-W4A8" \ --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": "amd/Kimi-K2-Thinking-W4A8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use amd/Kimi-K2-Thinking-W4A8 with Docker Model Runner:
docker model run hf.co/amd/Kimi-K2-Thinking-W4A8
Model Overview
- Model Architecture: Kimi-K2-Thinking
- Input: Text
- Output: Text
- Supported Hardware Microarchitecture: AMD MI300/MI355
- ROCm: 7.0
- PyTorch: 2.8.0
- Transformers: 4.53.0
- Operating System(s): Linux
- Inference Engine: vLLM
- Model Optimizer: AMD-Quark (V0.10)
- Weight quantization: INT4 Per-Channel & FP8E4M3, Static
- Activation quantization: FP8E4M3, Dynamic
This model was built with moonshotai Kimi-K2-Thinking model by applying AMD-Quark for INT4-FP8 quantization.
Model Quantization
The model was quantized from moonshotai/Kimi-K2-Thinking using AMD-Quark.
Deployment
This model can be deployed efficiently using the vLLM backends.
Evaluation
The model was evaluated on GSM8K benchmarks using the lm-evaluation-harness framework.
Accuracy
| Benchmark | Kimi-K2-Thinking | Kimi-K2-Thinking-W4A8(this model) | Recovery |
| GSM8K | 93.93 | 93.4 | 99.4% |
Reproduction
The results of GSM8K were obtained using lm-evaluation-harness and latest vLLM.
Launch vLLM
MODEL_DIR=/data/amd/Kimi-K2-Thinking-W4A8
VLLM_ATTENTION_BACKEND="TRITON_MLA" VLLM_ROCM_USE_AITER=1 VLLM_ROCM_USE_AITER_FUSION_SHARED_EXPERTS=0 VLLM_ROCM_USE_AITER_FP4BMM=0 vllm serve $MODEL_DIR \
--port 8001 \
--trust-remote-code \
--gpu-memory-utilization 0.9 \
--tensor-parallel-size 8 \
--load-format "fastsafetensors"
GSM8K evaluation
MODEL_ARGS="model=/data/amd/Kimi-K2-Thinking-W4A8,base_url=http://localhost:8001/v1/completions,num_concurrent=999999,timeout=999999,tokenized_requests=False,max_length=38768,temperature=0.6,top_p=0.95,add_bos_token=True,seed=$SEED,trust_remote_code=True"
lm_eval \
--model local-completions \
--model_args $MODEL_ARGS \
--tasks gsm8k \
--num_fewshot 8 \
--batch_size auto
License
Modifications Copyright(c) 2025 Advanced Micro Devices, Inc. All rights reserved.
- Downloads last month
- 49
Model tree for amd/Kimi-K2-Thinking-W4A8
Base model
moonshotai/Kimi-K2-Thinking