Skip to content
项目

关于

Blazing-fast LLM inference in pure Rust. No PyTorch and Python runtime.

人工智能与机器学习

这些数字如何统计

实测星标增长

24小时
0
7天
+4
15天
+4
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

ReadMe-CN.md

原文

xInfer
纯 Rust 实现的极速 LLM 推理引擎。无需 PyTorch,无需 Python 运行时,开箱即用。
English | 简体中文


✨ 为什么选择 xInfer?

特性 详情
0️⃣ 零 Python 依赖 纯 Rust 后端 — 不需要 PyTorch 或 CUDA Python 绑定
⚡ 极致性能 原生 Flash Attention、FlashInfer、CUDA Graphs、持续批处理、前缀缓存、PD 分离。消费级 GPU 上 30B+ 模型解码速度高达 197 tok/s
🪶 极简内核 核心调度 + 注意力逻辑仅 < 5000 行 Rust 代码
🌍 跨平台 CUDA(Linux/Windows)、Metal(macOS),统一二进制,统一 API
🏭 生产就绪 OpenAI/Anthropic 兼容 API、内置 ChatGPT 风格 Web UI、MCP 工具调用、结构化输出、Embedding + 分词器端点、MTP
🗜️ 极致 KV 压缩 TurboQuant(2–4 位 KV 缓存)以极小的质量损失将上下文扩展至 4.3 倍。单卡 24/32 GB GPU 即可运行 30B+ MoE 模型并支持百万级上下文
🔥 V100 + NVFP4 业界首创:V100 上运行 NVFP4 + 低位 KV 缓存推理 — 无需硬件 FP4,旧 GPU 重获新生
🐍 轻量 Python 绑定 需要 Python 入口时可选 PyO3 wheel 包

📽️ 演示


🚀 快速开始

📦 安装

方式 1 — 安装 DEB 或 Python包

curl -sSL https://guoqingbao.github.io/xinfer/install.sh | bash

方式 2 — npm

npm install -g xinfer-ai

install.sh 和 npm 会自动检测 GPU 的 CUDA 计算能力并下载对应的预编译二进制文件。


▶️ 运行

使用 HuggingFace 模型 ID:

xinfer --m Qwen/Qwen3.6-27B-FP8 --kvcache-dtype turbo4 --ui-server

使用本地模型路径:

xinfer --m /home/Qwen3.6-35B-A3B --d 0,1 --ui-server

Python 使用方式:

python3 -m xinfer.server --m Qwen/Qwen3.6-27B-FP8 --kvcache-dtype turbo4 --ui-server

推测解码(MTP 与 DFlash2)

内置 MTP(目标模型需包含 MTP 层):

xinfer --m Qwen/Qwen3.5-35B-A3B --d 0,1 --ui-server --num-speculative-tokens 3

外部 DFlash2 草稿模型:

xinfer --m Qwen/Qwen3.8-... --d 0,1 --ui-server \
  --draft-model <dflash2-草稿-id或路径> --num-speculative-tokens 7

详见 docs/speculative_decoding.md。

🧩 MoE 专家卸载

MoE 专家卸载仅支持 CUDA。将大型 MoE 模型的专家权重卸载到主机内存。该值使用比例表示:0.2 表示每层 20% 的专家保留在 GPU,auto 表示自动选择缓存大小。张量并行需要 NCCL。

XINFER_MOE_OFFLOAD=0.2 xinfer \
  --m Qwen/Qwen3.5-35B-A3B-FP8 --d 0,1 --ui-server

配置选项和 TP 详情请参阅 MoE 专家卸载指南。

提示: 浏览器打开 http://IP:8001 即可使用内置对话界面,或使用 http://IP:8000/v1/ 作为 API 服务 Base URL。


🗜️ KV 缓存压缩

添加 --kvcache-dtype 参数压缩 KV 缓存,扩展上下文长度:

参数(--kvcache-dtype) 压缩比 质量 GPU 要求
(默认) 1×(BF16) 基线 全部
fp8 2× 近无损 SM70+ / Apple M1
turbo8 2.6× 79–100% 基线吞吐 SM70+ / Apple M1
turbo4 3.7× 最佳平衡 SM70+ / Apple M1
turbo3 4.7× 最大压缩 SM70+

