[BUG] CPU fallback for the quantized accelerated-HNSW Lucene codecs throws instead of falling back
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
先从 LuceneAcceleratedHNSWScalarQuantizedVectorsFormat 和 LuceneAcceleratedHNSWBinaryQuantizedVectorsFormat 中的 fieldsWriter 开始,然后检查 LuceneProvider 中对应的 fallback 方法。使用 setCuVSResourcesInstance(null) 和提供的 codec 加载示例重现该问题。完成的标准是两个量化 codec 都能通过各自的 CPU fallback 成功建立索引,且不会抛出异常。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
The CPU fallback path in LuceneAcceleratedHNSWScalarQuantizedVectorsFormat and LuceneAcceleratedHNSWBinaryQuantizedVectorsFormat is broken. When cuVS resources cannot be created, both log GPU based indexing not supported, falling back to using the ... and then throw instead of falling back.
Steps to reproduce
Try loading the codecs
package com.nvidia.cuvs.repro;
import static com.nvidia.cuvs.lucene.ThreadLocalCuVSResourcesProvider.setCuVSResourcesInstance;
import static org.apache.lucene.index.VectorSimilarityFunction.EUCLIDEAN;
import com.nvidia.cuvs.lucene.AcceleratedHNSWParams;
import com.nvidia.cuvs.lucene.Lucene101AcceleratedHNSWCodec;
import com.nvidia.cuvs.lucene.LuceneAcceleratedHNSWBinaryQuantizedCodec;
import com.nvidia.cuvs.lucene.LuceneAcceleratedHNSWScalarQuantizedCodec;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Random;
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.KnnFloatVectorField;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
/**
* Indexes a few vectors with each accelerated HNSW codec while cuVS resources are unavailable.
*
* <p>All three codecs are documented to fall back to CPU index construction in this state.
* Only {@code Lucene101AcceleratedHNSWCodec} does; the two quantized variants throw.
*/
public class FallbackRepro {
private static final int NUM_DOCS = 16;
private static final int DIMENSION = 8;
public static void main(String[] args) throws Exception {
// Force the !isSupported() branch on this thread, the same way
// TestCagraToHnswSerializationAndSearchWithFallbackWriter does.
setCuVSResourcesInstance(null);
AcceleratedHNSWParams params = new AcceleratedHNSWParams.Builder().build();
index("Lucene101AcceleratedHNSWCodec", new Lucene101AcceleratedHNSWCodec(params));
index("LuceneAcceleratedHNSWScalarQuantizedCodec", new LuceneAcceleratedHNSWScalarQuantizedCodec(params));
index("LuceneAcceleratedHNSWBinaryQuantizedCodec", new LuceneAcceleratedHNSWBinaryQuantizedCodec(params));
}
private static void index(String label, Codec codec) {
Random random = new Random(222);
IndexWriterConfig config = new IndexWriterConfig().setCodec(codec);
try {
Path indexPath = Files.createTempDirectory("cuvs-fallback-repro");
try (Directory directory = FSDirectory.open(indexPath);
IndexWriter writer = new IndexWriter(directory, config)) {
for (int i = 0; i < NUM_DOCS; i++) {
float[] vector = new float[DIMENSION];
for (int j = 0; j < DIMENSION; j++) {
vector[j] = random.nextFloat() * 100;
}
Document document = new Document();
document.add(new KnnFloatVectorField("vector_field", vector, EUCLIDEAN));
writer.addDocument(document);
}
}
System.out.printf("%-45s OK%n", label);
} catch (Throwable t) {
System.out.printf("%-45s %s%n", label, t);
}
}
}
output:
WARNING: Java vector incubator module is not readable. For optimal vector performance, pass '--add-modules jdk.incubator.vector' to enable Vector API.
Sep 16, 2026 5:38:43 PM com.nvidia.cuvs.lucene.Lucene99AcceleratedHNSWVectorsFormat fieldsWriter
WARNING: GPU based indexing not supported, falling back to using the Lucene99HnswVectorsWriter
Lucene101AcceleratedHNSWCodec OK
Sep 16, 2026 5:38:44 PM com.nvidia.cuvs.lucene.LuceneAcceleratedHNSWScalarQuantizedVectorsFormat fieldsWriter
WARNING: GPU based indexing not supported, falling back to using the Lucene99HnswScalarQuantizedVectorsFormat
Sep 16, 2026 5:38:44 PM com.nvidia.cuvs.lucene.LuceneProvider getLuceneHnswScalarQuantizedVectorsFormatInstance
SEVERE: Unable to initialize LuceneHnswScalarQuantizedVectorsFormat: class org.apache.lucene.codecs.lucene99.Lucene99HnswScalarQuantizedVectorsFormat cannot be cast to class org.apache.lucene.codecs.hnsw.FlatVectorsFormat (org.apache.lucene.codecs.lucene99.Lucene99HnswScalarQuantizedVectorsFormat and org.apache.lucene.codecs.hnsw.FlatVectorsFormat are in unnamed module of loader org.codehaus.mojo.exec.URLClassLoaderBuilder$ExecJavaClassLoader @5f7989fa)
LuceneAcceleratedHNSWScalarQuantizedCodec java.lang.ClassCastException: class org.apache.lucene.codecs.lucene99.Lucene99HnswScalarQuantizedVectorsFormat cannot be cast to class org.apache.lucene.codecs.hnsw.FlatVectorsFormat (org.apache.lucene.codecs.lucene99.Lucene99HnswScalarQuantizedVectorsFormat and org.apache.lucene.codecs.hnsw.FlatVectorsFormat are in unnamed module of loader org.codehaus.mojo.exec.URLClassLoaderBuilder$ExecJavaClassLoader @5f7989fa)
Sep 16, 2026 5:38:44 PM com.nvidia.cuvs.lucene.LuceneAcceleratedHNSWBinaryQuantizedVectorsFormat fieldsWriter
WARNING: GPU based indexing not supported, falling back to using the Lucene102HnswBinaryQuantizedVectorsFormat
Sep 16, 2026 5:38:44 PM com.nvidia.cuvs.lucene.LuceneProvider getLuceneHnswBinaryQuantizedVectorsFormatInstance
SEVERE: Unable to initialize LuceneBinaryQuantizedVectorsFormat: Cannot invoke "java.lang.Class.getConstructor(java.lang.Class[])" because "this.hnswBinaryQuantizedVectorsFormat" is null
LuceneAcceleratedHNSWBinaryQuantizedCodec java.lang.NullPointerException: Cannot invoke "java.lang.Class.getConstructor(java.lang.Class[])" because "this.hnswBinaryQuantizedVectorsFormat" is null
Additional context covers three things:
The NullPointerException is already tracked in #2615 as part of another set of issues.
- 主要语言
- Cuda
- 星标
- 902
- 派生
- 267
- 平均合并
- 2 天 21 小时
- 30 天内合并 PR
- 57
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
NVIDIA/cuvs 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
[BUG] CAGRA multi-CTA and multi-kernel search over-allocate the hashmap they use可能已有人在做 @mc8max 于 12 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
[BUG] cuVS Bench Faiss CAGRA b_ratio reads the wrong JSON key可能已有人在做 @arcusbuilds 于 55 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
doc
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
Upgrade faiss to v1.16.0可能已有人在做 @aamijar 于 8 天前认领。 未关闭faiss improvement
难度 1/5 1 小时以内 新手友好度 86/100
维护者通常 1 天内回复
相似的 Issue
-
clawsweeper:needs-maintainer-review clawsweeper:needs-product-decision clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:other issue-rating: 🦞 diamond lobster P2
难度 2/5 1-3 小时 新手友好度 72/100
openclaw/openclaw#205598 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
area:site feature good first issue help wanted
难度 2/5 1-3 小时 新手友好度 90/100
pacocartones/free-llm-api-hub#793 ·
维护者通常 1 天内回复
-
search-backend-module-elasticsearch: search term is ignored as soon as a filter is set可能已有人在做 @adityakumar027 今天认领。 未关闭area:search
难度 2/5 1-3 小时 新手友好度 78/100
backstage/backstage#37150 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
NixOS/nixos-search#1690 · 1 个 reaction ·
维护者通常 1 天内回复
-
search: highlight() builds a RegExp from the typed search text可能已有人在做 @goranai 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
nanbingxyz/5ire#471 ·
维护者通常 2 天内回复