> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sglang.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Kimi-K3

> [!NOTE]
>
> This page focuses on optimal configuration and benchmark results for Kimi-K3 on the Ascend NPU.
>
> On the A3 Series, each card has 2 dies, so `--tp-size` is twice the card count; with pipeline parallelism, `--tp-size` multiplied by `--pp-size` is the total die count; see [Ascend NPU Reference](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/reference/glossary.md#hardware) for details.

### High Throughput

| Model | Hardware | Cards | Deploy Mode | Dataset | TPOT | TTFT | Quantization | Configuration |
| - | - | - | - | - | - | - | - | - |
| Kimi-K3 | A3 Series Products | 32 | PD Mixed | 128k+1 | - | 20s | W4A8 INT8 | [Optimal Configuration](#kimi-k3-w4a8-32p-mix-in128k-out1-prefill-20s) |
| Kimi-K3 | A3 Series Products | 32 | PD Mixed | 128k+1k (99% prefix cache hit rate) | 30.0ms | - | W4A8 INT8 | [Optimal Configuration](#kimi-k3-w4a8-32p-mix-in128k-out1k-decode-prefix-30-0ms) |

## Optimal Configuration

Referenced by external docs. Verify before removing.

### Kimi-K3 W4A8 32P MIX IN128K OUT1 PREFILL 20s

**Model**: Kimi-K3

**Hardware**: A3 Series Products

**Cards**: 32

**Deploy Mode**: PD Mixed

**Quantization**: W4A8 INT8

**Dataset**: 128k+1

**TTFT**: 20s

#### Model Deployment

```bash Command theme={null}
# ============================================================
# Before running, update the following variables:
#   MODEL_PATH: path to the model weights directory
#   NODE_IPS: IP addresses of each node in the cluster
#   HCCL_SOCKET_IFNAME: network interface name for HCCL
#   GLOO_SOCKET_IFNAME: network interface name for Gloo
# ============================================================

MODEL_PATH=/path/to/model-weights
NODE_IPS=('<your node1 ip>' '<your node2 ip>' '<your node3 ip>' '<your node4 ip>')

echo performance | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
sysctl -w vm.swappiness=0
sysctl -w kernel.numa_balancing=0
sysctl -w kernel.sched_migration_cost_ns=50000

unset https_proxy
unset http_proxy
unset HTTPS_PROXY
unset HTTP_PROXY
unset ASCEND_LAUNCH_BLOCKING

source /usr/local/Ascend/ascend-toolkit/set_env.sh
source /usr/local/Ascend/nnal/atb/set_env.sh
# Optional vendor op packages.
source /usr/local/Ascend/ascend-toolkit/latest/opp/vendors/customize/bin/set_env.bash 2>/dev/null || true
source /usr/local/Ascend/ascend-toolkit/latest/opp/vendors/custom_transformer/bin/set_env.bash 2>/dev/null || true

export ASCEND_USE_FIA=1
export DEEPEP_HYBRID_DEPLOYMENT=1
export DEEPEP_NORMAL_LONG_SEQ_PER_ROUND_TOKENS=512
export DEEPEP_NORMAL_LONG_SEQ_ROUND=2
export DEEP_NORMAL_MODE_USE_INT8_QUANT=1
export GLOO_SOCKET_IFNAME=<network-interface>
export HCCL_BUFFSIZE=2000
export HCCL_OP_EXPANSION_MODE=AIV
export HCCL_SOCKET_IFNAME=<network-interface>
export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True
export SGLANG_DEEPEP_NUM_MAX_DISPATCH_TOKENS_PER_RANK=128
export SGLANG_NPU_USE_FIAS_V2_BSND=1
export SGLANG_ONE_VISIBLE_DEVICE_PER_PROCESS=1
export SGLANG_PP_LAYER_PARTITION=24,24,24,21
export SGLANG_SET_CPU_AFFINITY=1
export STREAMS_PER_DEVICE=32
export TRITON_CACHE_DIR=/tmp/triton_cache

LOCAL_HOST1=`hostname -I|awk -F " " '{print$1}'`
LOCAL_HOST2=`hostname -I|awk -F " " '{print$2}'`
echo "${LOCAL_HOST1}"
echo "${LOCAL_HOST2}"

for i in "${!NODE_IPS[@]}";
do
    if [[ "$LOCAL_HOST1" == "${NODE_IPS[$i]}" || "$LOCAL_HOST2" == "${NODE_IPS[$i]}" ]];
    then
        echo "${NODE_IPS[$i]}"
        python3 -m sglang.launch_server \
        --model-path $MODEL_PATH \
        --host ${NODE_IPS[$i]} --port 6688 \
        --nnodes 4 \
        --dist-init-addr ${NODE_IPS[0]}:5000 \
        --node-rank $i \
        --model-loader-extra-config '{"enable_multithread_load": true}' \
        --tokenizer-path $MODEL_PATH \
        --trust-remote-code \
        --attention-backend ascend \
        --device npu \
        --quantization modelslim \
        --dtype bfloat16 \
        --tp-size 16 \
        --pp-size 4 \
        --pp-async-batch-depth 0 \
        --disable-overlap-schedule \
        --attn-dp-size 2 \
        --enable-dp-lm-head \
        --enable-shared-experts-attn-tp \
        --enable-dense-mlp-attn-tp \
        --mem-fraction-static 0.78 \
        --chunked-prefill-size 16384 \
        --max-total-tokens 250000 \
        --disable-radix-cache \
        --cuda-graph-backend-decode disabled \
        --max-running-requests 8 \
        --reasoning-parser kimi_k3 \
        --moe-a2a-backend deepep \
        --deepep-mode auto \
        --disable-custom-all-reduce \
        --watchdog-timeout 9000
        break
    fi
done
```

#### Benchmark

The measured run used AISBench with the `GSM8K` fixed-length dataset; the command below is the equivalent `bench_serving` `RANDOM` reproduction.

```bash Command theme={null}
python -m sglang.benchmark.serving \
    --dataset-name random \
    --backend sglang \
    --host 127.0.0.1 \
    --port 6688 \
    --random-input-len 131072 \
    --random-output-len 1 \
    --num-prompts 1 \
    --max-concurrency 1 \
    --random-range-ratio 1
```

### Kimi-K3 W4A8 32P MIX IN128K OUT1K DECODE PREFIX 30.0ms

**Model**: Kimi-K3

**Hardware**: A3 Series Products

**Cards**: 32

**Deploy Mode**: PD Mixed

**Quantization**: W4A8 INT8

**Dataset**: 128k+1k (99% prefix cache hit rate)

**TPOT**: 30.0ms

#### Model Deployment

```bash Command theme={null}
# ============================================================
# Before running, update the following variables:
#   MODEL_PATH: path to the model weights directory
#   DRAFT_MODEL_PATH: path to the draft model weights directory
#   NODE_IPS: IP addresses of each node in the cluster
#   HCCL_SOCKET_IFNAME: network interface name for HCCL
#   GLOO_SOCKET_IFNAME: network interface name for Gloo
# ============================================================

MODEL_PATH=/path/to/model-weights
DRAFT_MODEL_PATH=/path/to/draft-model-weights

NODE_IPS=('<your node1 ip>' '<your node2 ip>' '<your node3 ip>' '<your node4 ip>')

echo performance | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
sysctl -w vm.swappiness=0
sysctl -w kernel.numa_balancing=0
sysctl -w kernel.sched_migration_cost_ns=50000

unset https_proxy
unset http_proxy
unset HTTPS_PROXY
unset HTTP_PROXY
unset ASCEND_LAUNCH_BLOCKING

source /usr/local/Ascend/ascend-toolkit/set_env.sh
source /usr/local/Ascend/nnal/atb/set_env.sh
# Optional vendor op packages.
source /usr/local/Ascend/ascend-toolkit/latest/opp/vendors/customize/bin/set_env.bash 2>/dev/null || true
source /usr/local/Ascend/ascend-toolkit/latest/opp/vendors/custom_transformer/bin/set_env.bash 2>/dev/null || true

export ASCEND_USE_FIA=1
export DEEPEP_HCCL_BUFFSIZE=1800
export DEEPEP_NORMAL_LONG_SEQ_PER_ROUND_TOKENS=512
export DEEPEP_NORMAL_LONG_SEQ_ROUND=2
export DEEP_NORMAL_MODE_USE_INT8_QUANT=1
export GLOO_SOCKET_IFNAME=<network-interface>
export HCCL_BUFFSIZE=200
export HCCL_OP_EXPANSION_MODE=AIV
export HCCL_SOCKET_IFNAME=<network-interface>
export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True
export SGLANG_DEEPEP_NUM_MAX_DISPATCH_TOKENS_PER_RANK=128
export SGLANG_DSPARK_EMBED_IN_GRAPH=0
export SGLANG_DSPARK_FOLDED_PROPOSAL=0
export SGLANG_DSPARK_STACKED_CTX_KV=0
export SGLANG_ENABLE_OVERLAP_PLAN_STREAM=1
export SGLANG_NPU_FINE_GRAINED_MOE_DUAL_STREAM=0
export SGLANG_NPU_USE_FIAS_V2_BSND=1
export SGLANG_NPU_USE_TRITON_PREFIX_KV_CACHE_STORE=1
export SGLANG_ONE_VISIBLE_DEVICE_PER_PROCESS=1
export SGLANG_RAGGED_VERIFY_MODE=static
export SGLANG_SET_CPU_AFFINITY=1
export STREAMS_PER_DEVICE=32
export TRITON_CACHE_DIR=/tmp/triton_cache

LOCAL_HOST1=`hostname -I|awk -F " " '{print$1}'`
LOCAL_HOST2=`hostname -I|awk -F " " '{print$2}'`
echo "${LOCAL_HOST1}"
echo "${LOCAL_HOST2}"

for i in "${!NODE_IPS[@]}";
do
    if [[ "$LOCAL_HOST1" == "${NODE_IPS[$i]}" || "$LOCAL_HOST2" == "${NODE_IPS[$i]}" ]];
    then
        echo "${NODE_IPS[$i]}"
        python3 -m sglang.launch_server \
        --model-path $MODEL_PATH \
        --host ${NODE_IPS[$i]} --port 6688 \
        --nnodes 4 \
        --dist-init-addr ${NODE_IPS[0]}:5000 \
        --node-rank $i \
        --model-loader-extra-config '{"enable_multithread_load": true}' \
        --tokenizer-path $MODEL_PATH \
        --trust-remote-code \
        --attention-backend ascend \
        --device npu \
        --quantization modelslim \
        --dtype bfloat16 \
        --tp-size 64 \
        --attn-dp-size 4 \
        --enable-dp-lm-head \
        --enable-shared-experts-attn-tp \
        --enable-dense-mlp-attn-tp \
        --mamba-ssm-dtype bfloat16 \
        --mem-fraction-static 0.75 \
        --max-total-tokens 250000 \
        --max-mamba-cache-size 240 \
        --chunked-prefill-size 20480 \
        --cuda-graph-bs-decode 2 4 8 12 16 \
        --max-running-requests 64 \
        --reasoning-parser kimi_k3 \
        --enable-cache-report \
        --random-seed 540332093 \
        --moe-a2a-backend deepep \
        --deepep-mode auto \
        --speculative-algorithm DSPARK \
        --speculative-draft-model-path $DRAFT_MODEL_PATH \
        --speculative-draft-model-quantization unquant \
        --speculative-dspark-block-size 7 \
        --speculative-draft-attention-backend ascend \
        --linear-attn-verify-backend triton \
        --speculative-eagle-topk 1 \
        --disable-custom-all-reduce \
        --watchdog-timeout 9000
        break
    fi
done
```

#### Benchmark

The measured run used AISBench's prefix-cache mode (`repeat_rate = 0.99`, `--dp 4` client parallelism); the command below is the equivalent `bench_serving` `generated-shared-prefix` reproduction with a 99% shared prefix:
`--gsp-system-prompt-len 129761` = `int(131072 * 0.99)` is the shared prefix portion.
`--gsp-question-len 1310` = `int(131072 * (1 - 0.99))` is the unique per-request suffix.
`--gsp-num-groups 1` keeps all requests in one prefix group for maximum cache reuse.

```bash Command theme={null}
python -m sglang.benchmark.serving \
    --dataset-name generated-shared-prefix \
    --backend sglang \
    --host 127.0.0.1 \
    --port 6688 \
    --gsp-num-groups 1 \
    --gsp-prompts-per-group 6 \
    --gsp-system-prompt-len 129761 \
    --gsp-question-len 1310 \
    --gsp-output-len 1024 \
    --max-concurrency 6 \
    --num-prompts 6
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.