📈 性能

测试平台:V100-32G、A100-40G、Hopper-80G 及 RTX 5090

模型 格式 大小 输出速度 (非MTP)
Ministral-3-3B (多模态) ISQ (BF16→Q4K) 3B 193.67 tokens/s
Qwen3-VL-8B-Instruct (多模态) Q8_0 8B 112.51 tokens/s
Llama-3.1-8B ISQ (BF16→Q4K) 8B 133.10 tokens/s
DeepSeek-R1-0528-Qwen3-8B Q4_K_M 8B 161.60 tokens/s
GLM-4-9B-0414 Q4_K_M 9B 92.10 tokens/s
QwQ-32B Q4_K_M 32B 55.65 tokens/s
Qwen3-30B-A3B NVFP4 30B (MoE) 197.29 tokens/s (RTX 5090)
Qwen3-30B-A3B NVFP4 30B (MoE) 72.86 tokens/s (V100, Software FP4)
Qwen3-Next-80B AWQ 80B (MoE) 90 tokens/s (Hopper)
Qwen3.5/3.6/3.8 27B (多模态) Q4_K_M/IQ4 27B (Dense) 61.9 tokens/s
Qwen3.5/3.6/3.8 27B FP8 27B (Dense) 52.2 tokens/s (Hopper)
Qwen3.6-35B-A3B (多模态) FP8 35B (MoE) 120 tokens/s (Hopper)
GLM4.7 Flash NVFP4 30B (MoE) 79 tokens/s (Hopper, Software FP4)
Gemma4-31B ISQ (BF16→Q4K) 31B (Dense) 55 tokens/s (Hopper)
Gemma4-26B-A4B NVFP4 26B (MoE) 137.23 tokens/s (RTX 5090)
MiniMax-M2.5 NVFP4 229B (MoE) 64.50 tokens/s (Hopper, Software FP4, TP=2)
Apple Silicon (M4)
模型 并发数 输出 Tokens 耗时 (s) 吞吐量 (tokens/s)
Qwen3-0.6B (BF16) 128 63488 83.13s 763.73
Qwen3-0.6B (BF16) 32 15872 23.53s 674.43
Qwen3-0.6B (BF16) 1 456 9.23s 49.42
Qwen3-4B (Q4_K_M) 1 1683 52.62s 31.98
Qwen3-8B (Q2_K) 1 1300 80.88s 16.07
Qwen3.5-4B (Q3_K_M) 1 1592 69.04s 23.06
Qwen3.5-2B (NVFP4) 1 1883 60.76s 30.99
Qwen3.5-2B (NVFP4) 2 3942 81.96s 48.10

完整性能测试 →


🧠 支持的模型

  • ✅ LLaMa 系列(LLaMa2、LLaMa3、LLaMa4、IQuest-Coder)
  • ✅ Qwen 系列(Qwen2、Qwen3)
  • ✅ Qwen2/Qwen3 MoE 系列
  • ✅ Qwen3-Next 系列
  • ✅ Qwen3.5/3.6/3.8 Dense/MoE 系列(27B、35B、122B、397B、多模态)
  • ✅ Qwen3.8-Next/Qwen4 系列
  • ✅ Mistral v1、v2
  • ✅ Mistral-3-VL Reasoning(3B、8B、14B、多模态)
  • ✅ GLM4(0414 版本)
  • ✅ GLM4 MoE(4.6/4.7)
  • ✅ GLM4.7 Flash
  • ✅ GLM 5.2(DeepSeek V3.2 DSA 架构)
  • ✅ DeepSeek V3/R1/V3.2
  • ✅ DeepSeek V4(支持 通过 --isq w2 实现 2-bit权重加载)
  • ✅ Phi3 / Phi4(Phi-3、Phi-4、Phi-4-mini 等)
  • ✅ Gemma3/Gemma4(多模态)
  • ✅ Qwen3-VL(Dense、多模态)
  • ✅ MiroThinker-v1.5(30B、235B)

格式: Safetensors(BF16、FP8-blockwise、GPTQ、AWQ、MXFP4、NVFP4)| GGUF(所有量化类型)| ISQ(即时量化,含 DeepSeek V4 MoE 的 2-bit W2)

DeepSeek V4 Flash + 2-bit ISQ: --isq w2 在加载时将 MXFP4 路由专家重打包为 2-bit。双卡张量并行(--d 0,1)下,模型权重约占用 每卡 46 GB(合计 46 × 2 GB)。


TurboQuant KV 缓存 — 消费级 GPU 运行 30B+ 模型

TurboQuant 通过 Walsh-Hadamard 变换旋转 + 逐头 absmax 量化,将 KV 缓存压缩至 2–4 位。使用 turbo4 的最大上下文容量:

模型 KV 预算 BF16 turbo4 提升
Qwen3.6-35B-A3B(NVFP4) 7 GB(24 GB GPU) 70 万 270 万 3.9×
15 GB(32 GB GPU) 150 万 580 万 3.9×
Qwen3.6-27B(FP8) 7 GB 11.2 万 43.4 万 3.9×
15 GB 24 万 93 万 3.9×
Qwen3-30B-A3B(Q4_K_M) 7 GB 7.4 万 28.1 万 3.8×
15 GB 16 万 60.2 万 3.8×
Gemma4-26B-A4B(NVFP4) 7 GB 3.2 万 12.5 万 3.9×
15 GB 7 万 27.1 万 3.9×

混合架构模型(Qwen3.6)全注意力层数远少于总层数,TurboQuant 压缩效果尤为显著。MLA 模型(DeepSeek、GLM4.7 Flash)请搭配 fp8 使用。表中 KV 预算为理论最大值,实际可用量最高为 KV 预算的 90%(--kv-fraction 0.9),需为运行时和批处理预留缓冲空间。

# 35B MoE 单卡 24/32 GB 即可运行
xinfer --m unsloth/Qwen3.6-35B-A3B-NVFP4 --kvcache-dtype turbo4

# FP8 精度
xinfer --m Qwen/Qwen3.6-35B-A3B-FP8 --kvcache-dtype fp8

# 27B Dense + turbo4
xinfer --m Qwen/Qwen3.6-27B-FP8 --kvcache-dtype turbo4

# 26B Gemma4 (本地模型, 使用`--kv-fraction`选项增加kvcache占用)
xinfer --w /data/gemma-4-26B-A4B-it --ui-server --port 9000 --kv-fraction 0.8

# 30B MoE GGUF + turbo4
xinfer --m unsloth/Qwen3-30B-A3B-Instruct-2507-GGUF \
  --f Qwen3-30B-A3B-Instruct-2507-Q4_K_M.gguf --kvcache-dtype turbo4

# Metal/MacOS
xinfer --m unsloth/Qwen3.5-4B-GGUF --f Qwen3.5-4B-Q4_K_M.gguf

📘 使用方法

Python包安装后请使用 python3 -m xinfer.server 方式运行

Docker 内构建请参考 在 Docker 中运行 xInfer →

运行模型

