I2_S produces incorrect output on aarch64
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 25/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- cpp
调研方向
从固定的 3rdparty/llama.cpp 子模块开始,重点查看 quants.c、ggml-cpu-i2s.c、ggml_gemm_i2_i8_s 和 ggml_vec_dot_i2_i8_s。在 aarch64 上使用列出的 llama-cli 命令复现,然后将 perplexity 和 GEMV/GEMM 内核输出与 x86 进行比较。跨架构的输出和 perplexity 匹配即表示完成。
由索引模型根据 Issue 内容生成。
描述
I2_S inference is broken on aarch64. The model loads and runs, but output is nonsense — it does not crash, so it looks like a bad model rather than a broken kernel.
On an Orange Pi 5 Plus (RK3588, Debian 12, GCC 12.2) with microsoft/BitNet-b1.58-2B-4T's official ggml-model-i2_s.gguf:
$ llama-cli -m ggml-model-i2_s.gguf -p "The capital of France is" -n 12 --temp 0
> The capital of France is ????????????????
[ Prompt: 0.7 t/s | Generation: 0.7 t/s ]
The same file on x86-64 gives The capital of France is Paris. at ~40 t/s. Model md5 verified identical on both machines.
Three separate bugs, all in 3rdparty/llama.cpp code paths that x86 never compiles:
QK_I2_Sis 128 under AVX2 but 64 under__ARM_NEON, in bothquants.candggml-cpu-i2s.c. It is the on-disk block size, so it must match the file format on every architecture.- The scalar
vec_dotfallback decodes the block-interleaved weight layout sequentially. ggml_gemm_i2_i8_s's ACT_PARALLEL branch invertsggml_vec_dot_i2_i8_s'snrcsemantics, corrupting prefill.
There is also no NEON path for I2_S at all — aarch64 unpacks one 2-bit weight at a time.
Fixes in https://github.com/isHuangXin/llama.cpp/pull/2, against the pinned 3rdparty/llama.cpp submodule. After them, perplexity on aarch64 matches x86 to 0.161% (74.0952 vs 73.9758, same model and corpus), and kernel output is bit-identical for both GEMV and GEMM.
This may be the same root cause as #55.
- 主要语言
- C++
- 星标
- 40.3k
- 派生
- 3.7k
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/BitNet 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 86/100
-
i2_s SIGSEGVs at n_ubatch >= 32: BLAS backend dequantises by a row stride 4x the real packed row未关闭
难度 2/5 1-3 小时 新手友好度 76/100
-
难度 2/5 1-3 小时 新手友好度 86/100
-
难度 1/5 1 小时以内 新手友好度 92/100
-
难度 2/5 1-3 小时 新手友好度 76/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
-
category:port-update
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 1/5 1-3 小时 新手友好度 88/100
tensorflow/tflite-micro#3784 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复