kvcache-ai / ktransformers
kvcache-ai / ktransformers
A Flexible Framework for Experiencing Cutting-edge LLM Inference/Fine-tune Optimizations 一个用于体验前沿大语言模型(LLM)推理与微调优化的灵活框架。
🎯 Overview | 🚀 Inference | 🎓 SFT | 🔥 Citation | 🚀 Roadmap(2026Q2) 🎯 概述 | 🚀 推理 | 🎓 微调 (SFT) | 🔥 引用 | 🚀 路线图 (2026年第二季度)
🎯 Overview
🎯 概述
KTransformers is a research project focused on efficient inference and fine-tuning of large language models through CPU-GPU heterogeneous computing. The project now exposes two user-facing capabilities from the kt-kernel source tree: Inference and SFT. KTransformers 是一个专注于通过 CPU-GPU 异构计算实现大语言模型高效推理与微调的研究项目。目前,该项目通过 kt-kernel 源码树向用户提供两大核心功能:推理(Inference)与微调(SFT)。
🔥 Updates
🔥 更新日志
- June 21, 2026: MiniMax-M3 Day0 Support! (Tutorial) 2026年6月21日:支持 MiniMax-M3 首日适配!(教程)
- June 17, 2026: GLM-5.2 Day0 Support! (Tutorial) 2026年6月17日:支持 GLM-5.2 首日适配!(教程)
- May 6, 2026: KTransformers at GOSIM Paris 2026 — “Agentic AI on Edge” track. We’ll present KT’s inference performance on consumer hardware. 2026年5月6日:KTransformers 亮相 GOSIM Paris 2026 —— “边缘智能体 AI”专题。我们将展示 KT 在消费级硬件上的推理性能。
- May 02, 2026: DeepSeek-V4-Flash Support! (Tutorial) 2026年5月2日:支持 DeepSeek-V4-Flash!(教程)
- Apr 30, 2026: KTransformers v0.6.1 refreshes kt-kernel inference and SFT docs with separate Inference and SFT Quick Start entry points. 2026年4月30日:KTransformers v0.6.1 更新了 kt-kernel 推理与微调文档,提供了独立的推理与微调快速入门入口。
- Mar 26, 2026: Support AVX2-only CPU backend for KT-Kernel inference. (Tutorial) 2026年3月26日:支持仅含 AVX2 指令集的 CPU 后端进行 KT-Kernel 推理。(教程)
- Feb 13, 2026: MiniMax-M2.5 Day0 Support! (Tutorial) 2026年2月13日:支持 MiniMax-M2.5 首日适配!(教程)
- Feb 12, 2026: GLM-5 Day0 Support! (Tutorial) 2026年2月12日:支持 GLM-5 首日适配!(教程)
- Jan 27, 2026: Kimi-K2.5 Day0 Support! (Tutorial) (SFT Tutorial) 2026年1月27日:支持 Kimi-K2.5 首日适配!(教程)(微调教程)
- Jan 22, 2026: Support CPU-GPU Expert Scheduling, Native BF16 and FP8 per channel Precision and AutoDL unified fine-tuning and inference. 2026年1月22日:支持 CPU-GPU 专家调度、原生 BF16 和 FP8 通道精度,以及 AutoDL 统一微调与推理。
- Dec 24, 2025: Support Native MiniMax-M2.1 inference. (Tutorial) 2025年12月24日:支持原生 MiniMax-M2.1 推理。(教程)
- Dec 22, 2025: Support RL-DPO fine-tuning with LLaMA-Factory. (Tutorial) 2025年12月22日:支持通过 LLaMA-Factory 进行 RL-DPO 微调。(教程)
- Dec 5, 2025: Support Native Kimi-K2-Thinking inference (Tutorial) 2025年12月5日:支持原生 Kimi-K2-Thinking 推理。(教程)
- Nov 6, 2025: Support Kimi-K2-Thinking inference (Tutorial) and fine-tune (Tutorial) 2025年11月6日:支持 Kimi-K2-Thinking 推理(教程)与微调(教程)。
- Nov 4, 2025: KTransformers Fine-Tuning × LLaMA-Factory Integration. (Tutorial) 2025年11月4日:KTransformers 微调与 LLaMA-Factory 集成。(教程)
- Oct 27, 2025: Support Ascend NPU. (Tutorial) 2025年10月27日:支持昇腾 NPU。(教程)
- Oct 10, 2025: Integrating into SGLang. (Roadmap, Blog) 2025年10月10日:集成至 SGLang。(路线图,博客)
- Sept 11, 2025: Support Qwen3-Next. (Tutorial) 2025年9月11日:支持 Qwen3-Next。(教程)
- Sept 05, 2025: Support Kimi-K2-0905. (Tutorial) 2025年9月5日:支持 Kimi-K2-0905。(教程)
- July 26, 2025: Support SmallThinker and GLM4-MoE. (Tutorial) 2025年7月26日:支持 SmallThinker 和 GLM4-MoE。(教程)
- July 11, 2025: Support Kimi-K2. (Tutorial) 2025年7月11日:支持 Kimi-K2。(教程)
- June 30, 2025: Support 3-layer (GPU-CPU-Disk) prefix cache reuse. 2025年6月30日:支持三层(GPU-CPU-磁盘)前缀缓存复用。
- May 14, 2025: Support Intel Arc GPU (Tutorial). 2025年5月14日:支持 Intel Arc GPU。(教程)
- Apr 29, 2025: Support AMX-Int8、 AMX-BF16 and Qwen3MoE (Tutorial) 2025年4月29日:支持 AMX-Int8、AMX-BF16 和 Qwen3MoE。(教程)
- Apr 9, 2025: Experimental support for LLaMA 4 models (Tutorial). 2025年4月9日:实验性支持 LLaMA 4 模型。(教程)
- Apr 2, 2025: Support Multi-concurrency. (Tutorial). 2025年4月2日:支持多并发。(教程)
- Mar 15, 2025: Support ROCm on AMD GPU (Tutorial). 2025年3月15日:支持 AMD GPU 上的 ROCm。(教程)
- Mar 5, 2025: Support unsloth 1.58/2.51 bits weights and IQ1_S/FP8 hybrid weights. Support 139K Longer Context for DeepSeek-V3 and R1 in 24GB VRAM. 2025年3月5日:支持 unsloth 1.58/2.51 位权重及 IQ1_S/FP8 混合权重。支持在 24GB 显存下实现 DeepSeek-V3 和 R1 的 139K 长上下文。
- Feb 25, 2025: Support FP8 GPU kernel for DeepSeek-V3 and R1; Longer Context. 2025年2月25日:支持 DeepSeek-V3 和 R1 的 FP8 GPU 内核;支持更长上下文。
- Feb 15, 2025: Longer Context (from 4K to 8K for 24GB VRAM) & Slightly Faster Speed (+15%, up to 16 Tokens/s), update docs and online books. 2025年2月15日:更长上下文(24GB 显存下从 4K 提升至 8K)及更快的速度(+15%,最高达 16 Tokens/s),更新文档与在线书籍。
- Feb 10, 2025: Support Deepseek-R1 and V3 on single (24GB VRAM)/multi gpu and 382G DRAM, up to 3
28x speedup. 2025年2月10日:支持在单卡(24GB 显存)/多卡 GPU 及 382G 内存上运行 Deepseek-R1 和 V3,最高可达 328 倍加速。
📦 Capabilities
📦 功能特性
🚀 Inference - High-Performance kt-kernel Serving
🚀 推理 - 高性能 kt-kernel 服务
CPU-optimized kernel operations for heterogeneous LLM inference. 为异构 LLM 推理提供 CPU 优化的内核操作。
Key Features: 核心特性:
- AMX/AVX Acceleration: Intel AMX and AVX512/AVX2 optimized kernels for INT4/INT8 quantized inference AMX/AVX 加速: 针对 INT4/INT8 量化推理的 Intel AMX 和 AVX512/AVX2 优化内核。
- MoE Optimization: Efficient Mixture-of-Experts inference with NUMA-aware memory management MoE 优化: 具备 NUMA 感知内存管理的高效混合专家模型(MoE)推理。
- Quantization Support: CPU-side INT4/INT8 quantized weights, GPU-side GPTQ support 量化支持: CPU 端 INT4/INT8 量化权重,GPU 端 GPTQ 支持。
- Easy Integration: Clean Python API for SGLang and other frameworks 易于集成: 为 SGLang 及其他框架提供简洁的 Python API。
Quick Start: 快速入门:
cd kt-kernel
pip install .
🎓 SFT - Fine-Tuning with LLaMA-Factory
🎓 微调 (SFT) - 基于 LLaMA-Factory 的微调
KTransformers × LLaMA-Factory integration for ultra-large MoE model fine-tuning. KTransformers 与 LLaMA-Factory 集成,用于超大规模 MoE 模型的微调。
Key Features: 核心特性:
- Multi-Backend Support: CPU/GPU hybrid fine-tuning with INT8/INT4 quantization 多后端支持: 结合 INT8/INT4 量化的 CPU/GPU 混合微调。
- Ultra-Large MoE Support: Fine-tune models like DeepSeek-V3/R1 on limited GPU memory 超大规模 MoE 支持: 在有限的 GPU 显存下微调 DeepSeek-V3/R1 等模型。
- Faster than ZeRO-Offload: 6-12x training speedup in benchmarked MoE SFT workloads 比 ZeRO-Offload 更快: 在基准 MoE 微调任务中,训练速度提升 6-12 倍。
- Lower CPU Memory: About half the CPU memory of the previous KT SFT path in the benchmarked setup 更低的 CPU 内存占用: 在基准测试配置中,CPU 内存占用仅为之前 KT 微调路径的一半。
Quick Start: 快速入门:
cd /path/to/LLaMA-Factory
pip install -e .
pip install -r requirements/ktransformers.txt
CUDA_VISIBLE_DEVICES=0,1,2,3 accelerate launch \
--config_file examples/ktransformers/accelerate/fsdp2_kt_int8.yaml \
src/train.py \
examples/ktransformers/train_lora/qwen3_5moe_lora_sft_kt.yaml
🔥 Citation
🔥 引用
If you use KTransformers in your research, please cite our paper: 如果您在研究中使用了 KTransformers,请引用我们的论文:
@inproceedings{10.1145/3731569.3764843,
title = {KTransformers: Unleashing the Full Potential of CPU/GPU Hybrid Inference for MoE Models},
author = {Chen, Hongtao and Xie, Weiyu and Zhang, Boxin and Tang, Jingqi and Wang, Jiahao and Dong, Jianwei and Chen, Shaoyuan and Yuan, Ziwei and Lin, Chen and Qiu, Chengyu and Zhu, Yuening and Ou, Qingliang and Liao, Jiaqi and Chen, Xianglin and Ai, Zhiyuan and Wu, Yongwei and Zhang, Mingxing},
booktitle = {Proceedings of the ACM SIGOPS 31st Symposium on Operating Systems Principles},
year = {2025}
}
👥 Contributors & Team
👥 贡献者与团队
Developed and maintained by: 由以下团队开发与维护:
- MADSys Lab @ Tsinghua University
- Approaching.AI
- 9#AISoft
- Community contributors
We welcome contributions! Please feel free to submit issues and pull requests. 我们欢迎社区贡献!请随时提交 Issue 和 Pull Request。