提示: 默认启动 OpenAI 兼容 API 服务(http://localhost:8000)。添加 --ui-server 可同时启动内置 ChatGPT 风格 Web UI(http://localhost:8001)。

# FP8 模型(sm90+ 需启用 cutlass)+ Web UI
xinfer --m Qwen/Qwen3.6-27B-FP8 --ui-server

# 未量化 Safetensors(多卡)
xinfer --d 0,1 --m Qwen/Qwen3-30B-A3B-Instruct-2507 --kvcache-dtype fp8

# ISQ 即时量化
xinfer --m Qwen/Qwen3.6-35B-A3B --isq q4k

# DeepSeek V4 Flash(2-bit ISQ MoE,双卡约每卡 46 GB 权重)
xinfer --d 0,1 --m /path/DeepSeek-V4-Flash --isq w2 --kv-fraction 0.7 --ui-server

# NVFP4 模型
xinfer --m unsloth/Qwen3.6-27B-NVFP4

# MXFP4
xinfer --m olka-fi/Qwen3.5-4B-MXFP4

# GGUF 模型(4 位 KV 缓存)
xinfer --m unsloth/Qwen3.5-27B-GGUF --f Qwen3.5-27B-Q4_K_M.gguf --kvcache-dtype turbo4

# GGUF 多分片(自动检测 HF 子文件夹)
xinfer --d 0,1,2,3 --m unsloth/Qwen3.5-122B-A10B-GGUF --f Q3_K_M --kvcache-dtype fp8

# FP8 Metal
xinfer --m Qwen/Qwen3.5-4B-FP8

# Gemma4 26B(NVFP4)
xinfer --m unsloth/gemma-4-26b-a4b-it-NVFP4

# MLA 模型(GLM4.7 Flash)
xinfer --m GadflyII/GLM-4.7-Flash-NVFP4

# 交互式 CLI 对话
xinfer --i --m unsloth/Qwen3.5-27B-GGUF --f Qwen3.5-27B-Q4_K_M.gguf

# Hopper 上加速 GDN 预填充,精度略有损失
SM90_LOWER_PRECISION_GDN_PREFILL=1 xinfer --m Qwen/Qwen3.5-35B-A3B-FP8

# AWQ (pack-quantized)
xinfer --m cyankiwi/Qwen3-Coder-Next-AWQ-4bit

# 多节点推理: GLM 5.2(DeepSeek V3.2 架构,FP8)
# 主节点
xinfer --d 0,1,2,3,4,5,6,7 --m zai-org/GLM-5.2-FP8 --num-nodes 2 --node-rank 0 --master-addr 192.168.xxx.xxx
# 次节点
xinfer --d 0,1,2,3,4,5,6,7 --m zai-org/GLM-5.2-FP8 --num-nodes 2 --node-rank 1 --master-addr 192.168.xxx.xxx
ISQ 即时量化 + KV 缓存压缩
# ISQ Q4K + FP8 KV 缓存
xinfer --m Qwen/Qwen3.6-35B-A3B --isq q4k --kvcache-dtype fp8

# ISQ Q4K + TurboQuant KV 缓存
xinfer --m Qwen/Qwen3.6-35B-A3B --isq q4k --kvcache-dtype turbo4

# Metal ISQ
xinfer --m /path/Qwen3-4B --isq q6k

# DeepSeek V4 Flash:路由 MoE 专家 2-bit W2 ISQ(双卡 TP,约每卡 46 GB 权重)
xinfer --d 0,1 --m /path/DeepSeek-V4-Flash --isq w2 --kv-fraction 0.7
GGUF 模型
# 多卡 GGUF(模型 ID + 子文件夹)
xinfer --d 0,1,2,3 --m unsloth/Qwen3.5-122B-A10B-GGUF --f Q3_K_M

# 远程 GGUF — 单文件模型
xinfer --m unsloth/Qwen3.5-27B-GGUF --f Qwen3.5-27B-Q4_K_M.gguf

# 本地 GGUF 文件(直接路径)
xinfer --d 0,1 --m /path/Qwen3-30B-A3B-Instruct-2507-Q4_K_M.gguf

# 本地 GGUF 文件夹
xinfer --d 0,1,2,3 --m /path/to/Qwen3.5-122B-A10B-GGUF/Q3_K_M
TurboQuant KV 缓存(2–4 位压缩)— 详见 TurboQuant 专区
# turbo4: 4位 K+V — 3.7× 压缩,最佳平衡
xinfer --m Qwen/Qwen3.6-27B-FP8 --kvcache-dtype turbo4

# turbo3: 3位 K + 4位 V — 4.7× 压缩
xinfer --m Qwen/Qwen3.6-27B-FP8 --kvcache-dtype turbo3

# turbo8: FP8 K + 4位 V — 2.6× 压缩,最高质量
xinfer --m Qwen/Qwen3.6-27B-FP8 --kvcache-dtype turbo8

# 35B MoE(NVFP4 + turbo4)— 24 GB 单卡即可运行
xinfer --m unsloth/Qwen3.6-35B-A3B-NVFP4 --kvcache-dtype turbo4

# 30B MoE(GGUF Q4_K_M + turbo4)— 消费级 GPU
xinfer --m unsloth/Qwen3-30B-A3B-Instruct-2507-GGUF \
  --f Qwen3-30B-A3B-Instruct-2507-Q4_K_M.gguf --kvcache-dtype turbo4
多模态模型(Qwen3-VL, Gemma4, Mistral3-VL)
# 通过内置 Chat UI 上传图片或在 API 请求中传入 image_url

# Qwen3.6 35B MoE(FP8,多模态)
xinfer --m Qwen/Qwen3.6-35B-A3B-FP8 --ui-server

# Qwen3-VL 8B(GGUF)
xinfer --m unsloth/Qwen3-VL-8B-Instruct-GGUF --f Qwen3-VL-8B-Instruct-Q8_0.gguf --ui-server

# Gemma4 26B MoE(NVFP4,多模态)
xinfer --m unsloth/gemma-4-26b-a4b-it-NVFP4 --ui-server

# Mistral-3 VL 3B(BF16,多模态)
xinfer --m mistralai/Ministral-3-3B --ui-server

📘 从源码编译安装

方式 1 — Cargo

# 依赖项: Rust 编译器、CUDA 工具链(可选)、Metal 需安装 Xcode 命令行工具(可选)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
sudo apt-get install -y git build-essential

export XINFER_REPO="https://github.com/guoqingbao/xinfer"
# macOS/Metal:将特性替换为 `--features metal`
# SM_70/SM_75(如 V100):去掉 `flashinfer` 和 `cutlass` 编译选项
cargo install --git $XINFER_REPO xinfer --features cuda,nccl,flashinfer,cutlass

方式 2 — Docker

# Turing/V100 (sm_70/sm_75):去掉 `flashinfer` 和 `cutlass` 编译选项
./build_docker.sh "cuda,nccl,flashinfer,cutlass"

参考 Docker 指南 →

从源码编译 Python wheel
pip install maturin maturin[patchelf]

# FlashInfer 后端(SM80+)
./build.sh --release --features cuda,nccl,flashinfer,cutlass,python

# Flash Attention 后端
./build.sh --release --features cuda,nccl,flashattn,cutlass,python

# macOS Metal
maturin build --release --features metal,python

# 安装
pip install target/wheels/xinfer_ai-*.whl --force-reinstall

🌐 多机张量并行推理

跨多台机器分布式推理,基于 TCP 的 NCCL 引导,无需 MPI。

# 节点 0(主节点,192.168.1.100):调度器 + API 服务
xinfer --d 0,1,2,3 --m /data/DeepSeek-R1/ \
  --num-nodes 2 --node-rank 0 --master-addr 192.168.1.100 --ui-server

# 节点 1(工作节点,192.168.1.101):仅执行前向推理
xinfer --d 0,1,2,3 --m /data/DeepSeek-R1/ \
  --num-nodes 2 --node-rank 1 --master-addr 192.168.1.100

所有节点需本地存放模型权重,并通过 TCP 连接 --master-port(默认 29500)。详见 Get Started。


🔀 Prefill-Decode 分离(PD 分离)

将预填充(prompt 处理)和解码(token 生成)拆分到不同 GPU 或机器。消除长上下文预填充时的解码卡顿。PD 服务器与 PD 客户端必须使用相同 KvCache 数据类型(--kvcache-dtype)。对话请求需发送至 PD 客户端,PD 服务端只处理 PD 客户端发来的预填充请求。

模式 配置 适用场景
本地 IPC (默认,无需参数) 同一机器,CUDA
文件 IPC --pd-url file:///path Docker 容器,共享卷
远程 TCP --pd-url tcp://host:port 不同机器

单机多卡部署(无需指定 pd-url,默认使用 CUDA IPC)

# PD 服务器(预填充 GPU,默认端口 7000)
xinfer --d 0,1 --m Qwen/Qwen3-30B-A3B-Instruct-2507 --pd-server

# PD 客户端(解码 GPU + API 服务)
xinfer --d 2,3 --m /path/Qwen3-30B-A3B-Instruct-2507 --isq q4k --ui-server --port 8000 --pd-client

多机部署(tcp 模式)

# 服务器机器(192.168.1.100)
target/release/xinfer --d 0,1 --m Qwen/... --pd-server --pd-url tcp://0.0.0.0:8100

# 客户端机器
target/release/xinfer --d 0,1 --m /path/... --pd-client --pd-url tcp://192.168.1.100:8100 --ui-server --port 8000

Metal/macOS 不支持 Local IPC,必须指定 --pd-url。

多容器部署(file:// 模式)
mkdir -p /tmp/pd-sockets

# 服务器容器
docker run --gpus '"device=0,1"' -v /tmp/pd-sockets:/sockets ...
target/release/xinfer --d 0,1 --m Qwen/... --pd-server --pd-url file:///sockets

# 客户端容器
docker run --gpus '"device=2,3"' -v /tmp/pd-sockets:/sockets ...
target/release/xinfer --d 0,1 --m /path/... --pd-client --pd-url file:///sockets --ui-server --port 8000

🔌 MCP 工具调用

xinfer --m unsloth/Qwen3-30B-A3B-Instruct-2507-GGUF \
  --f Qwen3-30B-A3B-Instruct-2507-Q4_K_M.gguf --ui-server --mcp-config ./mcp.json

MCP 文档 →


🔌 结构化输出与引导解码

通过 llguidance 实现约束生成 — JSON Schema、正则表达式、Lark 语法、选项列表。

# 启用结构化输出和工具语法
xinfer --m Qwen/Qwen3.6-27B-FP8 --ui-server --enable-tool-grammar

结构化输出文档 →


📚 文档

指南 说明
快速开始 编译、运行与配置
Docker 容器构建与部署
性能测试 完整性能表
前缀缓存 自动 KV 缓存复用
多模态 视觉语言模型
Embedding 文本嵌入 API
分词器 API Tokenize / Detokenize 端点
工具调用解析 工具调用检测与解析
MCP 集成 Model Context Protocol
引导解码 结构化输出
Rust 库 作为 Rust 库使用
添加模型 移植新架构(AI 辅助)
测试模型 验证模型质量(AI 辅助)
CUDA 精度探针 定位 CUDA kernel 精度问题

在 xInfer 后端下使用 Agent: xbot · OpenCode · Kilo Code · Claude Code · Goose


⚙️ 命令行参数

参数 说明
--m 模型来源:HuggingFace 模型 ID、本地 Safetensors 目录、本地 GGUF 文件或包含 GGUF 文件的本地文件夹
--w 本地 Safetensors 目录的旧别名;新命令优先使用 --m <local_dir>
--f 单独使用时为本地 GGUF 文件;配合 --m <model_id> 时为远程 GGUF 文件名
--d 设备 ID(如 --d 0,1)
--ui-server API 服务 + ChatGPT 风格内置 Web UI
--server API 服务器。无参数:0.0.0.0:8000;或 host[:port]、file:///path、socket:///path、unix:///path
--i 交互式 CLI 对话
--isq 即时量化:q2k、q3k、q4k、q5k、q6k、q8_0、w2 / moe_w2
--kvcache-dtype KV 缓存量化:fp8、turbo8、turbo4、turbo3
--max-num-seqs 最大并发请求数(默认 32,macOS 为 8)
--max-tokens 单次最大输出 token 数(默认 16384)
--kv-fraction GPU 显存用于 KV 缓存的比例
--cpu-mem-fold CPU 交换显存比例(默认 0.2)
--pd-server 作为 PD 预填充服务器运行
--pd-client 作为 PD 解码客户端运行
--pd-url PD 连接 URL(tcp://、http://、file://)
--disable-prefix-cache 禁用前缀缓存
--prefix-cache-max-tokens 前缀缓存大小上限
--prefill-chunk-size 预填充分块大小 (默认: CUDA 8K, Metal: 4k)
--num-nodes 多机推理节点总数(默认 1)
--node-rank 当前节点编号(0 = 主节点)
--master-addr 主节点 IP(多机推理必填)
--master-port NCCL 引导端口(默认 29500)
--disable-cuda-graph 禁用 CUDA 图捕获
--yarn-scaling-factor YARN RoPE 上下文扩展因子
--temperature 采样温度(0–1)
--top-k / --top-p Top-k / 核采样
--presence-penalty 重复惩罚(−2 到 2)
--frequency-penalty 高频惩罚(−2 到 2)
--mcp-config MCP 服务器 JSON 配置
--mcp-command / --mcp-args 单个 MCP 服务器命令及参数
--num-speculative-tokens 每步推测草稿 token 数。在含 MTP 层的模型上启用内置 MTP,例如 --num-speculative-tokens 3
--draft-model 外部 DFlash2 草稿模型(HuggingFace ID 或本地目录)。设置后使用 DFlash2,而非内置 MTP。

环境变量

变量 描述
XINFER_NVFP4_FORCE_LUT=1 强制 NVFP4 软件解码使用 LUT(查找表)路径替代 Blackwell (SM100+) 硬件 FP4 指令。精度更高,适用于对解码精度有要求的场景。
XINFER_ENABLE_FLASHMLA 设置为 1 或 true 时启用 DeepSeek V4 稀疏 MLA 加速。默认未设置,因此默认使用保精度的自定义 BF16 稀疏注意力内核。
XINFER_SSE_BUFFER_SIZE=256 每个客户端连接的 SSE 流式缓冲区大小(默认:256)。对于慢速网络代理或高吞吐模型,可适当增大。
SM90_LOWER_PRECISION_GDN_PREFILL=1 在 Hopper (SM90) GPU 上启用 FlashInfer SM90 持久化内核加速 GatedDeltaNet (GDN) 预填充。可为 Qwen3.5/3.6 等混合架构模型带来预填充加速,但精度略有损失。

示例(Blackwell 高精度 NVFP4 解码):

XINFER_NVFP4_FORCE_LUT=1 xinfer --m nvidia/Qwen3-30B-A3B-FP4 --ui-server

示例(Hopper 上加速 GDN 预填充):

SM90_LOWER_PRECISION_GDN_PREFILL=1 xinfer --m Qwen/Qwen3.5-35B-A3B-FP8 --ui-server

🛠️ 开发计划

  • Metal 平台支持批量推理
  • 支持 GGUF 格式
  • CUDA 平台 Flash Attention 支持
  • CUDA Graph
  • OpenAI API 兼容服务器(支持流式输出)
  • 持续批处理
  • 多卡并行推理(Safetensors 模型、GPTQ/AWQ 及 GGUF 量化模型)
  • 多机张量并行推理(基于 TCP 的 NCCL 引导,无需 MPI)
  • Metal/macOS 平台 Prompt 处理加速
  • 分块预填充(Chunked Prefill)
  • 前缀缓存(使用 prefix-cache 参数)
  • 从 HuggingFace Hub 下载并加载模型
  • 从 ModelScope 下载并加载(中国大陆地区)
  • Metal/macOS 平台前缀缓存
  • FP8 KV Cache(CUDA,所有后端,FlashInfer 支持 SM80+)
  • FP8 KV Cache(Metal)
  • FP8 KV Cache(FlashInfer,SM80+)
  • TurboQuant KV Cache(2-4 位压缩,WHT 旋转量化)
  • FP8 模型(CUDA: MoE, Dense; Metal: Dense)
  • GLM 5.2(DeepSeek V3.2 + DSA)
  • DeepSeek V4(Flash)+ 2-bit W2 ISQ MoE(约每卡 46 GB 权重 × 2)
  • 支持更多模型类型(Kimi K2 等)
  • CPU KV Cache 卸载
  • PD(Prefill/Decode)分离(CUDA)
  • PD(Prefill/Decode)分离(Metal)
  • 内置 ChatGPT 风格 Web 网页服务
  • Embedding API
  • Tokenize/Detokenize API
  • MCP 集成与工具调用
  • 公共前缀缓存
  • Claude/Anthropic API 兼容服务器
  • 支持 CUDA 13
  • 支持 FlashInfer 后端
  • 支持 DeepGEMM 后端(Hopper)
  • MXFP4/NVFP4 模型支持
  • 支持 Turboquant(4 位、3 位)KvCache
  • TentorRT-LLM
  • 多 token 预测(MTP)与 DFlash2 推测解码

📚 参考项目

Star History

喜欢这个项目?欢迎 ⭐ 收藏和参与贡献!

探索相关项目

加载中…