Configs2026年7月21日·1 分钟阅读

KTransformers — Heterogeneous LLM Inference and Optimization Framework

A framework for running large language models efficiently on mixed hardware by combining CPU and GPU resources for inference and fine-tuning.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
KTransformers Overview
直接安装命令
npx -y tokrepo@latest install 8ea5de12-84c1-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

KTransformers is an inference framework designed to run large language models on heterogeneous hardware. It lets you split model layers across CPU and GPU, making it possible to run models that exceed your GPU memory by offloading parts to system RAM while maintaining reasonable throughput.

What KTransformers Does

  • Splits model layers across CPU and GPU for mixed-hardware inference
  • Runs models larger than available VRAM by offloading to system memory
  • Optimizes inference throughput with custom CUDA kernels
  • Supports quantized models to reduce memory requirements
  • Provides an OpenAI-compatible API server for easy integration

Architecture Overview

KTransformers analyzes the transformer architecture and assigns each layer to the most appropriate compute device. Attention layers that benefit from parallelism go to the GPU, while less compute-intensive layers can run on CPU. A scheduler coordinates data transfer between devices, minimizing PCIe bottleneck. The framework includes optimized kernels for both CPU (AVX/AMX) and GPU (CUDA) execution paths.

Self-Hosting & Configuration

  • Install via pip with CUDA toolkit and compatible PyTorch
  • Specify a model path or Hugging Face model ID
  • Configure CPU/GPU layer split ratios in the config file
  • Set quantization level (4-bit, 8-bit) for memory optimization
  • Launch the built-in API server for OpenAI-compatible access

Key Features

  • Heterogeneous execution across CPU and GPU devices
  • Runs 70B+ parameter models on consumer hardware with sufficient RAM
  • Custom optimized kernels for both CPU and GPU paths
  • Quantization support for reduced memory footprint
  • Drop-in OpenAI API compatibility for existing applications

Comparison with Similar Tools

  • llama.cpp — Pure CPU/Metal inference in C++; KTransformers focuses on hybrid CPU+GPU with Python integration
  • vLLM — High-throughput GPU serving; KTransformers targets heterogeneous hardware when full GPU memory is unavailable
  • ExLlamaV2 — GPU-focused quantized inference; KTransformers adds CPU offloading for larger models
  • Ollama — User-friendly local LLM runner; KTransformers gives more control over layer placement and optimization

FAQ

Q: What hardware do I need to run KTransformers? A: A CUDA-capable GPU with at least 8 GB VRAM and sufficient system RAM. Larger models require more RAM for CPU-offloaded layers.

Q: How does KTransformers compare to running entirely on GPU? A: Pure GPU inference is faster, but KTransformers lets you run models that would not fit in VRAM by offloading layers to CPU.

Q: Does KTransformers support fine-tuning? A: Yes, it supports fine-tuning optimizations alongside inference on heterogeneous hardware.

Q: What model formats does KTransformers support? A: It supports Hugging Face Transformers format and various quantization formats including GPTQ and AWQ.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产