Skip to content

[BUG] [sm_121] Device graph capture crashes on DGX Spark GB10: preBackForCapture vmmCreate fails with CUDA_ERROR_INVALID_DEVICE (VMM allocator sets gpuDirectRDMACapable unsupported on iGPU) #6961

Open

Description

@superpan

(Sub-issue of #6570*)*

Summary

max serve crashes at startup on NVIDIA DGX Spark (GB10, sm_121a) for any model where device graph capture is auto-enabled (e.g. Qwen2). The worker dies during graph-capture warmup with:

RuntimeError: Failed to capture graph: preBackForCapture vmmCreate failed: CUDA call failed: CUDA_ERROR_INVALID_DEVICE (invalid device ordinal)

Root cause (verified with a minimal driver-API repro below): the VMM defragmenting allocator's pre-back-for-capture path calls cuMemCreate with allocFlags.gpuDirectRDMACapable = 1. On GB10, CU_DEVICE_ATTRIBUTE_GPU_DIRECT_RDMA_WITH_CUDA_VMM_SUPPORTED is 0 (while CU_DEVICE_ATTRIBUTE_VIRTUAL_MEMORY_MANAGEMENT_SUPPORTED is 1), so any cuMemCreate with that flag fails with CUDA_ERROR_INVALID_DEVICE. Plain VMM allocations (flag = 0) succeed on this device.

Environment

  • MAX: 26.6.0.dev2026082105 (nightly, conda max + max-pipelines)
  • Hardware: NVIDIA DGX Spark — GB10 (integrated/unified memory), compute capability 12.1 (sm_121a), 48 SMs
  • Driver: 580.95.05, CUDA 13.0
  • OS: Ubuntu 24.04.3 LTS, kernel 6.14.0-1015-nvidia, aarch64

Reproduction

max serve --model Qwen/Qwen2.5-0.5B-Instruct

Startup log shows Automatically enabling device graph capture for Qwen2ForCausalLM, then the model worker crashes during capture warmup with the error above.

Isolation matrix (all on the same box, same model)

MODULAR_DEVICE_CONTEXT_MEMORY_MANAGER_VMM device graph capture result
default (VMM allocator on) auto-enabled ❌ preBackForCapture vmmCreate failed: CUDA_ERROR_INVALID_DEVICE
default (VMM allocator on) --no-device-graph-capture ✅ serves, completions OK
0 auto-enabled ✅ serves; capture warmup completes in 0.13s, completions OK
0 --no-device-graph-capture ✅ serves, completions OK

So graph capture itself works fine on sm_121 — the failure is specific to the VMM allocator's preBackForCapture backing allocation.

Root cause: minimal driver-API repro

Device attributes on GB10 (driver 580.95.05):

CU_DEVICE_ATTRIBUTE_VIRTUAL_MEMORY_MANAGEMENT_SUPPORTED (102) = 1
CU_DEVICE_ATTRIBUTE_INTEGRATED (17)                           = 1
CU_DEVICE_ATTRIBUTE_HANDLE_TYPE_POSIX_FILE_DESCRIPTOR_SUPPORTED (103) = 1
CU_DEVICE_ATTRIBUTE_GPU_DIRECT_RDMA_WITH_CUDA_VMM_SUPPORTED (105)     = 0

cuMemCreate results for a 2 MiB pinned device allocation, by allocation props:

allocFlags.gpuDirectRDMACapable requestedHandleTypes cuMemCreate result
0 NONE CUDA_SUCCESS
0 POSIX_FD CUDA_SUCCESS
1 NONE 101 CUDA_ERROR_INVALID_DEVICE
1 POSIX_FD 101 CUDA_ERROR_INVALID_DEVICE

Repro script (ctypes, no dependencies):

import ctypes

class Loc(ctypes.Structure):
    _fields_ = [("type", ctypes.c_int), ("id", ctypes.c_int)]
class AllocFlags(ctypes.Structure):
    _fields_ = [("compressionType", ctypes.c_ubyte),
                ("gpuDirectRDMACapable", ctypes.c_ubyte),
                ("usage", ctypes.c_ushort)]
class Prop(ctypes.Structure):
    _fields_ = [("type", ctypes.c_int), ("requestedHandleTypes", ctypes.c_int),
                ("location", Loc), ("win32HandleMetaData", ctypes.c_void_p),
                ("allocFlags", AllocFlags)]

cu = ctypes.CDLL("libcuda.so.1")
assert cu.cuInit(0) == 0
dev = ctypes.c_int(); cu.cuDeviceGet(ctypes.byref(dev), 0)
ctx = ctypes.c_void_p(); cu.cuCtxCreate_v2(ctypes.byref(ctx), 0, dev)

for rdma in (0, 1):
    p = Prop(); p.type = 1  # CU_MEM_ALLOCATION_TYPE_PINNED
    p.location.type = 1; p.location.id = 0  # CU_MEM_LOCATION_TYPE_DEVICE
    p.allocFlags.gpuDirectRDMACapable = rdma
    h = ctypes.c_ulonglong()
    r = cu.cuMemCreate(ctypes.byref(h), ctypes.c_size_t(2 << 20), ctypes.byref(p), 0)
    print(f"gpuDirectRDMACapable={rdma}: cuMemCreate rc={r}")
    if r == 0:
        cu.cuMemRelease(h)

Output on GB10:

gpuDirectRDMACapable=0: cuMemCreate rc=0
gpuDirectRDMACapable=1: cuMemCreate rc=101

Suggested fix

In the VMM defragmenting allocator (closed-source AsyncRT — libmax.so contains the preBackForCapture vmmCreate failed / ensureRegionBacked: vmmCreate failed sites), query CU_DEVICE_ATTRIBUTE_GPU_DIRECT_RDMA_WITH_CUDA_VMM_SUPPORTED once per device and only set allocFlags.gpuDirectRDMACapable when it is 1. Plain VMM allocations work on GB10, so the allocator (and graph capture with it) should then work unmodified — no need to disable VMM or capture on sm_121.

This likely affects other platforms where attr 105 is 0 (e.g. Jetson-class integrated GPUs), not just DGX Spark.

Severity / frequency

Blocker for out-of-the-box max serve on DGX Spark for every architecture with supports_device_graph_capture (capture is auto-enabled): 100% reproducible.

Workaround: --no-device-graph-capture, or MODULAR_DEVICE_CONTEXT_MEMORY_MANAGER_VMM=0.

Happy to test candidate fixes on this hardware.

Activity

  1. superpan commented on Aug 22, 2026

    @superpan
    Author

    Root cause now confirmed experimentally: I wrote an LD_PRELOAD shim that interposes dlsym (libmax resolves driver symbols via dlopen("libcuda.so.1")/dlsym) and wraps cuMemCreate to do exactly one thing — clear allocFlags.gpuDirectRDMACapable when CU_DEVICE_ATTRIBUTE_GPU_DIRECT_RDMA_WITH_CUDA_VMM_SUPPORTED == 0 for the target device.

    With the shim, max serve --model Qwen/Qwen2.5-0.5B-Instruct runs with fully default settings on the DGX Spark — VMM allocator on, device graph capture on:

    [cuvmm_shim] clearing unsupported gpuDirectRDMACapable flag on cuMemCreate (modular/modular#6961)
    INFO: Starting serve device graph capture warmup.
    INFO: Completed serve device graph capture warmup.
    INFO: Device graph capture warmup completed in 20.35s (model=Qwen2ForCausalLM, max_batch_size=8)
    🚀 Server ready on http://0.0.0.0:8000
    

    Completions verified working. Since clearing that single flag is the entire difference between crash and working, gating the flag on device attribute 105 inside the VMM allocator should be the complete fix. Shim source available if useful for reference; happy to verify the internal fix on this hardware when it lands in a nightly.

  2. superpan commented on Aug 22, 2026

    @superpan
    Author

    Shim source published: https://github.com/superpan/cuvmm-shim — the dlsym interposer described above, with build/usage instructions. Verified against MAX 26.6.0.dev2026082105 on DGX Spark.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions