Inferensys

Glossary

Peer-to-Peer (P2P) Access

Peer-to-Peer (P2P) access is a hardware and software capability that allows GPUs within a system to directly read from and write to each other's memory over a high-speed interconnect, bypassing the CPU and host system memory to dramatically reduce communication latency in multi-GPU workloads.
Developer building agentic RAG system, retrieval pipeline diagram on laptop, technical workspace with notes.
GPU MEMORY OPTIMIZATION

What is Peer-to-Peer (P2P) Access?

A direct communication channel between GPUs that bypasses the CPU and host memory, crucial for high-performance multi-GPU computing.

Peer-to-Peer (P2P) Access is a hardware and software capability that enables GPUs within the same system to directly read from and write to each other's device memory. This is achieved over a high-speed interconnect like NVLink or PCIe, allowing data transfers to occur without staging through the host's CPU memory (RAM). The primary technical benefit is a dramatic reduction in communication latency and an increase in effective bandwidth between accelerators, which is essential for scaling distributed training and large-model inference workloads.

For P2P access to be enabled, the GPUs must be on the same PCIe root complex or connected via NVLink, and the operating system driver must support it. In practice, this allows kernels running on one GPU to directly access the global memory of another, enabling efficient model parallelism and parameter synchronization. This direct path eliminates a major bottleneck in multi-GPU systems, as it avoids the bandwidth limitations and added latency of the CPU memory bus, making data exchange between GPUs nearly as fast as accessing their own local memory.

GPU MEMORY OPTIMIZATION

Key Characteristics of P2P Access

Peer-to-Peer (P2P) access is a foundational capability for multi-GPU systems, enabling direct data transfers between accelerator devices. This section details its core mechanisms, enabling technologies, and performance implications.

01

Direct GPU-to-GPU Transfers

P2P access enables GPUs within the same system to read and write directly to each other's device memory without staging data through the host's CPU memory. This bypasses the PCIe bus for the CPU leg of the transfer, cutting latency and freeing host memory bandwidth for other tasks. It is essential for workloads like large model training where tensors must be shared between GPUs every iteration.

  • Mechanism: Managed by the GPU driver and CUDA runtime via APIs like cudaDeviceEnablePeerAccess().
  • Benefit: Can double effective bandwidth for inter-GPU communication compared to a host-mediated copy.
02

NVLink & High-Speed Interconnects

P2P performance is dictated by the physical interconnect between GPUs. NVLink is NVIDIA's dedicated, high-bandwidth interconnect designed specifically for GPU-to-GPU communication, offering significantly higher bandwidth and lower latency than standard PCIe.

  • NVLink: Provides a direct mesh or switch fabric between GPUs (e.g., up to 900 GB/s with NVLink 4.0). Enables a unified memory address space across multiple GPUs.
  • PCIe P2P: Also supports direct transfers but is limited by shared PCIe switch bandwidth and higher protocol overhead. Performance is highly dependent on system topology (e.g., GPUs on the same PCIe root complex).
03

Unified Virtual Addressing (UVA)

Unified Virtual Addressing is a memory model that provides a single, contiguous virtual address space across all GPU and host CPU memory in a system. UVA is a prerequisite for transparent P2P access, as it allows pointers to be dereferenced from any GPU without manual translation.

  • Function: The CUDA driver and GPU Memory Management Unit (MMU) translate a virtual address to the correct physical location, whether it's in another GPU's memory or host memory.
  • Transparency: Enables APIs like cudaMemcpy to perform P2P transfers automatically when source and destination pointers reside in different GPU memories, simplifying programmer effort.
04

Topology & Peer Accessibility

Not all GPU pairs in a system can establish a direct P2P link. Accessibility depends on the physical system topology—how GPUs are connected via PCIe switches and root complexes—and the presence of NVLink bridges.

  • Check Peer Access: Use cudaDeviceCanAccessPeer() to determine if a direct path exists between two GPUs.
  • PCIe Complexity: In multi-GPU servers, GPUs may be connected via multiple PCIe switches. Optimal P2P bandwidth is achieved when GPUs are on the same NUMA node and PCIe root complex.
  • NVIDIA DGX/ HGX Systems: Utilize fully connected NVLink topologies (e.g., NVSwitch) to provide uniform, high-bandwidth P2P access between all GPUs in the pod.
