Unified Virtual Memory Explained: How UVM Works for GPU Inference

How unified virtual memory migrates pages for GPU inference, when faults slow it, what prefetch and hints recover, and its GPU virtualization limits.

Unified Virtual Memory Explained: How UVM Works for GPU Inference
Written by TechnoLynx Published on 11 Jul 2026

Unified virtual memory (UVM), which CUDA calls unified or managed memory, gives the CPU and GPU one virtual address space. The driver moves pages to whichever processor touches them, so your code no longer issues an explicit host-to-device copy for every buffer. The data still moves. From Pascal on, a GPU thread that touches a page not resident in its memory stalls while the page migrates; on a Tesla P100, NVIDIA’s measured kernel time included that cost. UVM virtualises memory addresses, not the GPU. Sharing one GPU across virtual machines, a form of GPU virtualization, meets UVM through the vGPU profile limits described in the last section.

How Is Unified Memory Different from Copying Tensors to the GPU Yourself?

With explicit management you allocate device memory, call cudaMemcpy or cudaMemcpyAsync, and decide exactly when each transfer happens. Contiguous copies run on the copy engines and can overlap with work on both host and device. With managed memory (cudaMallocManaged), an allocation usually lands in the memory of whichever processor touches it first. It migrates when another processor uses it, at page granularity on software-coherent systems or cache-line granularity on hardware-coherent ones.

Two neighbouring ideas often get mixed up with UVM. Unified virtual addressing only places host and device allocations in one address space, so the runtime can tell from a pointer where the memory lives. It moves nothing. Mapped (zero-copy) memory stays in CPU memory, so every GPU access crosses PCIe or NVLink at higher latency and lower bandwidth than device memory. Mapped memory also does not guarantee that every access type, atomics included, works on every system, while unified memory does.

Behaviour also varies by platform. Its features differ across operating systems, Linux kernel versions, GPU hardware and the CPU-GPU interconnect. You can check which form you have through cudaDeviceGetAttribute, for example cudaDevAttrConcurrentManagedAccess (1 means full support) and cudaDevAttrPageableMemoryAccessUsesHostPageTables (1 means hardware coherence). On Windows, WSL and some Tegra systems, managed memory migrates in bulk when the GPU starts executing, the CPU must not touch it while the GPU is active, and oversubscription of GPU memory is not allowed. Pre-Pascal GPUs cannot page fault, so the runtime migrates every managed page back to the device before each kernel launch.

Whether UVM removes host-to-device copies or only turns them into runtime faults has its own answer, and so does measuring the result. Our explainer on unified virtual memory for latency-bound rendering covers both: the copy question and how to profile UVM page faults and migration traffic against a latency budget.

What Happens When an Inference Kernel Touches a Page That Is Not on the GPU?

When a kernel touches a page that is not resident in GPU memory, the GPU raises a page fault and the driver migrates the page from CPU memory before the access can complete. Pascal was the first NVIDIA architecture with hardware page faulting and migration, which it does through its Page Migration Engine.

According to NVIDIA’s developer blog, a fault on Pascal or Volta generates a fault message and locks the TLBs for the affected SM. Translations already in flight can finish, but new ones stall until all faults are resolved. The GPU can raise many faults at the same time, including duplicates for the same page. The UVM driver removes the duplicates, updates the mappings and then transfers the data. A 2024 study of Grace Hopper, citing earlier work, notes that handling the fault can cost more than the data migration itself.

The driver and GPU MMU set migration granularity, not your tensor boundaries. The 2026 PAGE404 study of the NVIDIA driver describes 2 MB prefetch regions in the virtual address space. Residency inside each region is tracked as a binary tree down to 64 KB leaves, and once one half of a node is resident, the driver prefetches the sibling half. NVIDIA also describes density prefetching: once enough of a predefined region has been transferred, the driver fetches the rest. It may also merge small pages into larger ones on the GPU to improve TLB coverage.

When GPU memory fills up, the UVM driver evicts least-recently-used pages back to host memory. From Volta onwards, hardware access counters track remote accesses so that the driver can move only the pages accessed often. PAGE404 reports a default threshold of 256 accesses before a counter notification triggers migration.

NVIDIA’s developer blog reports on-demand migration reaching 5.4 GB/s on a PCIe system, against 10.9 GB/s for explicit prefetching with cudaMemPrefetchAsync and 11.4 GB/s for cudaMemcpyAsync. Fault latency also affects AMD GPUs. A 2025 study of AMD MI300A measured single-page GPU faults at 16 µs (minor) and 18 µs (major) on average, roughly twice the CPU’s 9 µs.

When Does UVM Slow GPU Inference, and Do Prefetching and Memory Hints Fix It?

UVM hurts GPU performance when kernels stall on page faults, and the published size of that penalty varies widely. A 2019 evaluation of CUDA Unified Memory found every application slower with basic unified memory than with explicit data movement. For its convolution and FDTD3d applications, the penalty was 2 to 3 times on an Intel-Pascal system and 14 and 9 times on a Power9-Volta system. UVMBench (2020) measured an average 34.2% slowdown when benchmarks were converted directly to UVM, caused by kernels stalling while page faults were handled. Across 14 workloads, a 2023 IISWC study found UVM alone 4.41% slower than the standard explicit version, but 20.96% faster once prefetching was added.

