1. Why Standard OS Memory Paging Breaks Local LLM Speed
Standard application memory allocated by malloc() is pageable: the operating system can relocate pages or flush them to NVMe swap at any moment. Before an NVIDIA GPU can copy pageable host memory over PCIe, the CUDA driver must first allocate a temporary staging buffer and copy the bytes via the CPU—adding latency and saturating CPU cores.
Page-locked (pinned) memory instructs the OS kernel to lock physical RAM addresses in place. This allows the GPU Direct Memory Access (DMA) engine to pull expert weight tensors straight from DDR4/DDR5 across the PCIe bus asynchronously while the GPU continues computing prior layers.
2. Asynchronous Prefetching & Overlapping Compute with Transfer
Sparse MoE offloading relies on overlapping two pipelines: CUDA Stream A executes attention and hot-expert matrix multiplication for Layer N, while CUDA Stream B prefetches cold experts predicted for Layer N+1 over PCIe. When the active payload per token is small and the PCIe link runs at full Gen 4 x16 (~25–27 GB/s) or Gen 5 x16 (~50–55 GB/s), transfer latency is largely hidden behind GPU compute.
3. Operational Limits of Pinned Memory on 64GB PCs
Because pinned memory cannot be swapped out by Windows or Linux, locking too large a buffer leaves the OS unable to respond to sudden background allocations—resulting in abrupt SIGKILL / OOM terminations. Always keep 8–10 GB of unpinned host RAM headroom for the operating system and IDE.