Machine Learning pathway increased my salary by 40%
GPU Computing for AI
Master the architecture, performance, and economics of Graphics Processing Units (GPUs) — the foundational compute engine powering modern artificial intelligence.
Executive Summary
Graphics Processing Units (GPUs) have become the dominant compute platform for artificial intelligence workloads. Unlike CPUs optimized for sequential, latency-sensitive tasks, GPUs are massively parallel processors designed for throughput computing. This chapter provides a comprehensive technical treatment of GPU architecture, programming models, performance optimization, and deployment considerations for AI workloads. We cover NVIDIA, AMD, and emerging GPU alternatives, with deep dives into memory hierarchies, parallelization strategies, and the economics of GPU computing.
Definition
GPU Computing for AI refers to the use of Graphics Processing Units to accelerate machine learning training and inference workloads. GPUs achieve their performance advantage through thousands of compute cores executing thousands of threads simultaneously, combined with high-bandwidth memory architectures. The GPU programming model, exemplified by NVIDIA CUDA and AMD ROCm, allows developers to express data-parallel algorithms that map efficiently to the GPU massively parallel architecture.
Why It Matters
GPU computing is the foundation of modern AI. The transition from CPU-based machine learning to GPU-accelerated deep learning in the early 2010s enabled the breakthroughs that define today AI landscape. Understanding GPU architecture is essential for selecting the right hardware for training and inference workloads, optimizing performance through memory management and parallelization, estimating costs accurately for infrastructure planning, troubleshooting performance bottlenecks in production, and designing efficient distributed systems that leverage GPU communication.
2026 Landscape
GPU Market Overview NVIDIA: - H100: Current flagship data-center GPU (80GB HBM3, 3.35 TB/s bandwidth) - H200: Enhanced H100 with additional HBM3E memory (141GB) - B100/B200 (Blackwell): Next-generation architecture announced - RTX 6000 Ada: Workstation GPU for AI development AMD: - MI300X: Data-center accelerator competing with H100 (192GB HBM3, 5.3 TB/s) - ROCm 6.0: Open software stack Intel: - Gaudi 3: AI accelerator - Data Center GPU Max series GPU Architecture Trends: - Increasing HBM capacity and bandwidth - Advanced precision support (FP8, FP4) - Enhanced multi-GPU communication (NVLink, Infinity Fabric) - Higher power density (800W+ per GPU) - Liquid cooling becoming standard Key Metrics: - FLOPS (Floating Point Operations Per Second) - Memory Bandwidth (TB/s) - Interconnect Bandwidth (GB/s) - Precision Support (FP64, FP32, FP16, BF16, FP8, INT8)
Learning Objectives
- Explain GPU architecture and its advantages for AI workloads
- Analyze GPU memory hierarchies and their impact on model training
- Design efficient GPU kernels for matrix multiplication and attention
- Optimize GPU utilization through batching and parallelism strategies
- Select appropriate GPU configurations for different AI workloads
- Implement distributed training strategies on multi-GPU systems
- Estimate GPU requirements and costs for infrastructure planning
- Evaluate GPU vs TPU vs ASIC trade-offs
Prerequisites
- Computer architecture fundamentals
- Understanding of AI/ML training and inference
- Basic knowledge of parallel computing concepts
- Familiarity with matrix multiplication and linear algebra
CPU vs GPU Architecture
CPUs are optimized for sequential, latency-sensitive tasks with a few powerful cores, deep cache hierarchies, and sophisticated branch prediction. GPUs are optimized for throughput with thousands of simpler cores, high-bandwidth memory, and massive parallelism. For AI workloads dominated by matrix multiplication and tensor operations, GPUs achieve 10-100x speedup over CPUs. The key architectural difference is that CPUs minimize latency for individual operations while GPUs maximize throughput across thousands of parallel operations.
CPU vs GPU vs TPU vs NPU vs ASIC
| Type | Core Count | Memory | Best For | Flexibility |
|---|---|---|---|---|
| CPU | 8-64 | DDR (100s GB) | Sequential, control flow | Highest |
| GPU | Thousands | HBM (80-192GB) | Parallel, matrix ops | High |
| TPU | Matrix units | HBM (16-192GB) | ML matrix multiply | ML-specific |
| NPU | Neural engines | Various | Edge AI inference | Edge-specific |
| ASIC | Custom | Custom | Fixed workloads | Lowest |
GPU Architecture Components
A GPU die consists of Streaming Multiprocessors (SMs) or Compute Units (CUs), each containing CUDA Cores or Stream Processors, Tensor Cores or Matrix Units, shared memory/L1 cache, and register file. The GPU also includes HBM (High-Bandwidth Memory), memory controllers, interconnect (NVLink/Infinity Fabric), and PCIe/other I/O. The NVIDIA H100 SXM has 132 SMs, each with 128 CUDA cores and 4 Tensor Cores, totaling 16,896 CUDA cores and 528 Tensor Cores, with 80GB HBM3 and 3.35 TB/s bandwidth.
NVIDIA H100 vs AMD MI300X
| Specification | NVIDIA H100 | AMD MI300X |
|---|---|---|
| Compute Cores | 16,896 CUDA + 528 Tensor | 19,456 Stream Processors |
| Memory | 80GB HBM3 | 192GB HBM3 |
| Memory Bandwidth | 3.35 TB/s | 5.3 TB/s |
| L2 Cache | 50MB | 256MB (Infinity Cache) |
| Interconnect | NVLink 4.0 (900 GB/s) | Infinity Fabric (896 GB/s) |
| PCIe | PCIe Gen5 (128 GB/s) | PCIe Gen5 |
| Power | ~800W | ~750W |
GPU Memory Hierarchy and Parallelization
GPU memory hierarchy flows from CPU system memory through PCIe (32-64 GB/s) to GPU HBM (3-5 TB/s), L2 cache, L1 cache/shared memory, register file, and compute units. Memory management for AI includes parameters (params × precision bytes), activations (batch × sequence × hidden), KV cache (batch × sequence × heads × head_dim × 2 × precision), and optimizer states (2 × parameters for Adam). Parallelization strategies include data parallelism (model replicated, data split), model parallelism (layers partitioned), tensor parallelism (tensors partitioned), and pipeline parallelism (micro-batches through stages).
Parallelization Strategies
| Strategy | Concept | Best For | Challenge |
|---|---|---|---|
| Data Parallelism | Model replicated, data split | Models fitting on single device | Communication overhead |
| Model Parallelism | Layers partitioned | Models exceeding device memory | Pipeline bubbles |
| Tensor Parallelism | Tensors partitioned | Large matrix operations | High communication overhead |
| Pipeline Parallelism | Micro-batches through stages | Deep models | Load balancing |
Architecture
GPU server architecture connects host system through GPUs with interconnect, networking, storage, and power.
Reference Architectures
AI Training Workflow on GPU
From data to trained model on GPU.
AI Inference Workflow on GPU
From request to response on GPU.
GPU Memory Management
Memory allocation for AI workloads.
GPU Memory Requirements for AI
Model Memory Requirements: MEMORY = PARAMETERS + ACTIVATIONS + KV CACHE + OPTIMIZER STATES + OVERHEAD PARAMETERS = (PARAMS × PRECISION_BYTES) ACTIVATIONS = BATCH × SEQUENCE_LENGTH × HIDDEN_SIZE KV CACHE = BATCH × SEQUENCE × HEADS × HEAD_DIM × 2 × PRECISION_BYTES OPTIMIZER STATES = 2 × PARAMETERS (for Adam) Example: 70B Parameter Model - Parameters (FP16): 70B × 2 bytes = 140GB - Single H100 (80GB) is not enough - Need multi-GPU with model parallelism - 8x H100 provides 640GB total (80GB each) Precision and Memory: - FP32: 4 bytes per parameter - FP16/BF16: 2 bytes per parameter - FP8: 1 byte per parameter - INT8: 1 byte per parameter - INT4: 0.5 bytes per parameter Quantization reduces memory requirements significantly: - FP16 to INT8: 50% memory reduction - FP16 to INT4: 75% memory reduction
Precision Comparison
| Precision | Bytes/Param | Use Case | Accuracy Impact |
|---|---|---|---|
| FP32 | 4 | Reference training | None |
| FP16 | 2 | Training, inference | Minimal |
| BF16 | 2 | Training (preferred) | Minimal |
| FP8 | 1 | Inference, training | Low |
| INT8 | 1 | Inference | Low-Moderate |
| INT4 | 0.5 | Inference (quantized) | Moderate |
Performance Optimization Techniques
Performance Bottlenecks: Compute-Bound: - Matrix multiplication dominates - Tensor cores fully utilized - Solution: Increase batch size, optimize kernels Memory-Bound: - Memory bandwidth saturation - Insufficient HBM capacity - Solution: Reduce precision, offload to CPU Communication-Bound: - Multi-GPU synchronization overhead - Network latency dominates - Solution: Use NVLink, InfiniBand, optimize topology Optimization Techniques: - Kernel Fusion: Combine operations to reduce memory traffic - Reduced Precision: Use FP16/BF16 for training, FP8/INT8 for inference - Memory Pooling: Reuse GPU memory allocations - Asynchronous Transfers: Overlap data transfer with computation - Batching: Process multiple inputs simultaneously GPU Utilization Metrics: - Compute utilization: % of peak FLOPS - Memory utilization: % of peak bandwidth - SM occupancy: % of available threads running
GPU Performance Metrics
| Metric | Description | Target |
|---|---|---|
| Compute Utilization | % of peak FLOPS used | 70-90% |
| Memory Utilization | % of peak bandwidth used | 70-90% |
| SM Occupancy | % of available threads running | >80% |
| GPU Temperature | Operating temperature | <80°C |
| Power Consumption | Power draw | <TDP |
| Scaling Efficiency | Multi-GPU scaling | >80% |
Technology Stack
| Component | Technology | Purpose |
|---|---|---|
| GPU Hardware | NVIDIA H100/H200, AMD MI300X | Compute accelerators |
| GPU Software | CUDA, ROCm | Programming models |
| AI Frameworks | PyTorch, TensorFlow, JAX | Model development |
| GPU Libraries | cuBLAS, cuDNN, rocBLAS | Optimized operations |
| Interconnect | NVLink, Infinity Fabric | GPU-to-GPU communication |
| Networking | InfiniBand, EFA, Ethernet | Inter-node communication |
| Monitoring | DCGM, nvidia-smi, Prometheus | GPU monitoring |
| Container Runtime | NVIDIA Container Toolkit | GPU in containers |
| Orchestration | Kubernetes with device plugins | GPU scheduling |
| Profiling | Nsight, ROCm Profiler | Performance analysis |
GPU vs TPU vs ASIC
| Dimension | GPU | TPU | ASIC |
|---|---|---|---|
| Flexibility | High (general-purpose) | ML-specific | Workload-specific |
| Programming | CUDA, ROCm | JAX, XLA | Vendor SDK |
| Software Ecosystem | Broadest | Google-optimized | Vendor-specific |
| Training | Excellent | Excellent | Moderate |
| Inference | Good | Good | Excellent |
| Memory | 80-192GB HBM | 16-192GB HBM | Varies |
| Networking | NVLink, InfiniBand | TPU interconnect | Vendor-specific |
| Availability | Broad (cloud + on-prem) | Google Cloud | Cloud-specific |
| Cost | Higher | Good price-performance | Lowest for inference |
| Portability | Multi-cloud | Google Cloud | Vendor lock-in |
NVIDIA GPU Generations
| GPU | Architecture | Memory | Bandwidth | Best For |
|---|---|---|---|---|
| H100 | Hopper | 80GB HBM3 | 3.35 TB/s | Large-scale training |
| H200 | Hopper | 141GB HBM3E | 4.8 TB/s | Larger models |
| A100 | Ampere | 40/80GB HBM2e | 1.5-2.0 TB/s | General training |
| L4 | Ada Lovelace | 24GB GDDR6 | 300 GB/s | Cost-optimized inference |
| A10G | Ampere | 24GB GDDR6 | 600 GB/s | Inference, fine-tuning |
| B100/B200 | Blackwell | 192GB HBM3e | 8 TB/s | Next-gen training |
GPU vs CPU - AI Workloads
| Dimension | GPU | CPU |
|---|---|---|
| Core Count | Thousands | 8-64 |
| Memory Bandwidth | 3-5 TB/s | 50-100 GB/s |
| Memory Capacity | 80-192GB HBM | 100s GB DDR |
| Parallelism | Massive | Moderate |
| AI Speedup | 10-100x | 1x (baseline) |
| Power | 300-800W | 200-400W |
| Cost | $10,000-$40,000 | $2,000-$10,000 |
| Best For | Training, inference | Control, data loading |
Enterprise Use Cases
Case Studies
Problem: Indian GCC experienced low GPU utilization (40%) across their A100 cluster for LLM training workloads.
Opportunity: Optimize GPU utilization through better batching, data pipeline optimization, and parallelism strategies.
Architecture: Analysis of data loading bottleneck (PCIe bandwidth), insufficient batching, CPU preprocessing bottleneck. Solution: increased batch size, optimized data pipeline, gradient accumulation.
Outcome: GPU utilization improved from 40% to 85%, training time reduced by 50%, annual cost savings of approximately $500,000.
Lessons: GPU optimization is as important as hardware selection, data pipeline often the bottleneck, batching size significantly impacts utilization.
Problem: Global AI company scaling from 1,024 to 8,192 A100 GPUs for foundation model training.
Opportunity: Build large-scale GPU cluster with InfiniBand networking and parallel file system.
Architecture: 8,192 A100 GPUs across 1,024 nodes, InfiniBand NDR 400 Gbps for node communication, NVSwitch for within-node GPU communication, parallel file system for training data.
Outcome: 80% scaling efficiency for model parallelism, 95% GPU utilization during training, training time reduced from 3 months to 2 weeks.
Lessons: Scaling to thousands of GPUs requires careful network design, communication dominates large-scale training, checkpointing overhead becomes significant.
Problem: Indian research institution needed to build a cost-effective GPU cluster for AI research.
Opportunity: Build on-premise GPU cluster with academic pricing for cost efficiency.
Architecture: 8x A100 GPUs (discounted academic pricing), 2x Intel Xeon CPUs, InfiniBand HDR 200 Gbps, 2x 1.92TB NVMe SSDs.
Outcome: 60% cost reduction vs cloud equivalent (over 3 years), 90% utilization for 80% of the time, 3x faster training vs previous CPU cluster.
Lessons: On-premise can be cost-effective for consistent usage, academic pricing provides significant savings, utilization is key to cost efficiency.
Problem: Global hedge fund needed AI for high-frequency trading with ultra-low latency.
Opportunity: Deploy GPU infrastructure with colocation for minimal latency.
Architecture: NVIDIA A100 GPUs for model training (offline), NVIDIA L4 GPUs for inference (low latency), colocation with trading exchanges.
Outcome: 90% GPU utilization for training, <1ms inference latency (single GPU), 25% improvement in trading performance.
Lessons: Training and inference have different requirements, low-latency inference requires specialized configuration, colocation reduces latency for financial applications.
Problem: Healthcare provider needed AI for medical imaging across 50+ hospitals.
Opportunity: Deploy hybrid GPU infrastructure with centralized training and edge inference.
Architecture: NVIDIA A100 for training (central), NVIDIA T4 for inference (edge), multi-site deployment with GPU clusters, secure data pipeline with encryption.
Outcome: 95% GPU utilization for training, 90% accuracy for disease detection, 3x faster diagnosis vs manual reading.
Lessons: Edge inference requires power-efficient GPUs, data pipeline and privacy are critical, multi-site deployment requires coordination.
Implementation Steps
Design a GPU Cluster for AI Training
Problem: Design a GPU cluster for training a 70B parameter LLM with a target training time of 2 weeks.
- 70B parameter model in FP16/BF16
- 1 trillion training tokens
- 2-week training time
- 80%+ scaling efficiency
- Fault tolerance with checkpointing
- Cost optimization strategy
Architecture: 1,024 H100 GPUs across 128 nodes, InfiniBand NDR 400 Gbps, parallel file system (Lustre), Slurm scheduling, PyTorch FSDP for distributed training.
Outcome: Complete cluster design with GPU sizing, networking topology, storage architecture, scheduling strategy, and cost model.
GCC Applications
- Build GPU cluster operations in GCCs for global enterprises
- Develop GPU infrastructure engineering and optimization
- Create GPU scheduling and resource allocation systems
- Establish GPU FinOps and cost optimization operations
- Build GPU performance monitoring and optimization
- Develop distributed training operations on GPU clusters
- Create GPU security and access management
- Build cross-market GPU operations for global AI training
