{"id":50475705,"url":"https://github.com/guoqingbao/xinfer","last_synced_at":"2026-06-01T13:01:32.255Z","repository":{"id":300047778,"uuid":"1004914097","full_name":"guoqingbao/xinfer","owner":"guoqingbao","description":"Blazing-fast LLM inference in pure Rust. No PyTorch and Python runtime.","archived":false,"fork":false,"pushed_at":"2026-05-30T17:03:13.000Z","size":2274,"stargazers_count":240,"open_issues_count":60,"forks_count":31,"subscribers_count":5,"default_branch":"main","last_synced_at":"2026-05-30T19:05:00.076Z","etag":null,"topics":["agent","llm","qwen","rust","vllm"],"latest_commit_sha":null,"homepage":"http://guoqingbao.github.io/xinfer/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/guoqingbao.png","metadata":{"files":{"readme":"ReadMe-CN.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-19T11:26:35.000Z","updated_at":"2026-05-30T07:56:50.000Z","dependencies_parsed_at":"2026-02-12T17:06:04.973Z","dependency_job_id":null,"html_url":"https://github.com/guoqingbao/xinfer","commit_stats":null,"previous_names":["guoqingbao/vllm.rs","guoqingbao/xinfer"],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/guoqingbao/xinfer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guoqingbao%2Fxinfer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guoqingbao%2Fxinfer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guoqingbao%2Fxinfer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guoqingbao%2Fxinfer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/guoqingbao","download_url":"https://codeload.github.com/guoqingbao/xinfer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guoqingbao%2Fxinfer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33775864,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-01T02:00:06.963Z","response_time":115,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent","llm","qwen","rust","vllm"],"created_at":"2026-06-01T13:01:31.473Z","updated_at":"2026-06-01T13:01:32.247Z","avatar_url":"https://github.com/guoqingbao.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"logo.svg\" alt=\"xInfer\" width=\"400\"\u003e\u003cbr\u003e\n  \u003cb\u003e纯 Rust 实现的极速 LLM 推理引擎。\u003c/b\u003e无需 PyTorch，无需 Python 运行时，开箱即用。\u003cbr\u003e\n  \u003ca href=\"./ReadMe.md\"\u003eEnglish\u003c/a\u003e | \u003ca href=\"./ReadMe-CN.md\"\u003e简体中文\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\n## ✨ 为什么选择 xInfer？\n\n| | 特性 | 详情 |\n|---|---|---|\n| **0️⃣** | 零 Python 依赖 | 纯 Rust 后端 — 不需要 PyTorch 或 CUDA Python 绑定 |\n| **⚡** | 极致性能 | 原生 Flash Attention、FlashInfer、CUDA Graphs、持续批处理、前缀缓存、PD 分离。消费级 GPU 上 `30B+` 模型解码速度高达 **181 tok/s** |\n| **🪶** | 极简内核 | 核心调度 + 注意力逻辑仅 **\u003c 5000 行** Rust 代码 |\n| **🌍** | 跨平台 | CUDA（Linux/Windows）、Metal（macOS），统一二进制，统一 API |\n| **🏭** | 生产就绪 | OpenAI/Anthropic 兼容 API、内置 ChatGPT 风格 Web UI、MCP 工具调用、结构化输出、Embedding + 分词器端点 |\n| **🗜️** | 极致 KV 压缩 | TurboQuant（`2–4 位` KV 缓存）以极小的质量损失将上下文扩展至 **4.3 倍**。单卡 24/32 GB GPU 即可运行 `30B+` MoE 模型并支持**百万级上下文** |\n| **🔥** | V100 + NVFP4 | 业界首创：V100 上运行 NVFP4 + 低位 KV 缓存推理 — 无需硬件 FP4，旧 GPU 重获新生 |\n| **🐍** | 轻量 Python 绑定 | 需要 Python 入口时可选 PyO3 wheel 包 |\n\n---\n\n## 🚀 快速开始\n\n### 📦 安装\n\n**方式 1 — 安装 DEB 或 Python包**\n```bash\ncurl -sSL https://guoqingbao.github.io/xinfer/install.sh | bash\n```\n\n**方式 2 — npm**\n```bash\nnpm install -g xinfer-ai\n```\ninstall.sh 和 npm 会自动检测 GPU 的 CUDA 计算能力并下载对应的预编译二进制文件。\n\n---\n\n### ▶️ 运行\n\n**使用 HuggingFace 模型 ID：**\n```bash\nxinfer --m Qwen/Qwen3.6-27B-FP8 --kvcache-dtype turbo4 --ui-server\n```\n\n**使用本地模型路径：**\n```bash\nxinfer --w /home/Qwen3.6-35B-A3B --d 0,1 --ui-server\n```\n\n**Python 使用方式：**\n```bash\npython3 -m xinfer.server --m Qwen/Qwen3.6-27B-FP8 --kvcache-dtype turbo4 --ui-server\n```\n\n\u003e **提示：** 浏览器打开 `http://IP:8001` 即可使用内置对话界面，或使用 `http://IP:8000/v1/` 作为 API 服务 `Base URL`。\n\n---\n\n### 🗜️ KV 缓存压缩\n\n添加 `--kvcache-dtype` 参数压缩 KV 缓存，扩展上下文长度：\n\n| 参数（`--kvcache-dtype`） | 压缩比 | 质量 | GPU 要求 |\n|---|---|---|---|\n| _（默认）_ | 1×（BF16） | 基线 | 全部 |\n| `fp8` | **2×** | 近无损 | SM70+ / Apple M1 |\n| `turbo8` | **2.6×** | 79–100% 基线吞吐 | SM70+ / Apple M1|\n| `turbo4` | **3.7×** | 最佳平衡 | SM70+ / Apple M1|\n| `turbo3` | **4.7×** | 最大压缩 | SM70+ |\n\n---\n\n## 📈 性能\n\n\u003e 测试平台：**V100-32G**、**A100-40G**、**Hopper-80G** 及 **RTX 5090**\n\n| 模型 | 格式 | 大小 | 输出速度 |\n|---|---|---|---|\n| Ministral-3-3B (**多模态**) | ISQ (BF16→Q4K) | 3B | **193.67** tokens/s |\n| Qwen3-VL-8B-Instruct (**多模态**) | Q8_0 | 8B | **112.51** tokens/s |\n| Llama-3.1-8B | ISQ (BF16→Q4K) | 8B | **133.10** tokens/s |\n| DeepSeek-R1-0528-Qwen3-8B | Q4_K_M | 8B | **139.25** tokens/s |\n| GLM-4-9B-0414 | Q4_K_M | 9B | **77.48** tokens/s |\n| QwQ-32B | Q4_K_M | 32B | **46.02** tokens/s |\n| **Qwen3-30B-A3B** | NVFP4 | **30B (MoE)** | **181.59** tokens/s (**RTX 5090**) |\n| **Qwen3-30B-A3B** | NVFP4 | **30B (MoE)** | **72.86** tokens/s (**V100, Software FP4**) |\n| **Qwen3.5-27B** (**多模态**) | Q4_K_M | **27B (Dense)** | **49.33** tokens/s |\n| **Qwen3.5-27B/Qwen3.6-27B** | FP8 | **27B (Dense)** | **45** tokens/s (**Hopper**) |\n| **Qwen3.6-35B-A3B** (**多模态**) | FP8 | **35B (MoE)** | **110** tokens/s (**Hopper**) |\n| **GLM4.7 Flash** | NVFP4 | **30B (MoE)** | **79** tokens/s (**Hopper, Software FP4**) |\n| **Gemma4-31B** | ISQ (BF16→Q4K) | **31B (Dense)** | **47** tokens/s (**Hopper**) |\n| **Gemma4-26B-A4B** | NVFP4 | **26B (MoE)** | **137.23** tokens/s (**RTX 5090**) |\n| **MiniMax-M2.5** | NVFP4 | **229B (MoE)** | **64.50** tokens/s (**Hopper, Software FP4, TP=2**) |\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eApple Silicon (M4)\u003c/b\u003e\u003c/summary\u003e\n\n| 模型 | 并发数 | 输出 Tokens | 耗时 (s) | 吞吐量 (tokens/s) |\n|---|---|---|---|---|\n| Qwen3-0.6B (BF16) | 128 | 63488 | 83.13s | 763.73 |\n| Qwen3-0.6B (BF16) | 32 | 15872 | 23.53s | 674.43 |\n| Qwen3-0.6B (BF16) | 1 | 456 | 9.23s | 49.42 |\n| Qwen3-4B (Q4_K_M) | 1 | 1683 | 52.62s | 31.98 |\n| Qwen3-8B (Q2_K) | 1 | 1300 | 80.88s | 16.07 |\n| Qwen3.5-4B (Q3_K_M) | 1 | 1592 | 69.04s | 23.06 |\n| Qwen3.5-2B (NVFP4) | 1 | 1883 | 60.76s | 30.99 |\n| Qwen3.5-2B (NVFP4) | 2 | 3942 | 81.96s | 48.10 |\n\n\u003c/details\u003e\n\n[完整性能测试 →](docs/performance.md)\n\n---\n\n## 🧠 支持的模型\n\n* ✅ LLaMa 系列（LLaMa2、LLaMa3、**LLaMa4**、IQuest-Coder）\n* ✅ Qwen 系列（Qwen2、Qwen3）\n* ✅ Qwen2/Qwen3 MoE 系列\n* ✅ Qwen3-Next 系列\n* ✅ Qwen3.5/3.6 Dense/MoE 系列（27B、35B、122B、397B、多模态）\n* ✅ Mistral v1、v2\n* ✅ Mistral-3-VL Reasoning（3B、8B、14B、多模态）\n* ✅ GLM4（0414 版本，**非 ChatGLM**）\n* ✅ GLM4 MoE（4.6/4.7）\n* ✅ GLM4.7 Flash\n* ✅ DeepSeek V3/R1/V3.2\n* ✅ Phi3 / Phi4（Phi-3、Phi-4、Phi-4-mini 等）\n* ✅ Gemma3/**Gemma4**（多模态）\n* ✅ Qwen3-VL（Dense、多模态）\n* ✅ MiroThinker-v1.5（30B、235B）\n\n**格式：** Safetensors（BF16、`FP8-blockwise`、GPTQ、AWQ、MXFP4、`NVFP4`）| GGUF（所有量化类型）| `ISQ`（即时量化）\n\n---\n\n### TurboQuant KV 缓存 — 消费级 GPU 运行 30B+ 模型\n\nTurboQuant 通过 Walsh-Hadamard 变换旋转 + 逐头 absmax 量化，将 KV 缓存压缩至 2–4 位。使用 `turbo4` 的最大上下文容量：\n\n| 模型 | KV 预算 | BF16 | turbo4 | 提升 |\n|---|---|---|---|---|\n| **Qwen3.6-35B-A3B**（NVFP4） | 7 GB（24 GB GPU） | 70 万 | **270 万** | **3.9×** |\n| | 15 GB（32 GB GPU） | 150 万 | **580 万** | **3.9×** |\n| **Qwen3.6-27B**（FP8） | 7 GB | 11.2 万 | **43.4 万** | **3.9×** |\n| | 15 GB | 24 万 | **93 万** | **3.9×** |\n| **Qwen3-30B-A3B**（Q4_K_M） | 7 GB | 7.4 万 | **28.1 万** | **3.8×** |\n| | 15 GB | 16 万 | **60.2 万** | **3.8×** |\n| **Gemma4-26B-A4B**（NVFP4） | 7 GB | 3.2 万 | **12.5 万** | **3.9×** |\n| | 15 GB | 7 万 | **27.1 万** | **3.9×** |\n\n\u003e 混合架构模型（Qwen3.6）全注意力层数远少于总层数，TurboQuant 压缩效果尤为显著。MLA 模型（DeepSeek、GLM4.7 Flash）请搭配 `fp8` 使用。表中 KV 预算为理论最大值，实际可用量最高为 KV 预算的 90%（`--kv-fraction 0.9`），需为运行时和批处理预留缓冲空间。\n\n```bash\n# 35B MoE 单卡 24/32 GB 即可运行\nxinfer --m unsloth/Qwen3.6-35B-A3B-NVFP4 --kvcache-dtype turbo4\n\n# FP8 精度\nxinfer --m Qwen/Qwen3.6-35B-A3B-FP8 --kvcache-dtype fp8\n\n# 27B Dense + turbo4\nxinfer --m Qwen/Qwen3.6-27B-FP8 --kvcache-dtype turbo4\n\n# 30B MoE GGUF + turbo4\nxinfer --m unsloth/Qwen3-30B-A3B-Instruct-2507-GGUF \\\n  --f Qwen3-30B-A3B-Instruct-2507-Q4_K_M.gguf --kvcache-dtype turbo4\n```\n\n---\n\n## 📘 使用方法\n\u003e **Python包安装后**请使用 `python3 -m xinfer.server` 方式运行\n\n\u003e Docker 内构建请参考 [**在 Docker 中运行 xInfer →**](docs/docker.md)\n\n### 运行模型\n\n\u003e **提示：** 默认启动 OpenAI 兼容 API 服务（`http://localhost:8000`）。添加 `--ui-server` 可同时启动内置 ChatGPT 风格 Web UI（`http://localhost:8001`）。\n\n```bash\n# FP8 模型（sm90+ 需启用 cutlass）+ Web UI\nxinfer --m Qwen/Qwen3.6-27B-FP8 --ui-server\n\n# 未量化 Safetensors（多卡）\nxinfer --d 0,1 --m Qwen/Qwen3-30B-A3B-Instruct-2507 --kvcache-dtype fp8\n\n# ISQ 即时量化\nxinfer --m Qwen/Qwen3.6-35B-A3B --isq q4k\n\n# NVFP4 模型\nxinfer --m unsloth/Qwen3.6-27B-NVFP4\n\n# MXFP4\nxinfer --m olka-fi/Qwen3.5-4B-MXFP4\n\n# GGUF 模型（4 位 KV 缓存）\nxinfer --m unsloth/Qwen3.5-27B-GGUF --f Qwen3.5-27B-Q4_K_M.gguf --kvcache-dtype turbo4\n\n# FP8 Metal\nxinfer --m Qwen/Qwen3.5-4B-FP8\n\n# Gemma4 26B（NVFP4）\nxinfer --m unsloth/gemma-4-26b-a4b-it-NVFP4\n\n# MLA 模型（GLM4.7 Flash）\nxinfer --m GadflyII/GLM-4.7-Flash-NVFP4\n\n# 交互式 CLI 对话\nxinfer --i --m unsloth/Qwen3.5-27B-GGUF --f Qwen3.5-27B-Q4_K_M.gguf\n```\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eISQ 即时量化 + KV 缓存压缩\u003c/b\u003e\u003c/summary\u003e\n\n```bash\n# ISQ Q4K + FP8 KV 缓存\nxinfer --m Qwen/Qwen3.6-35B-A3B --isq q4k --kvcache-dtype fp8\n\n# ISQ Q4K + TurboQuant KV 缓存\nxinfer --m Qwen/Qwen3.6-35B-A3B --isq q4k --kvcache-dtype turbo4\n\n# Metal ISQ\nxinfer --w /path/Qwen3-4B --isq q6k\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eGGUF 模型\u003c/b\u003e\u003c/summary\u003e\n\n```bash\n# 单卡 — GGUF\nxinfer --m unsloth/Qwen3.5-27B-GGUF --f Qwen3.5-27B-Q4_K_M.gguf\n\n# 多卡 — GGUF\nxinfer --d 0,1 --f /path/Qwen3-30B-A3B-Instruct-2507-Q4_K_M.gguf\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eTurboQuant KV 缓存（2–4 位压缩）— 详见 \u003ca href=\"#turboquant-kv-缓存--消费级-gpu-运行-30b-模型\"\u003eTurboQuant 专区\u003c/a\u003e\u003c/b\u003e\u003c/summary\u003e\n\n```bash\n# turbo4: 4位 K+V — 3.7× 压缩，最佳平衡\nxinfer --m Qwen/Qwen3.6-27B-FP8 --kvcache-dtype turbo4\n\n# turbo3: 3位 K + 4位 V — 4.7× 压缩\nxinfer --m Qwen/Qwen3.6-27B-FP8 --kvcache-dtype turbo3\n\n# turbo8: FP8 K + 4位 V — 2.6× 压缩，最高质量\nxinfer --m Qwen/Qwen3.6-27B-FP8 --kvcache-dtype turbo8\n\n# 35B MoE（NVFP4 + turbo4）— 24 GB 单卡即可运行\nxinfer --m unsloth/Qwen3.6-35B-A3B-NVFP4 --kvcache-dtype turbo4\n\n# 30B MoE（GGUF Q4_K_M + turbo4）— 消费级 GPU\nxinfer --m unsloth/Qwen3-30B-A3B-Instruct-2507-GGUF \\\n  --f Qwen3-30B-A3B-Instruct-2507-Q4_K_M.gguf --kvcache-dtype turbo4\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003e多模态模型（Qwen3-VL, Gemma4, Mistral3-VL）\u003c/b\u003e\u003c/summary\u003e\n\n```bash\n# 通过内置 Chat UI 上传图片或在 API 请求中传入 image_url\n\n# Qwen3.6 35B MoE（FP8，多模态）\nxinfer --m Qwen/Qwen3.6-35B-A3B-FP8 --ui-server\n\n# Qwen3-VL 8B（GGUF）\nxinfer --m unsloth/Qwen3-VL-8B-Instruct-GGUF --f Qwen3-VL-8B-Instruct-Q8_0.gguf --ui-server\n\n# Gemma4 26B MoE（NVFP4，多模态）\nxinfer --m unsloth/gemma-4-26b-a4b-it-NVFP4 --ui-server\n\n# Mistral-3 VL 3B（BF16，多模态）\nxinfer --m mistralai/Ministral-3-3B --ui-server\n```\n\n\u003c/details\u003e\n\n---\n## 📘 从源码编译安装\n**方式 1 — Cargo**\n```bash\n# 依赖项: Rust 编译器、CUDA 工具链（可选）、Metal 需安装 Xcode 命令行工具（可选）\ncurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh\nsudo apt-get install -y git build-essential libssl-dev pkg-config\n\nexport XINFER_REPO=\"https://github.com/guoqingbao/xinfer\"\n# macOS/Metal：将特性替换为 `--features metal`\n# SM_70/SM_75（如 V100）：去掉 `flashinfer` 和 `cutlass` 编译选项\ncargo install --git $XINFER_REPO xinfer --features cuda,nccl,flashinfer,cutlass\n```\n\n**方式 2 — Docker**\n```bash\n# Turing/V100 (sm_70/sm_75)：去掉 `flashinfer` 和 `cutlass` 编译选项\n./build_docker.sh \"cuda,nccl,flashinfer,cutlass\"\n```\n\n参考 [Docker 指南 →](docs/docker.md)\n\n\u003cdetails open\u003e\n\u003csummary\u003e\u003cb\u003e从源码编译 Python wheel\u003c/b\u003e\u003c/summary\u003e\n\n```bash\npip install maturin maturin[patchelf]\n\n# FlashInfer 后端（SM80+）\n./build.sh --release --features cuda,nccl,flashinfer,cutlass,python\n\n# Flash Attention 后端\n./build.sh --release --features cuda,nccl,flashattn,cutlass,python\n\n# macOS Metal\nmaturin build --release --features metal,python\n\n# 安装\npip install target/wheels/xinfer_ai-*.whl --force-reinstall\n```\n\n\u003c/details\u003e\n\n---\n\n## 🔀 Prefill-Decode 分离（PD 分离）\n\n将预填充（prompt 处理）和解码（token 生成）拆分到不同 GPU 或机器。消除长上下文预填充时的解码卡顿。PD 服务器与 PD 客户端必须使用相同 KvCache 数据类型（`--kvcache-dtype`）。对话请求需发送至 PD 客户端，PD 服务端只处理 PD 客户端发来的预填充请求。\n\n| 模式 | 配置 | 适用场景 |\n|---|---|---|\n| 本地 IPC | _（默认，无需参数）_ | 同一机器，CUDA |\n| 文件 IPC | `--pd-url file:///path` | Docker 容器，共享卷 |\n| 远程 TCP | `--pd-url tcp://host:port` | 不同机器 |\n\n**单机多卡部署**（无需指定 pd-url，默认使用 CUDA IPC）\n```bash\n# PD 服务器（预填充 GPU，默认端口 7000）\nxinfer --d 0,1 --m Qwen/Qwen3-30B-A3B-Instruct-2507 --pd-server\n\n# PD 客户端（解码 GPU + API 服务）\nxinfer --d 2,3 --w /path/Qwen3-30B-A3B-Instruct-2507 --isq q4k --ui-server --port 8000 --pd-client\n```\n\n**多机部署**（tcp 模式）\n```bash\n# 服务器机器（192.168.1.100）\ntarget/release/xinfer --d 0,1 --m Qwen/... --pd-server --pd-url tcp://0.0.0.0:8100\n\n# 客户端机器\ntarget/release/xinfer --d 0,1 --w /path/... --pd-client --pd-url tcp://192.168.1.100:8100 --ui-server --port 8000\n```\n\n\u003e Metal/macOS 不支持 Local IPC，必须指定 `--pd-url`。\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003e多容器部署（file:// 模式）\u003c/b\u003e\u003c/summary\u003e\n\n```bash\nmkdir -p /tmp/pd-sockets\n\n# 服务器容器\ndocker run --gpus '\"device=0,1\"' -v /tmp/pd-sockets:/sockets ...\ntarget/release/xinfer --d 0,1 --m Qwen/... --pd-server --pd-url file:///sockets\n\n# 客户端容器\ndocker run --gpus '\"device=2,3\"' -v /tmp/pd-sockets:/sockets ...\ntarget/release/xinfer --d 0,1 --w /path/... --pd-client --pd-url file:///sockets --ui-server --port 8000\n```\n\n\u003c/details\u003e\n\n---\n\n## 🔌 MCP 工具调用\n\n```bash\nxinfer --m unsloth/Qwen3-30B-A3B-Instruct-2507-GGUF \\\n  --f Qwen3-30B-A3B-Instruct-2507-Q4_K_M.gguf --ui-server --mcp-config ./mcp.json\n```\n\n[MCP 文档 →](docs/mcp_tool_calling.md)\n\n---\n\n## 🔌 结构化输出\n\n通过 llguidance 实现约束生成 — Lark 语法、正则表达式、JSON Schema。\n\n[结构化输出文档 →](docs/guided_decoding.md)\n\n---\n\n## 📚 文档\n\n| 指南 | 说明 |\n|---|---|\n| [快速开始](docs/get_started.md) | 编译、运行与配置 |\n| [Docker](docs/docker.md) | 容器构建与部署 |\n| [性能测试](docs/performance.md) | 完整性能表 |\n| [前缀缓存](docs/prefix-cache.md) | 自动 KV 缓存复用 |\n| [多模态](docs/multimodal.md) | 视觉语言模型 |\n| [Embedding](docs/embeddings.md) | 文本嵌入 API |\n| [分词器 API](docs/tokenizer_api.md) | Tokenize / Detokenize 端点 |\n| [工具调用解析](docs/tool_parsing.md) | 工具调用检测与解析 |\n| [MCP 集成](docs/mcp_tool_calling.md) | Model Context Protocol |\n| [引导解码](docs/guided_decoding.md) | 结构化输出 |\n| [Rust 库](docs/rust_crate.md) | 作为 Rust 库使用 |\n| [添加模型](docs/add_model.md) | 移植新架构（AI 辅助） |\n| [测试模型](docs/test_model.md) | 验证模型质量（AI 辅助） |\n\n**在 xInfer 后端下使用 Agent：** [xbot](docs/xbot.md) · [OpenCode](docs/opencode.md) · [Kilo Code](docs/kilocode.md) · [Claude Code](docs/claude_code.md) · [Goose](docs/goose.md)\n\n---\n\n## ⚙️ 命令行参数\n\n| 参数 | 说明 |\n|---|---|\n| `--m` | HuggingFace 模型 ID（自动下载） |\n| `--w` | 本地 Safetensors 模型路径 |\n| `--f` | GGUF 文件路径（或配合 `--m` 使用时为文件名） |\n| `--d` | 设备 ID（如 `--d 0,1`） |\n| `--ui-server` | API 服务 + ChatGPT 风格内置 Web UI |\n| `--server` | 仅 API 服务（无 Web UI） |\n| `--i` | 交互式 CLI 对话 |\n| `--isq` | 即时量化：`q2k`、`q3k`、`q4k`、`q5k`、`q6k`、`q8_0` |\n| `--kvcache-dtype` | KV 缓存量化：`fp8`、`turbo8`、`turbo4`、`turbo3` |\n| `--max-num-seqs` | 最大并发请求数（默认 32，macOS 为 8） |\n| `--max-tokens` | 单次最大输出 token 数（默认 16384） |\n| `--kv-fraction` | GPU 显存用于 KV 缓存的比例 |\n| `--cpu-mem-fold` | CPU 交换显存比例（默认 0.2） |\n| `--pd-server` | 作为 PD 预填充服务器运行 |\n| `--pd-client` | 作为 PD 解码客户端运行 |\n| `--pd-url` | PD 连接 URL（`tcp://`、`http://`、`file://`） |\n| `--disable-prefix-cache` | 禁用前缀缓存 |\n| `--prefix-cache-max-tokens` | 前缀缓存大小上限 |\n| `--prefill-chunk-size` | 预填充分块大小 (默认: CUDA 8K, Metal: 4k) |\n| `--disable-cuda-graph` | 禁用 CUDA 图捕获 |\n| `--yarn-scaling-factor` | YARN RoPE 上下文扩展因子 |\n| `--temperature` | 采样温度（0–1） |\n| `--top-k` / `--top-p` | Top-k / 核采样 |\n| `--presence-penalty` | 重复惩罚（−2 到 2） |\n| `--frequency-penalty` | 高频惩罚（−2 到 2） |\n| `--mcp-config` | MCP 服务器 JSON 配置 |\n| `--mcp-command` / `--mcp-args` | 单个 MCP 服务器命令及参数 |\n\n---\n\n## 📽️ 演示\n\n\u003cvideo src=\"https://github.com/user-attachments/assets/7fc6aa0b-78ac-4323-923f-d761dd12857f\" width=\"1000px\"\u003e\u003c/video\u003e\n\n---\n\n## 🛠️ 开发计划\n\n* [x] Metal 平台支持批量推理\n* [x] 支持 GGUF 格式\n* [x] CUDA 平台 Flash Attention 支持\n* [x] CUDA Graph\n* [x] OpenAI API 兼容服务器（支持流式输出）\n* [x] 持续批处理\n* [x] 多卡并行推理（Safetensors 模型、GPTQ/AWQ 及 GGUF 量化模型）\n* [x] Metal/macOS 平台 Prompt 处理加速\n* [x] 分块预填充（Chunked Prefill）\n* [x] 前缀缓存（使用 `prefix-cache` 参数）\n* [x] 从 HuggingFace Hub 下载并加载模型\n* [ ] 从 ModelScope 下载并加载（中国大陆地区）\n* [x] Metal/macOS 平台前缀缓存\n* [x] FP8 KV Cache（CUDA，所有后端，FlashInfer 支持 SM80+）\n* [x] FP8 KV Cache（Metal）\n* [x] FP8 KV Cache（FlashInfer，SM80+）\n* [x] TurboQuant KV Cache（2-4 位压缩，WHT 旋转量化）\n* [x] FP8 模型（CUDA: MoE, Dense; Metal: Dense）\n* [ ] 支持更多模型类型（Kimi K2、GLM 5.1 等）\n* [x] CPU KV Cache 卸载\n* [x] PD（Prefill/Decode）分离（CUDA）\n* [x] PD（Prefill/Decode）分离（Metal）\n* [x] 内置 ChatGPT 风格 Web 网页服务\n* [x] Embedding API\n* [x] Tokenize/Detokenize API\n* [x] MCP 集成与工具调用\n* [x] 公共前缀缓存\n* [x] Claude/Anthropic API 兼容服务器\n* [x] 支持 CUDA 13\n* [x] **支持 FlashInfer 后端**\n* [x] **支持 DeepGEMM 后端（Hopper）**\n* [x] **MXFP4/NVFP4 模型支持**\n* [x] **支持 Turboquant（4 位、3 位）KvCache**\n* [ ] TentorRT-LLM\n\n---\n\n## 📚 参考项目\n\n- [Candle-vLLM](https://github.com/EricLBuehler/candle-vllm)\n- Python nano-vllm\n\n## Star History\n\n\u003ca href=\"https://www.star-history.com/?repos=guoqingbao%2Fxinfer\u0026type=date\u0026legend=top-left\"\u003e\n \u003cpicture\u003e\n   \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://api.star-history.com/chart?repos=guoqingbao/xinfer\u0026type=date\u0026theme=dark\u0026legend=top-left\" /\u003e\n   \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://api.star-history.com/chart?repos=guoqingbao/xinfer\u0026type=date\u0026legend=top-left\" /\u003e\n   \u003cimg alt=\"Star History Chart\" src=\"https://api.star-history.com/chart?repos=guoqingbao/xinfer\u0026type=date\u0026legend=top-left\" /\u003e\n \u003c/picture\u003e\n\u003c/a\u003e\n\n**喜欢这个项目？欢迎 ⭐ 收藏和参与贡献！**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguoqingbao%2Fxinfer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguoqingbao%2Fxinfer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguoqingbao%2Fxinfer/lists"}