HNSW GPU upper-level IVF-PQ can overflow on unnormalized FP32 data; #2246 leaves FP16 LUT overflow unaddressed
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 18/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- machine-learning
Direzione di ricerca
Start with the overflow probe at cpp/src/neighbors/ivf_pq/ivf_pq_fp16_overflow.cuh and its CAGRA call site in cpp/src/neighbors/detail/cagra/cagra_build.cuh; then inspect all_neighbors_graph in cpp/src/neighbors/detail/hnsw.hpp. Compare the probe and fallback against the reported LUT/internal/coarse precision cases, and review how to expose upper-level overrides. Done means the gap has a regression case and a defined safe behavior for overflow; the issue does not name a test file or attach a standalone reproducer.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
The GPU hierarchy path in hnsw::from_cagra can select IVF-PQ inside all_neighbors_graph. The shape-based graph-build configuration sets coarse search, internal distance accumulation, and the lookup table to FP16, even for FP32 input. On two large-magnitude, unnormalized squared-L2 datasets, this produced non-finite distances and millions of repeated neighbors in an upper-level graph diagnostic.
The three precision settings have different failure modes. With one trained IVF-PQ index held constant per dataset, uniform data required FP32 coarse search and internal accumulation, while the manifold dataset additionally required an FP32 LUT. This is not evidence that every unnormalized dataset requires all three settings to be FP32.
#2246 adds useful protection, but its fallback changes only internal and coarse precision. The FP16 LUT failure demonstrated below is outside that fallback's coverage. The v26.10.00 and main observations in this report are source inspection, not fresh GPU reproductions on those versions.
Versions and reproduction environment
| Version / snapshot | Commit | Evidence and limits |
|---|---|---|
| v26.04.00 | 60b19a0f62ba0bd716de349382828e43be6e2daa |
GPU diagnostic using the v26.04-based implementation and correctly supplied FP32 rows; same-trained-index precision comparisons below. The installed SDK was a downstream build, not an unmodified release binary. |
| v26.04.00 plus the #2246 overflow-probe change | #2246 commit 7f2e67d61a90947b5f81f9ffed952be0a4343f82 |
Separate end-to-end hierarchy comparison verified that fallback ran. Other graph-input issues prevent attributing its original-space quality solely to precision. |
| v26.10.00 | 24ee1bf1cb17cad0ac611e39643af39ee1870124 |
Source inspection: includes #2246; graph-build defaults remain FP16 for all three fields and fallback leaves LUT FP16. Not GPU tested here. |
| main, inspected snapshot | 54d57677473140fdb1f6f80fb9490b4283e3412a |
Same precision policy and fallback limitation by source inspection. Upper-level candidate generation also changed; this snapshot was not GPU tested here. |
The controlled diagnostic ran on Linux with an NVIDIA A100-SXM4-80GB, using FP32 input and L2Expanded. The diagnostic used the existing CUDA 12.4 environment. The separately rebuilt #2246 comparison used CUDA 12.9.86 and GCC 12; those are separate experiments.
Reproduction conditions
- Upper-level diagnostic population: 344,411 rows, 64 dimensions, output degree 32. This gives 11,021,152 output neighbor slots, exceeding the
neighbors.size() < 1e7NN-descent branch threshold inall_neighbors_graph. - Shape-based IVF-PQ settings:
n_lists=172,pq_dim=32,pq_bits=4,n_probes=5,refinement_rate=1, and search width 33 before self removal. Here the candidate width is also 33, so there is no exact refinement stage. - Train once on each original dataset; reuse that exact trained index and query matrix for every precision comparison. Do not retrain between precision arms.
- Test data families: uniform integer-valued FP32 coordinates in
[0, 219); and an 8-dimensional affine manifold in 64 dimensions,15000 + z @ Q.T, with orthonormalQand latent coordinates uniform in[-5000, 5000]. The measured rows were retained upper-level subsets of larger synthetic inputs.
Minimal reproduction protocol
The causal reduction bypasses HNSW row gathering and calls IVF-PQ directly on the intended FP32 rows. This avoids conflating a vector-copy defect with a precision failure. The protocol below describes the executed reduction; the compact pseudocode is explanatory, not a newly compiled reproducer attachment.
X = contiguous float32 matrix, shape (344411, 64), squared-L2 metric
P = shape-based CAGRA IVF-PQ graph-build parameters for X
assert n_lists=172, pq_dim=32, pq_bits=4, n_probes=5
I = ivf_pq::build(resources, P.build_params, X) # exactly once
queries = copy X to device
for (LUT, internal, coarse) in supported precision combinations:
S = P.search_params
set S.lut_dtype, S.internal_distance_dtype, S.coarse_search_dtype
ids, distances = ivf_pq::search(resources, S, I, queries, k=33)
synchronize
graph = SDK write_to_graph(ids, output_degree=32)
count non-finite returned distances over every row and rank
count repeated neighbor slots in each sorted graph row
compare graph rows against exact float64 squared-L2 top32 of X
For exact-neighbor validation, use 100 evenly spaced row IDs from 0 through 344,410, exclude self, and break distance ties by row ID. Report overlap as total matched IDs divided by 100 * 32. Count duplicates as adjacent equal IDs after sorting each row, not as the number of affected rows. The SDK rejects LUT32/internal16; do not count either coarse variant of that combination as a successful arm.
For a self-contained synthetic fixture candidate in the same two families, the following generates approximately 84 MiB per matrix without any application data. It has not been GPU validated as an exact replacement for the retained subsets; the numerical table below must not be attributed to these freshly generated matrices. QR implementations and the upper-level selection affect exact bytes.
import numpy as np
n, d = 344411, 64
rng = np.random.default_rng(20261110)
uniform = rng.integers(0, 219, size=(n, 128), dtype=np.uint16)[:, :d]
uniform.astype('<f4').tofile('uniform.f32')
rng = np.random.default_rng(20261112)
basis, _ = np.linalg.qr(rng.normal(size=(d, 8)))
z = rng.uniform(-1, 1, size=(n, 8)) * 5000.0
(15000.0 + z @ basis.T).astype('<f4').tofile('manifold.f32')
A fully standalone, compiled source attachment and the exact retained diagnostic matrices are not included in this draft. The executed reduction used 344,411 rows; a smaller reproducing population has not been established.
Observed results: same trained index, precision changes only
Precision order is LUT / internal / coarse. Non-finite counts cover all 344411 * 33 = 11,365,563 returned distances. Duplicate counts cover all 344411 * 32 = 11,021,152 graph slots. Overlap is the sample metric defined above, not end-to-end HNSW recall.
| Dataset | Precision | Non-finite distances | Repeated neighbor slots | Exact top32 overlap |
|---|---|---|---|---|
| Uniform | 16 / 16 / 16 | 11,355,483 | 10,674,726 | 0.0000000 |
| Uniform | 16 / 32 / 16 | 0 | 8,610,265 | 0.0050000 |
| Uniform | 16 / 16 / 32 | 11,021,152 | 10,676,741 | 0.0003125 |
| Uniform | 16 / 32 / 32 | 0 | 0 | 0.2146875 |
| Uniform | 32 / 32 / 32 | 0 | 0 | 0.2153125 |
| Manifold | 16 / 16 / 16 | 11,365,563 | 10,676,741 | 0.0000000 |
| Manifold | 16 / 32 / 32 | 11,365,222 | 10,676,741 | 0.0006250 |
| Manifold | 32 / 32 / 32 | 0 | 0 | 0.7906250 |
These comparisons isolate the relevant factors:
- Uniform,
16/32/16versus16/32/32: changing only coarse precision removes 8,610,265 duplicates even though returned distances were already finite. - Uniform,
16/16/32versus16/32/32: changing only internal precision removes the non-finite results and duplicate collapse. FP16 LUT is sufficient for this dataset once the other two fields are FP32. - Manifold,
16/32/32versus32/32/32: changing only LUT precision removes the non-finite results and duplicate collapse.
Inspecting index.centers_half also found non-finite norm columns for all 172 coarse centers in both original datasets. The maximum corresponding FP32 center norm columns were 904,100 and 14,826,617,856 respectively.
Why #2246 does not fully cover this case
The merged change probes at most the first 128 query rows and checks returned distances for non-finite values. Its fallback promotes internal_distance_dtype and coarse_search_dtype but leaves lut_dtype at FP16 and does not repeat validation after promotion. See the main probe implementation and its CAGRA call site.
The manifold 16/32/32 arm is exactly the precision combination left after that fallback, and remains numerically broken in the controlled v26.04-based diagnostic. This demonstrates an uncovered precision combination, not an executed failure on the full v26.10.00 or main pipeline. The uniform 16/32/16 result separately shows why finite output distances alone cannot certify correct coarse selection. It is not evidence that the default #2246 probe necessarily misses this particular uniform dataset.
The quantities stored at the three stages differ: coarse search stores center norm terms and scores such as ||c||² - 2 q·c; LUT entries represent residual-to-codeword subspace distances; internal precision governs ADC accumulation. The bound ||x-y||² <= 4 max_i ||x_i||² for exact input pairs does not by itself certify all these IVF-PQ intermediates. Please do not interpret this report as proposing a universal input-norm threshold.
Other causes kept separate
- The resident HNSW gather has a distinct typed-copy issue covered by #3029. The direct IVF-PQ precision diagnostic bypasses it. Separate native backport runs removed duplicates when #2246 triggered, but did not recover original-space neighbors while the copy issue remained. Those end-to-end results do not prove a LUT-only cause.
- FP32 removes catastrophic numerical collapse, but does not guarantee exact neighbor quality. In a separate all-FP32 uniform control with the same trained index, increasing only
n_probesfrom 5 to all 172 lists changed sampled overlap from approximately 0.216 to 0.515. That control is not a claim of acceptable full-build cost or HNSW recall. - By source inspection, upper-level candidate generation in the inspected main snapshot differs from v26.04, and the effective NN-descent/IVF-PQ branch threshold there depends on candidate width rather than only the final degree. The v26.04 diagnostic counts should not be projected onto main's full hierarchy output.
Expected behavior
Valid FP32 squared-L2 inputs should produce an upper graph without catastrophic overflow and repeated-neighbor collapse, or receive a clear unsupported-range/error result. Approximation quality can vary, but a successful build should not silently retain a numerically invalid precision configuration.
Suggested changes
- Include LUT precision in overflow handling and validate the promoted configuration again. Use an FP32 LUT when required by observed LUT range or a suitable conservative policy.
- Check coarse intermediate validity and graph integrity as well as final distance finiteness. Treat the 128-row probe as sampling, not a guarantee for the whole dataset.
- Expose upper-level IVF-PQ precision and builder/search parameters through resident
from_cagra, or document a supported way to override them. At the inspected snapshots,all_neighbors_graphaccepts resource, dataset, graph output, and metric without an upper-level precision override. See v26.10.00 and main. - Add separate regression cases for coarse overflow, internal accumulation overflow, and LUT overflow, with a correctly gathered FP32 input and one trained index reused across controls.
Could you confirm the intended input-range guarantees for this path and whether the LUT fallback gap should be tracked as a follow-up to #2246?
- Lingua principale
- Cuda
- Stelle
- 902
- Fork
- 267
- Merge medio
- 2g 21h
- PR unite (30g)
- 57
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di NVIDIA/cuvs
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
[BUG] CAGRA multi-CTA and multi-kernel search over-allocate the hashmap they useForse già presa @mc8max l’ha presa 12 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
NVIDIA/cuvs#2856 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG] cuVS Bench Faiss CAGRA b_ratio reads the wrong JSON keyForse già presa @arcusbuilds l’ha presa 55 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
doc
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Upgrade faiss to v1.16.0Forse già presa @aamijar l’ha presa 8 giorni fa. Apertafaiss improvement
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
vllm-project/vllm#70030 ·
I maintainer di solito rispondono entro 1 giorno
-
help wanted small extra
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
t: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 3 giorni
-
Retry an empty final answer when Gemini reports MALFORMED_RESPONSE (gemini-4-hydrogen)Forse già presa @waleedkadous l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
iaser-ai/ansari#444 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno