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.

#!/usr/bin/env python3
"""Kimi-K2-Thinking W4A8 re-quantization via AMD Quark (File-to-File Quantization)."""

import argparse
import os
from quark.torch.quantization.config.config import (
    FP8E4M3PerTensorSpec, Int4PerChannelSpec, ProgressiveSpec,
    QConfig, QLayerConfig,
)
from quark.torch.quantization.api import ModelQuantizer


def get_config():
    exclude_layers = [
        "*self_attn*", "*mlp.gate", "*lm_head",
        "*mlp.gate_proj", "*mlp.up_proj", "*mlp.down_proj",
        "*shared_experts*",
    ]

    input_spec = FP8E4M3PerTensorSpec(
        observer_method="min_max", scale_type="float32", is_dynamic=True,
    ).to_quantization_spec()

    weight_spec = ProgressiveSpec(
        first_stage=FP8E4M3PerTensorSpec(
            observer_method="min_max", scale_type="float32", is_dynamic=False,
        ),
        second_stage=Int4PerChannelSpec(
            symmetric=True, scale_type="float32",
            round_method="half_even", is_dynamic=False, ch_axis=0,
        ),
    ).to_quantization_spec()

    return QConfig(
        global_quant_config=QLayerConfig(input_tensors=input_spec, weight=weight_spec),
        exclude=exclude_layers,
    )


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--model-path", type=str, required=True,
                        help="Path to moonshotai/Kimi-K2-Thinking checkpoint")
    parser.add_argument("--export-path", type=str, required=True,
                        help="Path to save quantized output")
    args = parser.parse_args()

    quantizer = ModelQuantizer(get_config())
    quantizer.direct_quantize_checkpoint(
        pretrained_model_path=args.model_path,
        save_path=args.export_path,
    )
    print("[INFO] Quantization completed")

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
156
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for amd/Kimi-K2-Thinking-W4A8

Quantized
(19)
this model