Skip to content

CudaBackend never overrides DeviceMemoryInfo, and the seam's comment says it does — so Gemma4MoE's device-expert LRU is dead on CUDA #1126

Description

@localai-bot

Found while measuring #1123, which needed a device memory budget and could not get one from this seam.

The false comment

include/vt/backend.h:78-83:

  // Optional device free/total VRAM probe (bytes). Default false = unknown.
  // ROCm/CUDA override with hipMemGetInfo/cudaMemGetInfo so model code can
  // size LRU caches without including vendor headers (device-leakage).
  virtual bool DeviceMemoryInfo(size_t* /*free_bytes*/, size_t* /*total_bytes*/) const {
    return false;
  }

Only ROCm overrides it (src/vt/rocm/rocm_backend.hip:338-345). CudaBackend does not, so on every CUDA device — not only a GB10 — DeviceMemoryInfo returns false. cudaMemGetInfo is called nowhere in the repository. The comment is corrected in prose by the #1123 change; the capability is this issue.

The consequence, which is not just a comment

Gemma4MoE is the seams only consumer. FreeBytes returns false when the probe is unavailable (src/vllm/model_executor/models/gemma4_moe.cpp:439-447), and MakeRoom refuses on unknown by design (:494-506, // Refuse device upload if free VRAM unknown). So on CUDA MakeRoomalways returns false and the whole device-expert LRU —kMaxSlots = 24, kHeadroom = 1.5 GiB` — never admits an expert. It falls back to host H2D on every expert, permanently, and nothing reports it.

That refusal-on-unknown is the RIGHT polarity for that call site (a hung hipMalloc is worse than a host fallback), so this is not a bug in gemma4_moe.cpp. It is a missing probe whose absence silently disables a landed capability.

Why #1123 did not add the override

Adding it would wake that LRU on CUDA, which is a behaviour change to another models residency policy with a measurement of its own to make. #1123 instead probes cudaMemGetInfoinCudaPlatform(which already includes<cuda_runtime.h>and already probes device attributes at registration) and carries the total onResidencyPolicy`, touching nothing Gemma4 reads.

What closing this looks like

  1. CudaBackend::DeviceMemoryInfo via cudaMemGetInfo, mirroring rocm_backend.hip:338-345.
  2. A measurement of Gemma4 MoE on CUDA with the LRU live: correctness first, then whether the device path is faster than the host H2D it replaces.
  3. The Qwen3.8-2.4T on --device cuda: the model loads, then the first forward dies on cudaMalloc: out of memory #1123 fit check can then read the budget from the backend seam on every platform that reports one, closing the "budget known only on CUDA" item under ## Owed in expert-streaming.md.

Measured for reference, on dgx:gpu0 (GB10) through libcudart.so.13, where nvidia-smi --query-gpu=memory.total,memory.free,memory.used answers [N/A], [N/A], [N/A]:

cudaMemGetInfo rc = 0
free  = 122059919360 (113.677 GiB)
total = 128452956160 (119.631 GiB)

total equals /proc/meminfo MemTotal rounded to the physical 128 GB. So the probe is usable on a unified pool, which is the case the comment`s "size LRU caches" sentence was written for.

Owning row: ENG-EXPERT-STREAM (## Owed).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions