feat(nvidia): add reusable GGUF Route B support for Qwen3.5 - #559
Open
xindongliu594 wants to merge 4 commits into
Open
feat(nvidia): add reusable GGUF Route B support for Qwen3.5#559xindongliu594 wants to merge 4 commits into
xindongliu594 wants to merge 4 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
csrc/layers/quantization/gguf.*中增加可复用的 GGUF Route B 权重加载和线性计算支持。BaseLinear、Linear、融合线性层以及 Qwen3.5 / Qwen3-Next 模型实现。linear_gguf算子原生支持Q8_0、Q4_K、Q5_K和Q6_KGGUF block。scripts/gguf_mapping.py、scripts/gguf_to_infinilm.py和scripts/gguf_transforms.py三个可复用的 GGUF 映射、转换和变换工具。test/scripts/test_gguf_routeb.py,覆盖权重重排、BF16 转换、量化配置和 packed checkpoint 校验。GGUF_ROUTE_B_QWEN38.md中记录 Route B 的设计、转换方式、验证结果和当前限制。Motivation
InfiniLM 此前无法直接执行目标 Qwen3.8-27B 模型使用的原生 GGUF 量化权重。
本 PR 增加可复用的 GGUF Route B 路径,而不是为单个模型实现完整的运行前反量化流程。受支持的 GGUF 线性层权重在 checkpoint 中继续保持原生 block bytes,并在执行时由 GPU 算子直接解析。当前不受原生算子支持的 IQ 格式 tensor,以及 embedding/lm-head 路径,会在权重打包阶段显式转换为 BF16,不存在静默的运行时 fallback。
本 PR 将 GGUF 适配拆分为公共量化层、模型权重映射层和转换工具层,使相关能力可以继续复用于其他 GGUF 模型,而不局限于当前 Qwen3.5 / Qwen3-Next 模型。
所需的 InfiniCore 算子通过独立 PR 提交:InfiniCore #1545。
默认情况下,本 PR 不会启用或修改已有的非 GGUF 执行路径。
Type of Change
feat— new feature / new modelfix— bug fixperf— performance improvement (no behavioral change)refactor— code restructuring without behavior changetest— adding or fixing tests onlydocs— documentation onlybuild/ci— build system or CI configurationchore— tooling, formatting, or other non-code changesTest Results of Involved Models on Supported Platforms (Please attach screenshots)
examples/test_infer.pyexamples/bench.pytest/bench/test_benchmark.pyscripts/test_perf.py_infinilmxmake build -y _infinilmtest/scripts/test_gguf_routeb.pyscripts/gguf_to_infinilm.py --dry-runSingle request
在当前 Qwen3.5 Mamba-cache 实现要求下,关闭 prefix caching 并启用 paged attention,
examples/test_infer.py在最终提交c643e7af上运行成功。首个原生 GGUF block 前向为:
这表明真实 prefill 已进入 GGUF Route B。
Offline performance entry point
最终提交
c643e7af的测试结果:这是一个没有 benchmark warmup 的小规模功能验证 case,不作为最终后端性能对比结果。
Sanity entry point
验证服务器无法连接 Hugging Face,底层错误为
[Errno 101] Network is unreachable。因此使用一个固定的本地 MMLU-format smoke sample,验证数据加载、模型执行、答案解析、统计和资源销毁的完整链路。该测试得到的 1/1 结果不作为正式 MMLU 准确率声明。如需正式准确率结果,仍需在能够访问 Hugging Face 或已经缓存正式 MMLU 数据集的环境中重新运行。
Service
使用只绑定回环地址、最大输出长度为 8 token 的临时服务运行
scripts/test_perf.py。全部服务端请求均返回 HTTP 200。临时服务只配置了 64 个 KV-cache block,因此部分请求被调度器暂时延后,但随后均正常完成。
64/64 请求成功汇总后,客户端的
httpcore2在事件循环退出阶段输出了异步生成器清理告警,但没有影响服务端响应、成功请求数量或最终退出状态。Benchmark / Performance Impact
本 PR 主要增加新的功能和可复用 GGUF 支持,不声明最终性能提升。
最终提交在一张 RTX 5090 上的初始离线性能基线为:
以上结果使用短输出、有限 KV-cache 容量且没有 benchmark warmup。由于 InfiniLM 此前没有对应的 GGUF Route B 执行路径,因此不存在可直接比较的旧 GGUF 基线。
针对 dense backend、其他量化 backend 或 llama.cpp 的受控性能比较,以及 prefill kernel、decode GEMV、权重加载和调度优化,留待后续工作完成。
Notes for Reviewers
Q8_0、Q4_K、Q5_K和Q6_K。IQ4_XS、IQ4_NLtensor 以及当前 embedding/lm-head 路径会在打包阶段显式转换为 BF16。v_tail保持、BF16 位模式、量化规则和 packed checkpoint 校验,结果为 5/5 通过。CI / ChatOps
本地已经完成以下检查:
独立 worktree 中的
_infinilm全新构建从 0% 到 100% 成功完成,用时 365.203 秒。由于验证服务器无法通过 GitHub 443 端口重新下载 submodule,构建时使用了主工作区中相同提交版本的json和spdlogsubmodule 内容,没有复用已有的 InfiniLM 编译产物。最终日志优化提交完成后,再次执行增量构建并成功完成,用时 97.089 秒。
GitHub Actions 尚未声明为通过。需要从 Actions 页面针对分支
feat/gguf-routeb-qwen38启动 CI workflow,或者由维护者在本 PR 中执行/retest或/test。Checklist
Title, Branch, and Commits
<type>/xxx-yyyy-zzzz.main.fixup!/squash!/wipcommits remain.Scope and Design
General Code Hygiene (applies to all languages)
git diff --check.C++ Specific (if C++ files changed)
scripts/format.py.csrc/models/llama_legacy/.Python Specific (if Python files changed)
scripts/format.py.python/infinilm/auto_config.py.Testing
examples/test_infer.py).examples/bench.py).test/bench/test_benchmark.py) using the explicitly documented local smoke sample.inference_server.py+scripts/test_perf.py).test/scripts/test_gguf_routeb.py).Build, CI, and Tooling
/retestwas requested.Documentation
GGUF_ROUTE_B_QWEN38.md.Security and Safety