Demand paging is a virtual memory management technique where data pages are transferred from a slower backing store—such as system RAM or NVMe storage—into faster GPU device memory only when a GPU kernel attempts to access them, as signaled by a page fault. This mechanism enables applications to operate on datasets larger than the physical GPU memory capacity by treating host memory and storage as an extension, swapping pages on-demand. It is a foundational component for memory overcommit and unified virtual memory (UVM) systems in accelerator computing.
Glossary
Demand Paging

What is Demand Paging?
Demand paging is a core virtual memory technique for managing GPU memory capacity, directly impacting inference latency and cost.
The performance of demand paging hinges on minimizing page fault latency. When a fault occurs, execution stalls while the required page is migrated, directly increasing inference latency. Optimizations include prefetching algorithms that predict future accesses and huge pages to reduce fault frequency. In AI workloads, demand paging is critical for large model inference, enabling GPU memory oversubscription by keeping only active attention key-value (KV) cache pages resident while others reside in host memory, a trade-off between throughput and per-request latency.
Key Characteristics of Demand Paging
Demand paging is a foundational virtual memory technique that defers data transfer into GPU memory until the moment it is required for computation. This section details its core operational mechanisms and system-level impacts.
On-Demand Page Migration
The core mechanism where data pages are transferred from a backing store (system RAM or SSD) into GPU device memory only when a kernel attempts to access an address that is not currently resident. This access attempt triggers a GPU page fault, which halts the executing thread and initiates a page migration operation to fetch the required data before resuming execution. This lazy loading principle is what defines 'demand' paging.
Transparency to the Programmer
A key benefit is that demand paging operates transparently beneath the CUDA Unified Memory programming model. Developers can write code using single pointers (e.g., allocated with cudaMallocManaged) that are accessible from both CPU and GPU. The memory management unit (MMU) and driver handle all migration logic, freeing the programmer from manually staging data via cudaMemcpy. This simplifies code but requires an understanding of the performance implications of page faults.
Enables Memory Overcommit
Demand paging is the essential enabler for memory overcommit (oversubscription). It allows an application to allocate a total working set larger than the physical GPU memory (VRAM) capacity. The system relies on host memory and even storage (via technologies like GPU Direct Storage) as a slower, larger backing tier. Only the actively accessed 'hot' pages reside in fast GPU memory, while 'cold' pages remain in slower tiers, effectively creating a large virtual address space.
Performance Trade-off: Latency vs. Utilization
The technique introduces a fundamental trade-off:
- Benefit: Maximizes GPU memory utilization by keeping only needed data resident, allowing more or larger models to run concurrently.
- Cost: Page fault latency. Handling a fault involves significant overhead: interrupting execution, migrating data over the PCIe bus (or NVLink), and resuming. Excessive faulting can devastate throughput, turning a compute-bound kernel into a memory-bound or I/O-bound operation. Performance optimization focuses on minimizing faults through access pattern optimization and prefetching hints.
Integration with Unified Virtual Memory (UVM)
Demand paging is a runtime behavior of a Unified Virtual Memory (UVM) system. UVM establishes a single virtual address space across CPU and GPU. Demand paging is the dynamic data movement policy within that space. Other UVM features, like CPU-initiated page faults and memory prefetching APIs (cudaMemPrefetchAsync), work in concert with demand paging to optimize data locality and hide migration latency.
Critical for Large Model Inference
This characteristic is pivotal for deploying large language models (LLMs) where the model weights exceed GPU memory. With demand paging, weights can be staged in CPU RAM or NVMe storage. During inference, the attention mechanism generates a sequential access pattern across layers and the KV cache. While naive demand paging would cause severe stuttering, it is combined with predictive prefetching algorithms that proactively load the weights for the next layer or sequence position, overlapping compute with data migration to sustain high throughput.
Demand Paging vs. Traditional Swapping
A technical comparison of two virtual memory techniques for managing GPU memory capacity, highlighting their operational mechanisms, performance characteristics, and suitability for AI inference workloads.
| Feature / Metric | Demand Paging | Traditional Swapping |
|---|---|---|
Unit of Transfer | Memory Page (e.g., 4KB, 2MB, 1GB) | Entire Process Context |
Transfer Trigger | GPU Page Fault on first access | System-wide memory pressure |
Granularity | Fine-grained (page-level) | Coarse-grained (process-level) |
Latency Impact | Per-access fault penalty (< 1 ms from host RAM, ~10-100 ms from SSD) | Process stall during full context swap (100s of ms to seconds) |
GPU Utilization | High; compute continues on other warps/threads during page fetch | Low to zero; GPU is idle during swap-in/swap-out |
Primary Use Case | Transparently oversubscribe GPU memory for large models | Relieve severe host memory pressure for multiple jobs |
Implementation Complexity | High; requires OS, driver, and GPU MMU support (e.g., NVIDIA UVM) | Low; standard OS scheduler function |
Optimal For | Inference with large, sparse memory access patterns | Multi-tenancy with independent, smaller workloads |
Implementations and Frameworks
Demand paging is implemented through a combination of hardware support, operating system drivers, and runtime libraries. These frameworks manage the virtual address space, handle page faults, and orchestrate data movement between memory tiers.
Page-Locked Host Memory & DMA
A foundational technique that enables efficient demand paging by ensuring host memory is ready for rapid transfer.
- Pinned (Page-Locked) Memory: Host memory allocated with
cudaHostAllocorhipHostMallocis prevented from being paged to disk by the OS, guaranteeing a fixed physical address. - Direct Memory Access (DMA): The GPU's DMA engine can directly read from/write to this pinned memory without CPU intervention, which is essential for fast page migration during a fault.
- Zero-Copy Fallback: In some implementations, the GPU can directly access pinned host memory (a 'zero-copy' transfer) as a temporary measure while the target page is being migrated to device memory.
User-Space Drivers & Runtime (ROCm, CUDA)
The software stack that orchestrates demand paging, sitting between the application and the kernel-mode driver.
- Virtual Address Management: The runtime (e.g.,
libcuda.so,libhip.so) manages the GPU's page tables, mapping virtual addresses to physical pages in GPU memory, system memory, or indicating 'not present'. - Fault Service Routine: When the GPU MMU raises a page fault, the user-space driver's fault handler is invoked. It identifies the required page, schedules a DMA transfer via the kernel driver, and updates the page table.
- Concurrency & Streams: Fault handling is designed to be asynchronous and non-blocking for other work on the GPU, allowing computation to continue on different streams while a fault is serviced.
Frequently Asked Questions
Demand paging is a core virtual memory technique for managing GPU memory capacity. These questions address its mechanisms, benefits, and role in modern AI infrastructure.
Demand paging is a virtual memory management technique where data is transferred from a slower backing store (like system RAM or SSD) into faster GPU device memory only when a GPU compute kernel attempts to access it, as triggered by a page fault. It works by extending the GPU's virtual address space beyond its physical memory limits. When a GPU thread accesses a virtual address whose corresponding physical page is not resident in GPU memory, a GPU page fault occurs. This fault is handled by the driver and hardware, which pauses the relevant work, migrates the required page from the host or storage, and then resumes execution transparently. This mechanism enables memory overcommit, allowing workloads to allocate more memory than the GPU physically has, with pages swapped in on-demand.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Demand paging operates within a broader ecosystem of memory management techniques essential for efficient GPU utilization. These related concepts define the architecture and mechanisms that enable high-performance, capacity-optimized computing.
Unified Virtual Memory (UVM)
A memory management architecture that creates a single, contiguous virtual address space shared between a CPU and GPU. This allows both processors to access the same memory pointers using a unified page table, simplifying data sharing and enabling demand paging by providing a coherent framework for page migration between host and device memory.
- Key Mechanism: A single virtual address for a data object can be accessed by code running on either processor.
- Enables Demand Paging: The unified address space is the prerequisite for the GPU's memory management unit to trigger page faults and migrate data on-demand.
- Example: NVIDIA's CUDA UVM allows
cudaMallocManagedto allocate memory accessible from both CPU and GPU code.
GPU Page Faults
An exception raised when a GPU thread attempts to access a virtual memory address whose corresponding physical page is not resident in GPU device memory. This hardware event is the critical trigger for demand paging.
- Fault Handler: The fault is handled by the GPU's Memory Management Unit (MMU) in conjunction with the driver, which initiates a page migration.
- Migration Source: The required page is retrieved from its backing store, which could be system memory (RAM) or even storage (NVMe SSD) in advanced systems.
- Performance Impact: While enabling overcommit, excessive page faults lead to stall cycles, harming latency and throughput.
Page Migration
The process of transparently moving a memory page between different tiers of a memory hierarchy in response to access patterns or capacity constraints. It is the core action executed after a page fault in a demand paging system.
- Direction: Pages migrate to the GPU on a read fault and may be migrated back to host memory if the GPU memory is under pressure (eviction).
- Granularity: Typically occurs at the system page size (e.g., 4KB, 2MB with huge pages).
- Managed by: The GPU driver and hardware MMU, often using a least-recently-used (LRU) or similar policy for eviction decisions.
Memory Overcommit (Oversubscription)
A technique where the total memory allocated for active GPU workloads exceeds the physical capacity of the GPU's device memory. Demand paging is the primary mechanism that makes overcommit feasible by using system memory and storage as a backing store.
- Use Case: Allows running larger models or batch sizes than would physically fit in GPU RAM.
- Trade-off: Introduces potential latency variability due to page fault handling. Performance depends heavily on access locality.
- System Requirement: Requires a unified memory architecture (like UVM) and sufficient host memory or fast storage to act as swap space.
Page-Locked Memory (Pinned Memory)
Host (CPU) system memory that is prevented from being paged out to disk by the operating system. This guarantees the physical memory address remains fixed, enabling high-bandwidth Direct Memory Access (DMA) transfers to/from the GPU.
- Contrast with Demand Paging: Pinned memory is used for explicit, asynchronous copies (e.g.,
cudaMemcpyAsync). Demand paging enables implicit, on-demand migration. - Performance: Essential for achieving peak PCIe transfer bandwidth. Critical for prefetching strategies that work alongside demand paging.
- Drawback: Excessive pinning can reduce available system memory for other processes and increase OS memory pressure.
GPU Direct Storage (GDS)
A technology that enables a GPU to directly access data from storage devices (e.g., NVMe SSDs), bypassing the CPU and host memory buffer. This creates a direct data path for demand paging when the backing store is fast storage.
- Architecture: Allows the GPU's DMA engines to read/write directly to NVMe drives using the PCIe bus.
- Impact on Demand Paging: Dramatically reduces I/O latency and CPU overhead when migrating pages from SSD to GPU memory, making storage-backed oversubscription more viable.
- Example: An inference server can hold a 100GB model checkpoint on SSD, with GDS enabling fast on-demand loading of active layers to GPU memory.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us