feat(ivf): support RaBitQ x+y split storage and search - #2707
Open
LightWant wants to merge 9 commits into
Open
Conversation
LightWant
requested review from
LHT129,
inabao,
jiaweizone and
wxyucs
as code owners
August 18, 2026 02:27
Collaborator
|
/label status/waiting-for-review |
Contributor
Merge Protections🟢 All 3 merge protections satisfied — ready to merge. Show 3 satisfied protections🟢 Require kind label
🟢 Require version label
🟢 Require linked issue for feature/bug PRs
|
Collaborator
Author
|
Maintainers: GitHub rejected the fork author's attempt to set upstream labels. Please add |
Signed-off-by: zhuangye.yxw <2510035537@qq.com> Assisted-by: Codex:gpt-5
LightWant
force-pushed
the
feat/issue-2443
branch
from
August 18, 2026 02:50
5ff8e2c to
261a807
Compare
Signed-off-by: zhuangye.yxw <2510035537@qq.com> Assisted-by: Codex:gpt-5
Signed-off-by: zhuangye.yxw <2510035537@qq.com> Assisted-by: Codex:gpt-5
Signed-off-by: zhuangye.yxw <2510035537@qq.com> Assisted-by: Codex:gpt-5
Signed-off-by: zhuangye.yxw <2510035537@qq.com> Assisted-by: Codex:gpt-5.5
Signed-off-by: zhuangye.yxw <2510035537@qq.com> Assisted-by: Codex:gpt-5.5
Signed-off-by: zhuangye.yxw <2510035537@qq.com> Assisted-by: Codex:gpt-5.5
Signed-off-by: zhuangye.yxw <2510035537@qq.com> Assisted-by: Codex:gpt-5.5
Signed-off-by: zhuangye.yxw <2510035537@qq.com> Assisted-by: Codex:gpt-5
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.
性能结果
本报告只比较 PR 前已有的 IVF RaBitQ 与本 PR 最终支持的 IVF split RaBitQ 布局,
不包含中间实现或内部优化阶段。
测试配置:
gist-960-euclidean.hdf5,1,000,000 条 960 维 L2 base 向量fast_encode_rabitq = true、fast_encode_rabitq_rounds = 12factor = 10、top-10、计时 1,000 次查询rabitq_bits_per_dim_query = 32相对传统 8-bit,1+7 的构建时间减少 9.5%,构建吞吐提升 10.5%;2+6 的构建时间
增加 3.6%,构建吞吐下降 3.4%;3+5 的构建时间增加 12.5%,构建吞吐下降 11.1%。
三种 split 布局的索引内存分别只增加 2.4%、3.3% 和 3.4%。filter xbits 只保留
bucket-local 32-vector packed blocks,不再同时保留按 inner ID 排列的 scalar xbits。
1+7 到 3+5 的内存差值为 13,688,688 bytes;剩余差值主要来自增加的 bit-plane、
每个 bucket 尾部不足 32 条向量的 padding,以及容器 capacity 对齐。
默认 candidate-reorder 检索下,1+7、2+6、3+5 的吞吐分别是传统 8-bit 的
6.2 倍、4.8 倍和 4.3 倍,平均延迟分别降低 83.9%、79.1% 和 77.0%。对应的
Recall@10 绝对差值分别为 -0.0153、-0.0097 和 -0.0139。本次结果中 1+7 吞吐最高,
2+6 在吞吐与召回之间最均衡。
以上为同一轮单机结果,不代表所有数据集和硬件环境都能获得相同比例的性能变化。
Residual IVF 检索
最终版本在相同的 32 buckets、
factor = 10、candidate-reorder 配置下,对1+7、2+6、3+5 residual split 进行了额外测试。每项使用相同的 1,000 条查询;
16 线程数据表示并行执行这 1,000 条查询。1+7 同时列出 non-residual 基线。
use_residualfalsetruetruetruefalsetruetruetrue在 1+7 同参数 A/B 中,residual 将 Recall@10 提升 0.0177;单线程和 16 线程 QPS
分别下降 4.4% 和 7.0%。Residual 2+6 与 3+5 的 Recall@10 分别为 0.9038 和
0.9031;随着 filter bit-plane 增加,扫描开销相应上升。Residual 查询路径只为路由
选中的 buckets 构建 computer/LUT,并将同 bucket 的 reorder 合并执行,避免对未扫描
buckets 做查询侧工作。
实现细节
Split 存储
bucket-local 32-vector packed blocks 并作为唯一 filter 存储;supplement 继续按 IVF
global inner ID 存储。按需读取完整 code 时,从 packed block 反解一条 xbits 后与
supplement 合并,不创建长期 scalar xbits 副本。
磁盘 IO、序列化与内存统计。
检索
查询只构建一份未加权的 4 维子集和 LUT;1-bit、2-bit 和 3-bit filter 的每个
bit-plane 共享这份 LUT,分别扫描后再按二进制位权重累加。例如 3-bit 为
4 * dot(q, x2) + 2 * dot(q, x1) + dot(q, x0)。candidate_reorder保持为默认策略:先扫描 x-bit record,保留factor * topk个候选,再只为这些候选读取 y-bit supplement。才读取 supplement;最终 x+y 距离估计直接复用 lower-bound 扫描保存的量化 x-bit
内积。
竞争同一把初始化 mutex;查询只对已路由 buckets 批量构建 computer/LUT。
supplement 距离,再按原候选顺序回填结果。
构建
写入互不重叠的临时 scalar-code slot,插入完成后再并行 pack 成正常可检索的
x-bit/y-bit record。
Add、不支持的 quantizer、设置fast_encode_rabitq=false的精确编码以及单线程构建,继续使用原有插入行为。
完整生成后才执行
Package。兼容性
rabitq_bits_per_dim_precise时,才选择 split storage。blocks;新索引直接序列化 packed blocks。
测试情况
git diff --check。packed-only 存储、按路由 bucket 批量构建 residual computers、optimized build 生命周期
和构建路径回退。
序列化、并发 Add,以及 optimized Build 后继续 Add;IVF streaming compatibility
另有 1 个用例、32,443 个 assertions 通过。
INT8 精确浮点比较和 non-finite searcher 测试。上述所有 RaBitQ/IVF 相关测试通过。
Fixes: #2443
附录:评测 YAML