Repository metrics
- Stars
-  (17,254 åã®ã¹ã¿ãŒ)
- PR merge metrics
-  (å¹³åããŒãž 2d) (30d ã§ 10 merged PRs)
説æ
[!NOTE] Please avoid creating issues regarding the following questions, as they might be closed without a response. 请é¿å å建äžäžè¿°é®é¢æå ³ç issuesïŒè¿äº issues å¯èœäžäŒè¢«åå€ã
[!TIP] Documentation: https://kvcache-ai.github.io/ktransformers/ äžæææ¡£ïŒhttps://github.com/kvcache-ai/ktransformers/tree/main/doc/zh
Most of problems / 倧倿°é®é¢
How to install kt-kernel/ æä¹å®è£ kt-kernel
Please update repository and install again following the link below: 请åèææ¡£è¿è¡å®è£ ïŒä»¥ååžžè§é®é¢æå¯ŒïŒ https://github.com/kvcache-ai/ktransformers/blob/main/kt-kernel/README.md
Inference with kt-kernel+Sglang/ åš kt-kernel + Sglang äžæšç
1. Install SGLang
git clone https://github.com/sgl-project/sglang.git
cd sglang
pip install -e "python[all]"
2. Prepare Weights
You need both GPU weights and CPU weights for heterogeneous inference:
GPU Weights: Use the original / quantized model weights.
CPU Weights: Quantize to AMX-optimized format using the conversion script:
python scripts/convert_cpu_weights.py \
--input-path /path/to/model \
--input-type bf16 \ # Depends on your GPU weights type: fp8, fp16, or bf16
--output /path/to/cpu-weights \
--quant-method int8 # or int4
Supported input formats: FP8, FP16, BF16 â INT4/INT8.
For more details, see:
Note: LLAMAFILE backend supports GGUF format directly, but this feature is still in preview.
3. Launch SGLang Server
Start the SGLang server with your normal SGLang parameters, and add the following KT-Kernel specific parameters to enable CPU-GPU heterogeneous inference:
KT-Kernel Parameters to Add:
--kt-method: Backend method (AMXINT4, AMXINT8, or LLAMAFILE)--kt-weight-path: Path to the converted CPU weights--kt-cpuinfer: Number of CPU inference threads (set to physical cores)--kt-threadpool-count: Number of thread pools (set to NUMA node count)--kt-num-gpu-experts: Number of experts to keep on GPU--kt-max-deferred-experts-per-token: Deferred experts for pipelined execution
Example:
python -m sglang.launch_server \
[your normal SGLang parameters...] \
--kt-method AMXINT8 \
--kt-weight-path /path/to/cpu-weights \
--kt-cpuinfer 64 \
--kt-threadpool-count 2 \
--kt-num-gpu-experts 32 \
--kt-max-deferred-experts-per-token 2
Support models/ æ¯æçæš¡åå衚
| Model_name/ æš¡ååç§° | have_tested/ æ¯åŠæµè¯è¿ |
|---|---|
| GLM-4.5-Air | :white_check_mark: |
| GLM-4.5 | :white_check_mark: |
| Qwen3-30B-A3B | :white_check_mark: |
| Qwen3-235B-A22B-Thinking-2507 | :white_check_mark: |
| Qwen3-235B-A22B-Instruct-2507 | :white_check_mark: |
| Qwen3-Next-80B-A3B-Thinking | :white_check_mark: |
| DeepSeek-R1-0528 | :white_check_mark: |
[!NOTE] In principle, we can support any model that SGLang supports. If a model cannot run, then SGLang running purely on GPU likely won't be able to either. So if you test additional models that work, feel free to share them.
Known Issues & Tips / å·²ç¥é®é¢äžæç€º
"KT fallback" log messages are normal / "KT fallback" æ¥å¿æ¯æ£åžžç
If you see logs like KT fallback: layer X prepare weight = XXms, compute = XXms, this is expected behavior indicating that Layer-wise Prefill is working correctly. The "fallback" naming is misleading and will be updated in a future release.
åŠæçå°ç±»äŒŒ KT fallback: layer X prepare weight = XXms çæ¥å¿ïŒè¿æ¯é¢æè¡äžºïŒè¯Žæ Layer-wise Prefill å·²æ£åžžå¯åšã"fallback" è¿äžªåç§°æè¯¯å¯Œæ§ïŒåç»çæ¬äŒäŒåã
Low GPU utilization during prefill / Prefill é¶æ®µ GPU å©çšçäœ
If your GPU utilization is low during prefill, enable Layer-wise Prefill by adding:
--kt-gpu-prefill-token-threshold 2048
This allows the GPU to participate in prefill computation, significantly improving prefill throughput.
åŠæ prefill é¶æ®µ GPU å©çšçåŸäœïŒè¯·æ·»å --kt-gpu-prefill-token-threshold 2048 åæ°åŒå¯ Layer-wise Prefillã
GPTQ_INT4 + tensor-parallel-size > 1 / GPTQ_INT4 äžå€å¡ TP äžå Œå®¹
GPTQ-Int4 quantized MoE models may fail with IndexError: start out of range when using tensor-parallel-size > 1 with GPU experts. This is an SGLang-side weight loader issue. Workarounds:
- Use
--tensor-parallel-size 1 - Use FP8 weights instead of GPTQ-Int4
GPTQ-Int4 éåç MoE æš¡ååš tensor-parallel-size > 1 äžäœ¿çš GPU experts æ¶å¯èœæ¥éãè¿æ¯ SGLang 䟧çé®é¢ã建议éäœ TP æäœ¿çš FP8 æéã
[!TIP] If the problems still exist with the latest code, please create an issue. è¥äœ¿çšææ°ç代ç ä»ç¶æ æ³è§£å³é®é¢ïŒè¯·å建äžäžª issueã