kvcache-ai/ktransformers

A Flexible Framework for Experiencing Heterogeneous LLM Inference/Fine-tune Optimizations

What it solves

KTransformers addresses the high hardware requirements for running and fine-tuning ultra-large Mixture-of-Experts (MoE) models. It allows these models to run on consumer-grade hardware by utilizing CPU-GPU heterogeneous computing, reducing the need for massive amounts of expensive GPU VRAM.

How it works

The framework employs a hybrid computing approach where different parts of the model are placed on different hardware. It uses "expert scheduling" to keep frequently used "hot" experts on the GPU while offloading "cold" experts to the CPU. To maintain performance, it utilizes optimized kernels for Intel AMX and AVX512/AVX2 for quantized inference and integrates with LlamaFactory to enable efficient fine-tuning (SFT) using techniques like LoRA and block-FP8, which can be significantly faster than traditional ZeRO-Offload methods.

Who it’s for

It is designed for researchers and developers who want to run or fine-tune cutting-edge large models (like DeepSeek-V3/R1 or GLM) on limited hardware, such as consumer GPUs or mixed CPU-GPU server setups.

Highlights

  • Heterogeneous Computing: Supports CPU-GPU hybrid inference and fine-tuning to lower VRAM barriers.
  • Hardware Acceleration: Optimized for Intel AMX, AVX512, AVX2, and supports ROCm (AMD) and Ascend NPUs.
  • MoE Optimization: Specialized memory management and expert scheduling for Mixture-of-Experts models.
  • Fine-Tuning Integration: Seamlessly integrates with LlamaFactory for LoRA and full-parameter fine-tuning of ultra-large models.

Related

  • Project
  • Project
  • Project
  • Project
  • Project