[BUG] cuvsDatasetMakePadded rejects an already-aligned device tensor
Nobody has claimed this yet.
- Dominant language
- Cuda
- Stars
- 854
- Forks
- 236
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 62
Description
Describe the bug
cuvsDatasetMakePadded fails when handed a device tensor whose rows already sit at CAGRA's required stride. The refusal makes sense since it avoids a redundant copy. However, it is not documented in the API, and the C API exposes no way to predict it.
Steps/Code to reproduce bug
- Allocate a contiguous float32 device matrix whose dimension is a multiple of 4 — e.g. 64 rows × 128 dims. (Contiguous means
rowStride == columns, which for 4-byte elements is already the 16-byte-aligned width CAGRA requires.) - Wrap it in a
DLManagedTensorwith device typekDLCUDA. - Call
cuvsDatasetMakePadded(res, tensor, CUVS_DATASET_MEM_TYPE_DEVICE, &out). - Repeat with 127 dims instead of 128 — it succeeds. The boundary is
dim % 4 == 0for float32.
Expected behavior
The dataset contents are copied into newly allocated padded storage, as documented at https://github.com/NVIDIA/cuvs/blob/2140532c5274dfbd9ba1d18c7bbdac15cc7ea93a/c/include/cuvs/core/dataset.h#L62-L63
Actual behavior
CUVS_ERROR, with cuvsGetLastErrorText() returning:
RAFT failure at cpp/include/cuvs/neighbors/common.hpp:1162:
source is device and stride is already correct.
Use make_device_padded_dataset_view() to get a view instead.
Environment details
Not environment specific. Present on main and release/26.08:
https://github.com/NVIDIA/cuvs/blob/2140532c5274dfbd9ba1d18c7bbdac15cc7ea93a/cpp/include/cuvs/neighbors/common.hpp#L1161-L1166
Additional context
The Python workaround is probably the clearest signal that the API is missing something:
https://github.com/NVIDIA/cuvs/blob/2140532c5274dfbd9ba1d18c7bbdac15cc7ea93a/python/cuvs/cuvs/common/dataset.pyx#L73-L89
It matches on the error text, so any rewording of that message turns the workaround into a crash. Rust, Go, and Java have no equivalent workaround and propagate the failure.
Might be related: #2402 (Dataset API C++, C, and language wrapper follow-up), #2394 (Remove dataset views from language wrappers).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with cpp/include/cuvs/neighbors/common.hpp:1161-1166 and the C API declaration in c/include/cuvs/core/dataset.h:62-63. Compare the Python handling in python/cuvs/cuvs/common/dataset.pyx:73-89 and review related issues #2402 and #2394. Done should leave the aligned-device-tensor behavior predictable through the API and avoid wrappers depending on matching error text.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp, go, java, python, rust
- Domain
- backend-api-design, machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 48/100