AIFeed

RustingStrata – 纯 Rust 的 LLM GGUF 引擎,可在 CUDA 和 Vulkan 上运行超出显存容量的模型

Translation(model translation, not the source's own text)

RustingStrata

一个纯 Rust 的 GGUF 模型推理引擎,专为放不进 VRAM 的 MoE 模型打造。CUDA 内核在运行时通过 NVRTC 编译,同一套内核也能跑在 Vulkan 上:没有 C++ 构建步骤,不依赖 ggml。放不进 VRAM 的专家会在 CPU 上运行,与 GPU 工作同时进行,专家的放置方式会根据实际观察到的路由自适应调整。

支持的模型:Qwen3、Qwen3-Next、Qwen3.5/3.6、Qwen3.8-Flash-Next、Recursive Flint、Gemma 4、DeepSeek-V4.1-Flash、GLM-5.3-Flash、Hy4-flash、Inkling 2 Mini 和 Kolibri 1.1。各模型的架构、GGUF 类型和说明见 docs/MODELS.md。

版本 1.4.0。

数据

Qwen3.6-35B-A3B 在 RTX 3060 12 GB(Ryzen 5 7600X,32 GB 内存)上,CUDA,贪心解码,对比针对同一文件调优的 llama.cpp。两个文件都放不进 VRAM。

RustingStratallama.cpp
UD-Q5_K_M(25.2 GiB),4K 提示后的解码80.5 tok/s64.4
UD-Q5_K_M,4K 提示的 prefill1530 tok/s1118-1122
UD-Q2_K_XL(11.7 GiB),4K 提示后的解码113.4 tok/s66.5
UD-Q2_K_XL,4K 提示的 prefill2216 tok/s~2236

多用户并发

serve --parallel N 在一次批量前向中并行解码这些请求(CUDA)。同一台机器,同一个负载脚本(tools/loadtest.py:N 个同时进行的流式对话,每次回复 128 个 token,贪心),总解码 tok/s:

客户端数Qwen3-4B, RustingStrata (Q4_K_M)Qwen3-4B, vLLM 0.33 (bf16)Qwen3.6-35B-A3B UD-Q5_K_M, RustingStrata
191.336.749.0
4228.1139.988.9
16799.0520.1100.7
6416981688-1765129.3

vLLM 运行的是 bf16 权重,RustingStrata 运行的是 Q4_K_M,所以密集模型那几列并非同条件对比。27 GB 的 MoE 文件放不进 12 GB 显卡,所以没有对它运行 vLLM。RustingStrata 在每个步骤中为所有请求只读取每个专家一次,把不在 VRAM 中的专家放到 CPU 上运行,并把放不进 VRAM 的槽位状态保留在内存中。在这台机器上,MoE 那一列每次运行之间会有约 30% 的波动(27 GB 文件是通过 30 GB 的页缓存读取的)。

方法、区间范围、Vulkan、其他模型以及质量检查见 docs/BENCHMARKS.md。

安装

Windows(PowerShell;安装到 %LOCALAPPDATA%\Programs\RustingStrata,加入 PATH,并创建一个打开聊天页面的开始菜单项):


        irm https://raw.githubusercontent.com/RustingStudio/RustingStrata/main/install.ps1 | iex
      

Linux x86_64(安装到 ~/.local/bin):


        curl -fsSL https://raw.githubusercontent.com/RustingStudio/RustingStrata/main/install.sh | sh
      

Arch Linux:yay -S rustingstrata-bin(AUR)。或者从 releases 页面下载二进制文件,或自行构建(Rust 2024 edition;在 Windows 上需先安装 Visual Studio C++ Build Tools):


        cargo build --release    # 二进制文件为 target/release/rustingstrata
      

然后 rustingstrata serve --gpu --open 会打开聊天页面(其中可下载模型),rustingstrata interface 会在终端中询问几个问题。rustingstrata update 会把二进制文件替换为最新发行版(--check 仅检查是否有新版本);当有新版本发布时,serve 会在启动时打印一行提示。由包管理器安装的二进制文件(AUR 包)需通过该包管理器更新。

GPU 运行需要以下之一:

  • 带有 CUDA NVRTC 库的 NVIDIA 驱动(运行时加载)。Volta(sm_70)、Turing(sm_75)以及 Ampere 或更新架构(sm_80+)可用;CUDA 13 移除了对 Volta 的支持,因此 V100 需要 12.x 工具包。Pascal 及更早架构使用 Vulkan。该库按名称查找(libnvrtc.so;在 Windows 上为 nvrtc64_130_0.dll 或 nvrtc64_120_0.dll,位于 PATH 中或 %CUDA_PATH%\bin 下);STRATA_NVRTC 可指定其他文件。若没有该库,则回退到 Vulkan。
  • 支持 shaderFloat64、int8/16/64 且子组大小为 32 或固定为 64 的 Vulkan 1.3 驱动(已在 RTX 3060、Radeon VII 和 V100 上测试;Intel Arc 缺少 shaderFloat64)。
  • 对于 --backend hip:需要一个带 hiprtc 的 ROCm 运行时(libamdhip64.so、libhiprtc.so),同样在运行时加载;内核在首次使用时针对显卡的 gfx 目标进行编译。实验性功能——状态、数据和限制见 docs/HIP.md。

--gpu 在加载时优先选择 CUDA,否则选择 Vulkan;--backend 用于选择(cuda、vulkan 或 hip)。首次 CUDA 运行会编译内核(约 15 秒)并缓存。目前尝试过的所有 GPU 都记录在 docs/SUPPORTED_GPUS.md 中。

快速开始

不带参数运行 rustingstrata(在 Windows 上双击 rustingstrata.exe)。它会在 http://127.0.0.1:8080 上启动服务器,并打开一个聊天页面,该页面可从 Hugging Face 下载模型,并在你的 models 文件夹中的模型之间切换。任何接受 OpenAI 兼容地址的应用(Open WebUI、Jan、SillyTavern、代码编辑器)都可以使用 http://127.0.0.1:8080/v1。

rustingstrata interface 会询问模型、模式(终端聊天、聊天页面、API 服务器、速度测试)、GPU 或 CPU、上下文长度和地址,打印出这些选项生成的命令并运行它。


        M=path/to/model.gguf

rustingstrata calibrate --model $M --dry-run  # preview the workload matrix and knob space
rustingstrata calibrate --model $M     # once per model and machine: best chunk, MTP drafts, short threshold
rustingstrata chat --model $M --gpu    # --think for thinking mode, --temp 0.7 to sample
rustingstrata generate --model $M --gpu --prompt "Write a haiku about rivers." -n 128
rustingstrata serve --model $M --gpu --addr 127.0.0.1:8080
rustingstrata bench --model $M --gpu --pp 512,4096 --tg 128
      

不带 --gpu 时,模型在 CPU 参考实现上运行,速度较慢,仅用于检查。DeepSeek、GLM、Hy4 和 Inkling 2 会自动启用 GPU。

文档

  • USAGE.md:标志、聊天页面和 MCP 工具、OpenAI 和 Anthropic API、提示缓存、多 GPU。
  • CALIBRATION.md:预算化搜索、任务语料库、spec 扫描和 JSON 文件。
  • MODELS.md:支持的架构和 GGUF 类型,每个模型的说明和注意事项。
  • BENCHMARKS.md:每个模型与 llama.cpp 的对比;更早的运行记录在基准历史中。
  • HOSTING.md:为他人运行服务器。
  • SUPPORTED_GPUS.md 和 AMD.md:目前尝试过的 GPU 和 AMD 说明。
  • VISION.md:图像输入。LORA.md:LoRA 适配器。
  • ROADMAP.md:按章节列出的后续计划;欢迎用户提出想法。

开发


        cargo test --release                      # GPU tests need the model: STRATA_MODEL=path/to/model.gguf
python -I tools/parity.py $M --extra "--gpu" --tag gpu   # agreement with llama.cpp (needs llama-server once)
      

CI 只做构建,因此请在提交拉取请求前运行测试。

源码地图:src/gguf.rs(文件读取器)、src/quant/(反量化)、src/model.rs(CPU 参考前向)、src/cuda/ 和 src/vulkan/(GPU 内核,位于 src/backend.rs 之后)、src/gpu_model.rs(GPU 前向)、src/expert_cache.rs(专家放置)、src/deepseek/、src/glm/、src/hy4/、src/inkling2/ 和 src/gemma4/(拥有自己前向的模型)、src/serve.rs(HTTP)、src/chat.rs(聊天模板和工具调用)、src/main.rs(CLI)。

许可证

RustingStrata 在 RustingStrata License 1.0 下发布。你可以使用、修改和分发它,包括用于商业服务,只要保留许可证并注明 Vasyl Trefilov 为原作者。你不得出售 RustingStrata 本身。

The translation is machine-generated and individual terms may be off. Nothing is rewritten or cut; the original is authoritative.

Published by HN AI
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