Inferensys

Glossary

Global Memory (Device Memory)

Global memory, also called device memory, is the large, high-bandwidth DRAM physically located on a GPU, accessible by all threads and serving as the primary workspace for kernels.
Stylish WeWork-like workspace with hot desks and document wall, professional searching through enterprise knowledge base on a mounted ultrawide display, warm industrial pendants overhead.
GPU MEMORY OPTIMIZATION

What is Global Memory (Device Memory)?

Global memory, also referred to as device memory, is the large, high-bandwidth, but higher-latency DRAM physically located on a GPU, accessible by all threads across all blocks and serving as the primary workspace for GPU kernels.

Global memory is the primary, high-capacity DRAM physically located on a Graphics Processing Unit (GPU). It serves as the main workspace for CUDA kernels, storing model weights, activations, and input/output data. Accessible by all threads across all thread blocks, it offers high bandwidth but has significantly higher latency than on-chip memories like shared memory or L1/L2 cache. Efficient management of global memory is critical for inference latency and throughput, as it is often the performance bottleneck for data-intensive workloads.

Optimizing access to this memory involves techniques like coalesced memory access to maximize bandwidth and using memory pools to reduce allocation overhead. In modern systems, it is part of a memory hierarchy that may include High Bandwidth Memory (HBM) and is managed alongside host memory via technologies like Unified Virtual Memory (UVM). For large models, strategies such as model quantization and KV cache management directly target reducing the footprint in global memory to avoid costly swapping to slower tiers.

GPU MEMORY OPTIMIZATION

Key Characteristics of Global Memory

Global memory, also called device memory, is the primary, high-bandwidth DRAM on a GPU. It is accessible by all threads but has higher latency than on-chip caches, making its management critical for performance.

01

Primary Workspace for Kernels

Global memory serves as the main data workspace for GPU kernels. It holds the input data, intermediate results, and final outputs for parallel computations. Unlike shared memory, which is private to a thread block, global memory is accessible by all threads across all blocks launched on a GPU. All data transferred from the host (CPU) via cudaMemcpy resides here, and kernels read from and write to this memory to perform their computations.

02

High Bandwidth, High Latency

Global memory provides extremely high bandwidth (hundreds of GB/s to over 1 TB/s on modern GPUs) but also has high latency (hundreds of clock cycles). This latency is mitigated through massive parallelism: while one warp of threads is stalled waiting for data, the GPU scheduler can switch to other warps that are ready to execute, effectively hiding the latency. Achieving peak bandwidth requires coalesced memory access patterns, where consecutive threads in a warp access consecutive memory addresses.

03

Managed by a Virtual Memory System

Modern GPUs manage global memory through a virtual memory system, similar to CPUs. This enables key features:

  • Unified Virtual Memory (UVM): Creates a single virtual address space shared by CPU and GPU.
  • Demand Paging: Data is migrated to GPU memory only upon access (page fault).
  • Memory Overcommit: Allows allocation of more memory than physically exists on the GPU, with pages swapped to host memory or storage. This abstraction simplifies programming but introduces overhead for page fault handling and migration.
04

Subject to Access Pattern Constraints

Performance is heavily dependent on memory access patterns. Optimal patterns maximize throughput:

  • Coalesced Access: Consecutive threads access consecutive 32-byte aligned segments. This merges requests into a minimal number of transactions.
  • Strided or Misaligned Access: Threads access non-consecutive addresses, causing multiple, smaller transactions and drastically reducing effective bandwidth.
  • Partition Camping: Excessive accesses to a single memory channel can create a bottleneck, even if accesses are coalesced. Profiling tools like Nsight Compute are essential for identifying suboptimal patterns.
05

Hierarchical Placement and Caching

Global memory sits at the bottom of the GPU's memory hierarchy, above system memory and storage but below on-chip memories. It is cached by several structures:

  • L2 Cache: A large, unified cache shared by all Streaming Multiprocessors (SMs) that helps capture spatial and temporal locality.
  • Read-Only Cache: A dedicated cache for data marked as constant (__constant__) or accessed via specific intrinsics.
  • Texture Cache: Optimized for 2D spatial locality. Data not found in these caches must be fetched from global memory at full latency. Effective use of shared memory as a programmer-managed cache is the primary strategy to reduce global memory traffic.
06

Allocation and Fragmentation Challenges

Dynamic allocation in global memory (e.g., cudaMalloc) is expensive and can lead to memory fragmentation. Over time, free memory can become divided into small, non-contiguous blocks, preventing the allocation of large buffers even if total free memory is sufficient. Best practices to mitigate this include:

  • Using memory pools (arenas) for frequent allocations/deallocations.
  • Pre-allocating large buffers and managing sub-allocations manually.
  • Leveraging stream-ordered memory allocators (like cudaMallocAsync) for asynchronous, context-aware allocation that reduces fragmentation. Fragmentation can lead to out-of-memory errors and reduced performance in long-running inference services.
GPU MEMORY OPTIMIZATION

Role in AI and Machine Learning Workloads

Global memory, also called device memory, is the primary, high-capacity workspace on a GPU accelerator, directly impacting the scale and speed of model inference and training.

Global memory (device memory) is the large, high-bandwidth DRAM physically located on a GPU, accessible by all threads and serving as the primary workspace for model weights, activations, and intermediate tensors. Its capacity is the critical constraint for determining which models can be loaded and at what batch size, making its management fundamental to inference latency and throughput. Unlike CPU system memory, it is optimized for massively parallel access but has higher latency than on-chip caches.

Efficient use of global memory is paramount for latency reduction. Techniques like memory pooling to avoid allocation overhead, coalesced memory access patterns to maximize bandwidth, and unified memory architectures to simplify data movement are essential. For large models, strategies such as model quantization and activation offloading are employed to work within fixed global memory limits, directly tying memory optimization to infrastructure cost control and scalable deployment.

ARCHITECTURE

GPU Memory Hierarchy Comparison

A comparison of the key memory types within a GPU's hierarchy, highlighting their role, scope, latency, and bandwidth relative to the primary workspace of Global Memory (Device Memory).

Memory TypeRole & ScopeRelative LatencyRelative BandwidthSoftware Management

Registers

Private storage for individual thread variables.

~1 cycle

Extremely High

Automatic (Compiler)

Shared Memory / L1 Cache

Low-latency cache shared by threads within a block for communication/data reuse.

~10-20 cycles

Very High

Explicit (Programmer)

L2 Cache

Unified cache shared across all Streaming Multiprocessors (SMs) on the GPU.

~100-200 cycles

High

Automatic (Hardware)

Global Memory (Device Memory)

Primary high-capacity DRAM workspace for all GPU threads; the main subject of optimization.

~400-800 cycles

High (Peak)

Explicit (Programmer/API)

Unified Virtual Memory (Host+Device)

Single virtual address space spanning CPU and GPU memory, enabling seamless data access.

Variable (Page Fault Penalty)

Variable (Depends on Location)

Automatic (Driver/Runtime)

Page-Locked (Pinned) Host Memory

Non-pageable host memory enabling high-bandwidth DMA transfers to/from GPU.

1000 cycles (for GPU access)

High (for DMA)

Explicit (Programmer/API)

Local Memory

Thread-private spill-over memory from registers, physically residing in Global Memory.

Global Memory Latency

Global Memory Bandwidth

Automatic (Compiler)

Constant Memory

Read-only, cached memory for data accessed uniformly by all threads (e.g., kernel parameters).

Cache Latency if hit, Global if miss

High if cached

Explicit (Programmer/API)

Texture Memory

Specialized read-only cache optimized for 2D spatial locality (e.g., image processing).

Cache Latency if hit, Global if miss

High if cached

Explicit (Programmer/API)

GPU MEMORY OPTIMIZATION

Frequently Asked Questions

Global memory, also called device memory, is the primary high-bandwidth DRAM on a GPU. These questions address its role, management, and optimization for high-performance computing and machine learning workloads.

Global memory, also referred to as device memory, is the large, high-bandwidth, but higher-latency DRAM physically located on a GPU, accessible by all threads across all blocks and serving as the primary workspace for GPU kernels. It is the main pool of memory where data is transferred from the host (CPU) for processing. Unlike the small, fast shared memory or L1/L2 caches, global memory has significantly higher capacity (e.g., 16GB to 80GB+ on modern accelerators) but also higher access latency. Its performance is critically dependent on achieving coalesced memory access patterns to maximize effective bandwidth.

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.