A PyTorch-based toolkit of from-scratch LLM implementations for pretraining, finetuning, evaluating and serving 20+ open-weight models.
kvcache-ai/ktransformers
A research framework for CPU-GPU heterogeneous LLM inference and LoRA/full fine-tuning of large MoE models on limited GPU memory.
- Stars
- 19,621
- Forks
- 1,602
- Open issues
- 526
- Last commit
- 2 days ago
What is it?
KTransformers is a research project for running and fine-tuning large language models by splitting work between CPU and GPU. Its inference side provides CPU-optimized kernels for INT4/INT8 quantized weights, with AMX and AVX512/AVX2 acceleration and NUMA-aware memory management for Mixture-of-Experts models. Hot experts can be placed on the GPU while cold experts stay on the CPU, and the kernels offer a Python API for integration with SGLang.
The fine-tuning side integrates with LLaMA-Factory to support LoRA and full-parameter training of ultra-large MoE models such as DeepSeek-V3/R1, Qwen3 MoE and Kimi K2 variants on limited GPU memory. The project also documents BF16, FP8 and INT8 configurations, resource planning and troubleshooting, and publishes a research paper on its heterogeneous MoE fine-tuning approach.
Key features
- 01Intel AMX and AVX512/AVX2 optimized kernels for INT4/INT8 quantized inference
- 02CPU-GPU expert scheduling for MoE models, with hot experts on GPU and cold experts on CPU
- 03Python API for integration with SGLang
- 04LoRA and full-parameter fine-tuning integrated with LLaMA-Factory
- 05Support for BF16, FP8 and INT8 training configurations
Use cases
- Running large MoE models on a single GPU paired with a large-memory CPU server
- Serving MoE models through SGLang with CPU-GPU hybrid expert placement
- Fine-tuning ultra-large MoE models on a few consumer GPUs with LLaMA-Factory
Quick start
- 1
Go to the kt-kernel source directory
cd kt-kernel - 2
Install kt-kernel from source
pip install .
Things to know
- Built for specialized hardware, relying on Intel AMX or AVX512/AVX2 CPUs and GPUs for heterogeneous inference.
- Positioned as a research project, and the original integrated framework has been archived.
Topics
FAQ
- What is ktransformers?
- A research framework for CPU-GPU heterogeneous LLM inference and LoRA/full fine-tuning of large MoE models on limited GPU memory. KTransformers is a research project for running and fine-tuning large language models by splitting work between CPU and GPU. Its inference side provides CPU-optimized kernels for INT4/INT8 quantized weights, with AMX and AVX512/AVX2 acceleration and NUMA-aware memory management for Mixture-of-Experts models. Hot experts can be placed on the GPU while cold experts stay on the CPU, and the kernels offer a Python API for integration with SGLang.
- Is ktransformers free to use? What license does it have?
- ktransformers is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
- Is ktransformers still maintained?
- Actively maintained. The last commit to ktransformers was on Oct 20, 2026.
- What can I use ktransformers for?
- Running large MoE models on a single GPU paired with a large-memory CPU server Serving MoE models through SGLang with CPU-GPU hybrid expert placement Fine-tuning ultra-large MoE models on a few consumer GPUs with LLaMA-Factory
- How do I install ktransformers?
- Go to the kt-kernel source directory: cd kt-kernel Install kt-kernel from source: pip install .
- Where can I get ktransformers?
- The source code and installation instructions are on GitHub: https://github.com/kvcache-ai/ktransformers
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
Python library that runs large language models layer by layer so 70B-class models can infer on a single 4GB GPU, without quantization.
Inference code for EAGLE-4, a speculative decoding harness that speeds up LLM serving on SGLang, vLLM and TokenSpeed.
A pure C inference engine that runs very large mixture-of-experts models on ordinary hardware by streaming routed experts from disk.
A toolkit for compressing, deploying, and serving LLMs and vision-language models, with TurboMind and PyTorch inference engines.
Recipe for serving DeepSeek-V4.1-Flash-1017 (EXL3 2.9 bpw) across two NVIDIA DGX Sparks as an OpenAI-compatible API with a 1M-token window.