[BUG] cuvs-java device matrices are capped at a quarter of GPU memory
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Área
- backend, performance
Línea de trabajo
Start with the cuvsRMMAlloc and cuvsRMMFree C API functions, which the issue says switched from the current device memory resource to the RAFT workspace resource in #2035. Run the Python ctypes script in the report on a GPU to reproduce the 6,224,112-row cap. Done means CuVSMatrix.deviceBuilder can hold an 8M x 1,024 float32 matrix while scratch buffers such as filter bitsets keep using the workspace pool.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
Since #2035, cuvsRMMAlloc allocates from the RAFT workspace resource instead of the current device memory resource. cuvs-java allocates device matrices (CuVSMatrix.deviceBuilder) through cuvsRMMAlloc, so a device matrix can't be larger than the workspace limit, which defaults to a quarter of total device memory. On a 96 GB GPU that is 6,224,112 rows of 1,024 float32. cuvsResourcesSetWorkspacePool, which is documented as configuring an uncapped pool, keeps the same limit.
I hit this building Vamana graphs through cuvs-java. An 8M × 1,024 dataset couldn't be copied to the GPU, so my code built from host memory instead, and the build ran over 2 hours where 4M took about 5 minutes from a device copy.
Steps/Code to reproduce bug
The script below calls the C API through ctypes on one otherwise idle GPU.
import ctypes
import cupy
lib = ctypes.CDLL("libcuvs_c.so")
lib.cuvsResourcesCreate.argtypes = [ctypes.POINTER(ctypes.c_size_t)]
lib.cuvsRMMAlloc.argtypes = [ctypes.c_size_t, ctypes.POINTER(ctypes.c_void_p), ctypes.c_size_t]
lib.cuvsRMMFree.argtypes = [ctypes.c_size_t, ctypes.c_void_p, ctypes.c_size_t]
lib.cuvsResourcesSetWorkspacePool.argtypes = [ctypes.c_size_t, ctypes.c_size_t]
lib.cuvsGetLastErrorText.restype = ctypes.c_char_p
CUVS_SUCCESS = 1
free, total = cupy.cuda.runtime.memGetInfo()
row = 1024 * 4 # one 1,024-dimensional float32 vector
quarter_rows = total // 4 // row
print(f"total device memory {total} bytes, a quarter holds {quarter_rows} rows")
def alloc(rows, pool=None):
res = ctypes.c_size_t()
assert lib.cuvsResourcesCreate(ctypes.byref(res)) == CUVS_SUCCESS
if pool is not None:
assert lib.cuvsResourcesSetWorkspacePool(res, pool) == CUVS_SUCCESS
ptr = ctypes.c_void_p()
ok = lib.cuvsRMMAlloc(res, ctypes.byref(ptr), rows * row) == CUVS_SUCCESS
print(f"{rows} rows{' after SetWorkspacePool' if pool else ''}:",
"OK" if ok else lib.cuvsGetLastErrorText().decode().rsplit(": ", 1)[-1])
if ok:
lib.cuvsRMMFree(res, ptr, rows * row)
alloc(quarter_rows)
alloc(quarter_rows + 1)
alloc(8_000_000)
alloc(8_000_000, pool=1 << 30)
x = cupy.empty((8_000_000, 1024), dtype=cupy.float32)
print("8000000 rows with CuPy: OK")
Output
total device memory 101975851008 bytes, a quarter holds 6224112 rows
6224112 rows: OK
6224113 rows: Exceeded memory limit 25493962752; Allocated bytes 0; Requested bytes 25493966848
8000000 rows: Exceeded memory limit 25493962752; Allocated bytes 0; Requested bytes 32768000000
8000000 rows after SetWorkspacePool: Exceeded memory limit 25493962752; Allocated bytes 0; Requested bytes 32768000000
8000000 rows with CuPy: OK
In cuvs-java, CuVSMatrix.deviceBuilder(resources, 8_000_000, 1024, CuVSMatrix.DataType.FLOAT).build() fails the same way.
Expected behavior
A device matrix that holds a dataset should be limited by device memory, as it was before #2035. RAFT's comment on default_allocation_limit describes the workspace limit as "merely an order for algorithm internals to plan the batching accordingly", so long-lived allocations like datasets shouldn't go through it.
Environment details (please complete the following information):
- Environment location: Bare-metal
- Method of cuVS install: conda, libcuvs 26.12.00a12 from rapidsai-nightly (commit c740818b), with cuvs-java 26.12.0 built from source.
cuvsRMMAllocis unchanged on main as of 32776b9. - GPU: NVIDIA RTX PRO 6000 Blackwell Server Edition (96 GB), driver 595.71.05
Additional context
#2035 changed cuvsRMMAlloc and cuvsRMMFree from rmm::mr::get_current_device_resource_ref() to raft::resource::get_workspace_resource_ref(). cuvs-java uses cuvsRMMAlloc both for short-lived buffers, such as filter bitsets, and for long-lived device matrices. The workspace pool suits the first and caps the second.
A possible fix is to keep the workspace pool for scratch buffers and give device matrices their own allocation and free path through the current device memory resource. Unpooled cudaMalloc and cudaFree synchronize the device, so the cuvs-java docs should also recommend enableRMMPooledMemory or enableRMMAsyncMemory for multithreaded applications. I'm happy to open a PR with this.
#682 reports the same workspace limit inside balanced k-means.
- Lenguaje dominante
- Cuda
- Estrellas
- 902
- Forks
- 267
- Merge medio
- 2 d 21 h
- PR fusionados (30 d)
- 57
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de NVIDIA/cuvs
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
[BUG] CAGRA multi-CTA and multi-kernel search over-allocate the hashmap they usePosiblemente ocupada @mc8max la tomó hace 12 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
NVIDIA/cuvs#2856 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
[BUG] cuVS Bench Faiss CAGRA b_ratio reads the wrong JSON keyPosiblemente ocupada @arcusbuilds la tomó hace 55 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
doc
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Upgrade faiss to v1.16.0Posiblemente ocupada @aamijar la tomó hace 8 días. Abiertofaiss improvement
Dificultad 1/5 Menos de una hora Aptitud para principiantes 86/100
Los mantenedores suelen responder en 1 día
Todos los issues de NVIDIA/cuvs
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
vllm-project/vllm#70030 ·
Los mantenedores suelen responder en 1 día
-
help wanted small extra
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
t: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 3 días
-
Retry an empty final answer when Gemini reports MALFORMED_RESPONSE (gemini-4-hydrogen)Posiblemente ocupada @waleedkadous la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
iaser-ai/ansari#444 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día