05

Use Cases: Multi-GPU Training & Inference

P2P access is critical for scaling deep learning training and large-model inference across multiple GPUs.

  • Model Parallelism: Different layers of a single model are split across GPUs. Activations and gradients are passed directly between GPUs each forward/backward pass, making P2P latency a major factor in training speed.
  • Data Parallelism: While each GPU works on a separate data batch, operations like all-reduce for gradient synchronization (e.g., via NCCL) rely heavily on P2P links for optimal performance.
  • Inference for Large Models: Running models that exceed the memory of a single GPU requires tensor parallelism, where intermediate results are directly exchanged between GPUs during the generation phase.
06

Performance Considerations & Limitations

While powerful, P2P access has specific constraints and performance nuances.

  • Bandwidth is Not Symmetric: Transfer speed from GPU A to GPU B may differ from B to A, depending on interconnect topology.
  • Memory Allocation Alignment: For best PCIe P2P performance, allocations should be aligned to 64KB boundaries.
  • Software Overhead: Enabling peer access has a small, one-time setup cost. The first transfer between a new peer pair may incur additional latency.
  • No CPU Access: Direct P2P memory is not directly accessible by the CPU; the CPU must still access it via the GPU's mapped PCIe BAR, which is slower than host memory.
  • System BIOS/SW Settings: Features like Above 4G Decoding and SR-IOV must often be configured correctly in the system BIOS for P2P to function.
GPU MEMORY OPTIMIZATION

How Does Peer-to-Peer Access Work?

Peer-to-Peer (P2P) access is a foundational technique for high-performance multi-GPU computing, enabling direct data transfers between accelerator devices.

Peer-to-Peer (P2P) access is a hardware and software capability that allows multiple GPUs within a system to directly read from and write to each other's device memory over a high-speed interconnect, bypassing the host CPU and system memory. This direct path, enabled by technologies like NVLink or via the PCIe bus with P2P support, eliminates the latency and bandwidth bottlenecks of copying data through host memory. It is essential for scaling workloads like large model training and high-performance computing across multiple GPUs, as it facilitates fast collective operations and efficient data sharing between devices.

For P2P access to function, the system hardware must support it, typically requiring GPUs to be on the same PCIe root complex or connected via NVLink. The software stack, through APIs like CUDA, must then explicitly enable the capability, allowing kernels on one GPU to directly access pointers in another GPU's memory. This creates a unified address space across devices, simplifying programming. Effective use of P2P access is a key optimization within the broader GPU memory hierarchy, dramatically reducing inter-GPU communication latency and freeing host resources for other tasks.

GPU MEMORY OPTIMIZATION

Primary Use Cases for P2P Access

Peer-to-Peer (P2P) access enables direct GPU-to-GPU communication, bypassing the CPU and host memory. This capability is foundational for scaling workloads across multiple accelerators. Below are its key applications in high-performance computing and machine learning.

01

Multi-GPU Model Training

P2P access is essential for data-parallel and model-parallel training strategies. In data parallelism, gradients must be averaged across all GPUs after each backward pass. P2P enables high-speed all-reduce operations directly between GPU memories, drastically reducing synchronization overhead compared to routing through host memory. For model parallelism, where different layers of a single model are split across devices, P2P allows activations and gradients to flow directly between GPUs during the forward and backward passes, minimizing inter-GPU communication latency.

5-10x
Higher Bandwidth vs PCIe
02

Large Model Inference

Running inference for models whose parameters exceed the memory of a single GPU requires model sharding. P2P access allows different layers or components of the model to reside on separate GPUs. During inference, the intermediate activations are passed directly from one GPU to the next via the high-speed interconnect (e.g., NVLink), creating a pipeline. This avoids the latency of copying data back to the CPU between each layer's execution, which is critical for meeting low-latency service-level agreements (SLAs) for large language models (LLMs) and diffusion models.