So “UVM costs X%” is not a number you can bring to your own model. The penalty depends on the workload, and the MI300A study says outright that unified-memory applications often fall short of explicit management. In the MI300A study, faults hurt most in one workload whose kernel was simple next to the cost of its page faults. A rule like “UVM is fine” or “never use UVM” only means something once you have measured the access pattern, the platform and the latency target.

Prefetching: The Main Recovery

cudaMemPrefetchAsync is a stream-ordered, asynchronous call. It starts migrating data towards a chosen processor once earlier work in the stream has finished, and the migration completes before later work in the stream begins. In UVMBench, adding it before each kernel launch cut the geometric-mean slowdown of the five worst-affected benchmarks from 95.8% to 0.7%, because the kernels rarely stalled on data that was already resident. The 2023 IISWC study found that regular access patterns gain most, with 2DCONV reaching up to 2.63 times the standard version under UVM with prefetch. Reusing data across repeated kernel launches also narrows the gap, since later launches touch pages the first one already brought over.

Memory Hints: Useful, Platform-Dependent, Sometimes Harmful

cudaMemAdvise tells the driver how an allocation will be used. SetReadMostly creates a read-only copy on the faulting side, which avoids future faults, but every copy is invalidated on a write. That suits read-only data such as frozen model weights. SetPreferredLocation pins pages to one memory and, where the hardware supports it, sets up a remote mapping in place of migration. SetAccessedBy keeps data in one place while mapping it for another processor.

The catch is that the same hint can help on one machine and hurt on another. In the 2019 evaluation, advice gave negligible gains for in-memory runs on Intel-Volta/Pascal PCIe systems but up to 25% at about 50% oversubscription. On Power9-Volta NVLink it gave up to 34% in memory, yet it increased page faults and lost considerable performance under oversubscription. Prefetch improved performance by up to 50% on the Intel PCIe platform and brought little benefit on Power9 NVLink. The CUDA Programming Guide adds that every hint has a host-side cost, so a hint has to save more than it costs.

Choosing a Placement Strategy for Inference Memory

Data in an inference workload Access pattern Placement that usually fits What to watch
Model weights that fit in GPU memory Read every step, never written Explicit copy, or managed memory with prefetch and SetReadMostly First-touch faults on the first request if nothing is prefetched
Activations and scratch buffers Produced and consumed on the GPU Device allocation, or first touch on the GPU On P100, initialising in a CUDA kernel removed CPU-to-GPU page faults
Data read once from host memory Single use Zero-copy pinned memory Every access crosses the interconnect
Data with heavy reuse that exceeds GPU memory Reused, larger than capacity Distribute pages explicitly with cudaMemAdvise, keep hot data resident Thrashing under short reuse distances
Random, irregular accesses under oversubscription Frequent, scattered Pin those pages on the GPU or rework the layout for locality The launch-ratio cliff

Why LLM Decode and a Growing KV Cache Punish Fault-Driven Migration

LLM serving combines a large, growing working set with a strict latency target. As sequence lengths and batch sizes grow, the KV cache can outgrow GPU memory. Developers then have to cap context length or stage data between host and device by hand. UVM looks like the way out of that choice, but conventional UVM pays for it through software-managed fault handling in the driver. Decode is usually limited by memory bandwidth, not compute. That makes every byte served from host memory, or waiting on a migration, directly visible in time between tokens.

Hardware coherence on GH200 did not make the problem disappear. The SuperInfer authors (2026) report that enabling unified memory for vLLM on GH200 severely degraded performance and significantly raised average time between tokens. They trace this to a bandwidth cliff, not to fault overhead: up to 4 TB/s from HBM against 384 GB/s from the Grace CPU’s DRAM. A new request whose KV blocks sit in DRAM is served over the slow link, and it can finish before the access counters ever trigger a migration.

Where oversubscription cannot be avoided, selective tensor-level prefetching has beaten baseline UVM. AutoUVM (2026) profiles kernel-to-tensor access once, offline, and prefetches at the tensor level. It reports an average 3.1 times speedup over baseline UVM for oversubscribed LLM execution, with 3.1, 2.9 and 2.7 times on RTX 3060, A100 and H100 respectively. Its policy prioritises kernels bottlenecked by the CPU-GPU interconnect and skips migration for compute-bound and GPU-memory-bound kernels. The profiling pass costs about 41.5 inference iterations on average, once. These speedups are measured against plain UVM, not against a model that fits in memory, so they tell you how much of the UVM penalty can be clawed back, not that oversubscribed serving matches resident serving.

Can UVM Let a Model Larger than GPU Memory Run for Inference?

Yes, it can run, on platforms with full unified memory support. Managed allocations may exceed physical GPU memory, and the driver evicts pages to make room. It will not run that way on Windows or WSL, where oversubscription is not allowed. Libraries need checking too: in UVMBench, a benchmark built on cuBLAS crashed under oversubscription.

What it costs depends on the access pattern and on how far you oversubscribe. The oversubscription factor is allocated managed memory divided by available GPU memory. A factor of 1.5 on a 32 GB GPU means 48 GB is allocated. At 110% and 125% of GPU memory, many UVMBench benchmarks finished with 2 to 3 times slowdown, while others suffered penalties beyond 100 times or crashed. The severe cases came from thrashing, where pages move back and forth because evicted data is needed again within a short time. NVIDIA’s own oversubscription tests show performance varying by up to 100 times depending on platform, oversubscription factor and hints.

For many applications, the cost does not rise smoothly. An ICPE 2022 study found that many applications run at steady speed as oversubscription grows and then hit a sudden jump in execution time at an application-specific point it calls the launch ratio, about 2 for gemm. Other applications barely notice: 2dconv slowed only 2.5 times at a ratio of 10. The authors tie the cliff to frequently and randomly accessed “FALL” pages, whose share of GPU memory sets how sensitive an application is. Hints change their effect around that point, too: keeping a direct mapping in the GPU page table helps above the launch ratio and hurts below it. That is why the authors suggest checking free memory with cudaMemGetInfo and choosing hints at runtime.

Decode adds a twist. Generating each token reads every layer’s weights in the same order, a cyclic scan. Under pure LRU, a cyclic scan larger than the cache evicts each page before it is reused, so every access misses. Our reading is that oversubscribed weights under default fault-and-migrate behave closer to the thrashing case than to the streaming case. Pinning the overflow on the host and mapping it to the GPU, as NVIDIA’s round-robin page distribution does with setAccessedBy, avoids repeated migration at an interconnect cost. NVIDIA’s tests found that explicit page distribution beats fault-driven allocation when GPU residency of part of the data matters.

Worked Example: A Lower Bound on Per-Token Latency from Spilled Weights

Assumptions, stated as assumptions: decode reads all weights once per token, the weights that do not fit stay in host memory and are read over the link once per token, and the link runs at the best rate the sources give. The added time per token is then at least the spilled bytes divided by the link bandwidth.

  • On the Pascal/Volta-era PCIe system in NVIDIA’s blog, explicit prefetch reached 10.9 GB/s. 1 GB ÷ 10.9 GB/s ≈ 92 ms added per token for every gigabyte outside GPU memory.
  • On GH200, the Grace DRAM bandwidth of 384 GB/s is a ceiling, not a measured transfer rate. 1 GB ÷ 384 GB/s ≈ 2.6 ms per token per gigabyte.

Fault-driven migration achieved about half the prefetch rate on PCIe, so the real cost sits above these floors. By these floors, a spilled gigabyte costs far less on GH200 than on the PCIe system, though, as SuperInfer found, unified memory still raised time between tokens there.

Hardware-Coherent Memory Changes the Cost Model, Not the Physics

On Grace Hopper and Grace Blackwell, the NVLink Chip-to-Chip link provides address translation services (ATS). The GPU can then use all host allocations as unified memory, and managed allocations resident on the GPU can be accessed from the CPU without migration. On these systems, GPU access to CPU-resident memory no longer triggers a GPU page fault every time. Coherence works at cache-line granularity, which avoids page-level contention. On PCIe-attached GPUs, Linux Heterogeneous Memory Management (HMM) brings software-coherent full unified memory with kernel 6.1.24, 6.2.11, or 6.3 and later.

Two cautions apply. First, a 2024 Grace Hopper study saw a significant managed-memory slowdown at about 130% oversubscription: no pages migrated and all data was read over NVLink-C2C at low bandwidth. Prefetching moved most accesses back to GPU memory. Second, the CUDA Programming Guide warns that system allocations mapped with default 4 KiB or 64 KiB CPU pages can cause heavy GPU TLB misses over large ranges.

UVM Under GPU Virtualization: vGPU Profiles, MIG and Live Migration

UVM inside a virtual machine works only on narrow vGPU configurations. NVIDIA AI Enterprise documentation restricts UVM to 1:1 time-sliced and MIG vGPU for Compute profiles that allocate the entire framebuffer of a physical GPU or GPU instance. Fractional time-sliced vGPUs do not support it. UVM is off by default and must be enabled per vGPU through a plugin parameter. Enabling it disables vGPU migration for that VM, which matters wherever operations depend on live migration. On A100 in SR-IOV Heavy mode, it also disables P2P over NVLink and NVSwitch between the VM’s vGPUs, a restriction that does not apply to H100, H200 or newer. For NVIDIA NIM, enabling UVM can change the backend: with an optimised engine available the model runs on TensorRT-LLM, otherwise typically on vLLM.

Isolation is the other caveat. The 2026 PAGE404 work found that the hardware access-counter pool driving page migration is shared across MIG instances, so MIG’s isolation guarantees do not extend to it.

For an inference service, then, the first question is not which hint to set. It is whether the working set fits once the KV cache reaches its worst case, on the platform and the vGPU profile you will actually deploy. If it fits, prefetching brought UVM close to explicit copies in UVMBench and in the 2024 Grace Hopper study. If it does not, plan for UVM as a way to keep running, not as a serving design, and measure the per-token cost of the spill before you commit.