03

High-Performance Computing (HPC)

In scientific computing, applications like computational fluid dynamics (CFD), molecular dynamics, and climate modeling involve massive, spatially decomposed datasets. P2P access allows GPUs working on adjacent spatial domains to exchange halo regions or boundary data directly. This direct exchange is far more efficient than a centralized gather-scatter pattern via the host, enabling stronger scaling and reducing time-to-solution for simulations that require frequent neighbor communication across the GPU grid.

04

GPU-Accelerated Databases & Analytics

Systems like GPU-accelerated SQL databases and dataframe libraries (e.g., RAPIDS cuDF) use P2P for multi-GPU join, sort, and aggregation operations. When a dataset is partitioned across GPUs, performing a global operation requires shuffling data. P2P enables direct GPU-to-GPU transfers for this shuffle phase, maximizing throughput for in-memory analytics. This is particularly effective for operations that are bandwidth-bound rather than compute-bound.

05

NVLink-Based GPU Clustering

NVIDIA's NVLink technology provides a switched fabric for connecting multiple GPUs at extremely high bandwidth. P2P access over NVLink creates a unified memory domain across GPUs, allowing them to access each other's memory as if it were their own. This enables:

  • GPU Direct RDMA: For MPI-based applications, GPUs can directly read/write to the memory of GPUs in other nodes.
  • Large Unified Address Spaces: Applications can allocate a single buffer that is physically distributed across multiple GPUs but accessible from any GPU in the cluster without explicit programming, managed by the UVM driver.
06

Overcoming PCIe Root Complex Bottlenecks

In multi-GPU systems connected via PCIe, all cross-GPU traffic traditionally routes through the CPU's PCIe root complex. This creates a bottleneck, as bandwidth is shared and latency increases. Enabling P2P access allows GPUs on the same PCIe switch (often within the same root complex) to communicate directly, bypassing the root complex. This topology-aware optimization is crucial for maximizing bandwidth in systems without NVLink, such as those using standard PCIe Gen4/Gen5 switches.

GPU MEMORY OPTIMIZATION

P2P Access vs. Traditional Host-Staged Transfer

A comparison of two fundamental paradigms for moving data between GPUs within a single system, highlighting their impact on latency, bandwidth, and host resource utilization.

Feature / MetricPeer-to-Peer (P2P) AccessTraditional Host-Staged Transfer

Primary Data Path

Direct GPU-to-GPU over NVLink/PCIe

GPU → Host Memory → GPU

Host Memory Bandwidth Consumption

0 GB/s

≥ 2x Data Size (Read + Write)

Typical Latency (for 1GB transfer)

< 5 ms (NVLink)

20 ms (PCIe Gen4)

Effective Bandwidth (NVLink System)

600-900 GB/s

Limited by PCIe (~64 GB/s) or host memory BW

CPU Utilization

Minimal (initiation only)

High (DMA engine management, potential CPU copies)

Required CUDA Support

cudaDeviceEnablePeerAccess

Standard cudaMemcpy

Use Case Ideal For

Multi-GPU model parallelism, tightly coupled workloads

One-off transfers, systems without P2P topology

Topology Dependency

Yes (requires NVLink or PCIe P2P support)

No (works on any PCIe topology)

GPU MEMORY OPTIMIZATION

Frequently Asked Questions

Peer-to-Peer (P2P) access is a critical capability for high-performance multi-GPU computing. These questions address its core mechanisms, requirements, and practical applications.

Peer-to-Peer (P2P) access is a hardware and software capability that enables GPUs within the same system to directly read from and write to each other's memory without routing data through the host CPU's system memory (RAM). It works by leveraging a high-speed interconnect, such as NVLink or PCIe, to establish a direct data path between GPU devices. When enabled, one GPU can perform a Direct Memory Access (DMA) operation to another GPU's memory, bypassing the host entirely. This is managed by the GPU driver and runtime (e.g., CUDA), which sets up the necessary address translations and mappings, allowing kernels on one GPU to use pointers to memory physically located on a peer GPU.

Prasad Kumkar

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.