LLM Training Optimization Techniques

  • by David Spuler, Ph.D.

LLM Training Optimization

LLM training optimization is the set of techniques to speed up the training phases. Training has a forward pass and a backward pass, each with lots of matrix multiplications, and both need to be optimized. Efficiency of training is one of the largest bottlenecks for training larger frontier models.

This is a companion article to the list of 500+ LLM Inference Optimization Techniques. There is some overlap with the inference optimization techniques, but there's also a whole swathe of issues that don't arise in inference, such as an entire "backward pass" of parameter updates. The network is important, too, but for different reasons to inference, because there's no KV caching in training, but there is outward transmission of training data and the inter-GPU transmission of the gradients and parameter updates.

Training versus Inference Optimization: Some of the key training optimization concepts:

  • LLM training runs compute through all the Transformer's layers and sub-components (and then back again!)
  • No decoding phase in training. No tokens are "output" during training.
  • No KV caches are needed in training.
  • Training's forward pass is prefill-like (token-wise parallel), but doesn't store any KV cache, and does many more things than prefill (to prepare for the backprop).
  • Training's backward pass updating parameters via "gradients" has no equivalent in inference.
  • Backward pass is more expensive than the forward pass in training.
  • GEMM is the main training compute cost, mostly in the backward propagation phase.
  • The gradient optimizer (AdamW) is memory-bound.
  • GPU sharding is key for distributed multi-GPU cluster training. GPUs each train different parts of the model.
  • Accuracy is often more important than speed in LLM training, which is why many lossy optimizations are shunned.
  • Many important LLM Inference Optimization methods have limited applicability to training (e.g., speculative decoding, KV cache optimizations like Paged Attention or Radix Attention).
  • Flash Attention is still a good one for attention in training! (just don't store the KV cache).
  • A large model stays distributed across GPUs for the most part during training, only centralized into the full model at particular "consolidated checkpoints" (and at the very end).

Free AI C++ books: for more about LLM optimization, read books online or download a PDF:

Popular inference optimization articles: additional research articles on faster LLM inference:

More lists: lots of general efficiency optimization information:

LLM Training Optimizations List

Here's the training list!

    Major LLM Intelligence Improvement Methods:
  1. Training
  2. Fine-Tuning
  3. RAG & Prompt Augmentation methods
  4. Tool usage (function calling)
  5. Plugins
  6. Knowledge distillation
  7. Harness and ecosystem
  8. Next-gen models
  9. AGI

    Prompt Augmentation Methods:
  10. RAG architectures
  11. RALM
  12. TALM
  13. Small reasoning model augmentation
  14. Reasoning scaffold augmentation
  15. Context engineering
  16. Plugins
  17. Internet search plugin
  18. Knowledge graph
  19. Taxonomy/ontology graph

    Prompt Preprocessing Methods:
  20. Prompt preprocessing ("hooks")
  21. Prompt shielding
  22. Refusal modules
  23. Prompt compression
  24. Context compression
  25. Automatic prompt optimization
  26. Heuristic prompt preprocessing

    Next-Generation Models:
  27. State Space Models (SSMs)
  28. Mamba
  29. Hyena
  30. Hybrid Transformer-SSM Architectures
  31. World models
  32. Embodied AI
  33. Symbolic reasoning
  34. Large Concept Models

    Previous-Generation Classic ML Models: still going strong!
  35. CNNs
  36. Hybrid CNN-Transformers
  37. RNNs
  38. Hybrid RNN-Transformers
  39. Diffusion models
  40. Hybrid Diffusion-Transformers
  41. GAN

    Harness Improvement Methods:
  42. Harness engineering
  43. Prompting techniques
  44. System prompt

    Overall Training Optimization Categories:
  45. Training data loading and preprocessing
  46. Loss calculations
  47. Back propagation
  48. Gradient optimizers
  49. Attention module optimizations
  50. Long context training optimizations
  51. FFN optimizations
  52. Matrix multiplication optimizations (GEMM/MatMul)
  53. Network transmission optimizations (both directions)
  54. Resilience and failure mitigation

    High-Level Training Methods:
  55. Pre-Training
  56. Supervised
  57. Unsupervised
  58. RLHF
  59. Reinforcement Learning
  60. Reward modeling
  61. Post-Training Optimizations

    Training Data:
  62. Labeled training data
  63. Unlabeled training data
  64. Synthetic data
  65. Open-source training data
  66. Commercially-licensed training data
  67. Proprietary training data
  68. Overrepresentation of common domains (needs downsampling)
  69. Underrepresentation of common domains (needs upsampling)

    Model Media Types:
  70. Text models
  71. Code generation models
  72. Multimodal models
  73. Image models
  74. OCR
  75. Audio
  76. Music
  77. Speech
  78. Voice
  79. Video models
  80. Computer Vision models

    Model Overarching Goals:
  81. Reasoning vs non-reasoning
  82. Agentic vs non-acting
  83. Chatbot vs batched models

    Model Platforms:
  84. Data Center LLMs
  85. — GPU
  86. — TPU
  87. — CPU
  88. — NPU
  89. Edge AI
  90. Hybrid cloud-on-device inference
  91. On-device
  92. AI Phones
  93. AI PCs (desktops/laptops)
  94. — IoT devices
  95. New AI form factors
  96. — AI gadgets
  97. — AI glasses
  98. — AI pendants
  99. — AI rings

    Model Architecture Decisions:
  100. Single Model vs Ensemble (Multi-Model)
  101. Decoder-only vs encoder-decoder vs encoder-only
  102. Model dimensions
  103. Total parameter count
  104. Layers
  105. Small models vs large models
  106. Dense model vs MoE (sparse experts)
  107. Data size (e.g., FP32 vs INT4)
  108. Tokenizer
  109. Vocabulary (size and composition)
  110. Pre-Norm vs Post-Norm
  111. Embeddings method
  112. FFN vs GLU
  113. NAS analysis
  114. Autoregressive Decoding vs Parallel decoding

    Model Architecture Major Components:
  115. Mixture-of-Experts (MoE)
  116. Attention algorithm
  117. FFN
  118. GLU
  119. Positional Encoding algorithm
  120. Activation function
  121. Normalization algorithm
  122. Decoding algorithms
  123. Tokenization
  124. Embedding matrix
  125. Unembedding
  126. Detokenization

    Other Model Architectures:
  127. Slimmable
  128. Bulging (attention or FFN)
  129. Per-Layer Embeddings (PLE)
  130. Mixture-of-Attention (MoA)

    Reasoning Models:
  131. One-step reasoning model ("long answers")
  132. Multi-step reasoning model
  133. Reasoning Harness
  134. Reasoning System Prompts

    Training Compute Optimizations:
  135. Mixed-Precision Training
  136. — FP16
  137. — BF16
  138. Batching of training data (for efficiency & gradient stability)
  139. Per-batch gradient updates (not per-query or per token)

    Open-Source LLM Training Engines:
  140. PyTorch
  141. TensorFlow
  142. JAX/Flax (using XLA)
  143. DeepSpeed (Microsoft)
  144. Megatron‑LM (NVIDIA)
  145. Colossal‑AI
  146. Hugging Face Accelerate
  147. Determined AI
  148. Kubeflow

    Open-Source LLM Inference Engines:
  149. llama.cpp (known for CPU and Apple platform inference)
  150. vLLM (mainstream usage data center inference; known for Paged Attention)
  151. SGLang (mainstream; known for Radix Attention)
  152. LMCache (known for KV caching optimizations)

    Gradient Optimizers:
  153. SGD (Stochastic Gradient Descent): original optimizer:
  154. — Vanilla SGD (old-style, too unstable)
  155. — QSGD (Quantized SGD)
  156. — Batch SGD
  157. — Mini‑batch SGD
  158. — SGD with momentum
  159. — Nesterov Accelerated Gradient (NAG)
  160. — DeepSpeed QSGD (1‑bit Adam, 1‑bit LAMB)
  161. Adam (adaptive SGD with momentum; name is wordplay based on "Adaptive Moment Estimation"; legacy production optimizer superceded by AdamW)
  162. AdamW (Adam + Weight decay; widely used for frontier training; also for fine-tuning; SGD with momentum and modifications; Adam + decoupled weight decay; warmup cosine decay)
  163. AdamW variants (mostly experimental, not yet widely used instead of AdamW)
  164. — RAdamW (Rectified AdamW)
  165. — AdaBeliefW
  166. — AdamP/AdamPW
  167. — AdaFactorW
  168. — LionW
  169. — K‑FAC‑AdamW hybrids
  170. Other production usage optimizers:
  171. — Adafactor (from Google, used for TPU, memory-efficiency)
  172. — Lion (from Google; looks only at the sign bit of the gradient; simpler than AdamW, used for fine-tuning, esp. LoRA/QLoRA fine-tuning)
  173. — Sophia/Sophia-G (second-order optimizer; experimental/emerging into production for fine-tuning)
  174. — Muon (Momentum Orthogonalized by Polar decomposition) (emerging 2026 optimizer)
  175. Other legacy optimizers: formerly used in production:
  176. — AdaGrad (legacy optimizers; still somewhat used)
  177. — RMSProp (legacy optimizer, superceded by AdamW)
  178. — AdaDelta (modification of AdaGrad; legacy production usage)
  179. Other experimental gradient optimizers: mostly research or experimental usage:
  180. — Shampoo / Block‑Shampoo
  181. — LARS (Layerwise Adaptive Rate Scaling)
  182. — LAMB (Layerwise Adaptive Moments)
  183. — Newton’s Method (Hessian)
  184. — AdaNorm/AdaNormW
  185. — L‑BFGS (quasi‑Newton)
  186. — K‑FAC (Kronecker‑factored curvature)
  187. — AdaHessian
  188. — RAdam (Rectified Adam)
  189. — Lookahead
  190. — SAM (Sharpness‑Aware Minimization)

    Gradient Optimizers for RLHF:
  191. PPO (Proximal Policy Optimization)
  192. TRPO (Trust Region Policy Optimization)
  193. A2C
  194. A3C

    SOTA Training Setup:
  195. AdamW gradient optimizer
  196. Low base learning rate
  197. Momentum: β₁ ≈ 0.9, β₂ between 0.95–0.999
  198. Epsilon: ε ≈ 1e‑8,
  199. Weight decay ≈ 0.01 (or 0.02-0.05)
  200. Warmup phase: 1–3% of total steps
  201. Decay algorithm: cosine or linear

    Random Noise Injection: to reduce overfitting and increase generalization; aimed at accuracy, not for efficiency improvement.
  202. Dropout (randomly zero a percentage of activations)
  203. Structured dropout (apply Dropout to particular structures)
  204. Attention Dropout (applies before Softmax)
  205. DropHead (attention head dropout)
  206. LayerDrop (randomly skip entire layers)
  207. Stochastic Depth (token-wise variant of LayerDrop)
  208. DropPath (in Vision Transformers)
  209. Token Dropout (randomly mask or prune input tokens in training)
  210. Randomized Positional Dropout (RoPE dropout, ALiBi dropout)
  211. Drop Embeddings
  212. Many more Dropout variants: see this 2022 paper: https://arxiv.org/pdf/2204.02027

    Network Optimizations for Training:
  213. Training data outward transmission
  214. Gradients and updates (returned)
  215. Gradient compression methods
  216. Burst management
  217. Network bandwidth management

    LLM Training Major Settings:
  218. Learning rate settings
  219. Learning Rate warmup (LR warmup)

    LLM Training Problems:
  220. Model training fails overall
  221. Model evaluation failure (bad model trained)
  222. — Misalignment
  223. — Emergent misalignment
  224. — Catastrophic forgetting
  225. — Overfitting
  226. — Generalization failures
  227. — Misgeneralization
  228. — Degenerate solution learning
  229. — Reasoning failures
  230. — Brittle reasoning (narrow learning)
  231. — Reward hacking (learned shortcuts)
  232. — Spurious correlations learned
  233. — Arithmetic failures
  234. Data problems
  235. — Data quality
  236. — Noisy data
  237. — Skewed data sets
  238. — Mixed data sets (e.g. text vs code)
  239. Optimizer instability
  240. — Vanishing gradient (loss plateaus)
  241. — Exploding gradients (loss spikes)
  242. — Floating-point overflow (NaN/Inf)
  243. — Floating-point underflow (zero rounding)
  244. — Divergence
  245. — Loss spikes
  246. — Loss oscillations
  247. — Learning rate incorrect
  248. — LayerNorm value spikes
  249. — Batch size too small
  250. — Optimizer state failures
  251. — Optimizer state drift
  252. — Distributed gradient corruption
  253. — Non-deterministic training
  254. — Long-context gradient problems
  255. Warmup failures
  256. — LR warmup issues
  257. — Checkpoint restore errors
  258. Hardware faults
  259. — Transient GPU faults
  260. — GPU burnouts
  261. Network faults
  262. — Network communication failure
  263. — Gradient communication faults
  264. — Gradient synchronization failures
  265. — Network latency spikes
  266. — Network bandwidth issues

    Numerical stability mechanisms:
  267. LR warmup (the learning rate is low to start and increased gradually)
  268. LR warmdown or "decay phase" (learning rate reduced near the end of training)
  269. AdamW bias correction
  270. RMS-scaled gradients (avoid floating-point underflow)
  271. Gradient clipping (stopping gradients above a threshold; global norm clipping of loss spikes to avoid exploding gradients)
  272. Norm tracking
  273. Cosine decay
  274. Activation scaling (uP, DeepNorm, RMSNorm)

    Distributed gradient corruption:
  275. all‑reduce desynchronization
  276. Silent bit flips (SDC, transient errors)
  277. Optimizer state inconsistent (across workers)
  278. AdamW moment vectors inconsistent
  279. Gradient compression errors
  280. Over-quantization in gradient compression
  281. Over-sparsification in gradient compression
  282. Mixed-precision desynchronization (desync)
  283. Checkpoint corruption

    Resilience Optimizations for Training: avoiding training failures is a big part of efficiency, because restarts are costly.
  284. Checkpointing optimizations
  285. In-memory checkpointing
  286. Asynchronous checkpointing
  287. Silent Data Corruption (SDC) mitigation
  288. GPU failure mitigation
  289. GPU burnout mitigation
  290. Stragglers (one slow GPU or slow network connection forces everyone else to wait)
  291. Hangs (if one GPU fails)
  292. NaN/Inf detection ("std::isnan" CPU/GPU; use "x!=x" trick; use CUDA __float_as_uint intrinsic)

    Pruning during Training: can be used for pre-training; rarely for fine-tuning.
  293. Unstructured pruning (overview)
  294. Magnitude pruning
  295. — First-order pruning
  296. Movement pruning
  297. — Second-order pruning
  298. — LTH (Lottery Ticket Hypothesis) (sparse unstructured pruning)
  299. — SNIP (Single‑Shot Network Pruning) (unstructured sparsity at initialization)
  300. — GraSP (Gradient Signal Preservation) (unstructured, initialization-based)
  301. Dynamic Sparse Training (DST)
  302. — Unstructured DST
  303. — RigL (Rigged Lottery) (fixed sparsity budget)
  304. — SET (Sparse Evolutionary Training) (mostly research usage)
  305. — NOTE: Unstructured pruning does not reduce FLOPs (only structured pruning does)
  306. Structured pruning (overview)
  307. Structured DST
  308. — 2:4 sparsity (prunes 50%)
  309. — 4:8 sparsity (prunes 50%)
  310. — Block sparsity (block-sparse DST)
  311. — Block-sparse RigL
  312. — Expert-level DST for MoE training (used by frontier MoE model training)
  313. Pruning approaches:
  314. — Phased sparsity increases pruning during warmup
  315. — Sparsity from initialization (during whole warmup)

    Quantization during Training:
  316. Quantization-Aware Training (QAT)
  317. Post-Training Quantization (PTQ)

    Attention optimization subtypes:
  318. Attention optimizations (overview)
  319. Multi-Head Attention (MHA)
  320. Group Query Attention (GQA)
  321. Multi-Query Attention (MQA)
  322. Sparse attention
  323. Local attention
  324. Memory-efficient attention algorithms
  325. Flash Attention
  326. Paged Attention
  327. Linear attention
  328. Cross attention
  329. Tree attention
  330. Sliding window attention
  331. Approximate attention heads
  332. Attention alternatives/replacements
  333. Fused MHA
  334. Low-rank matrix attention
  335. Medusa attention
  336. Block attention
  337. Cross attention
  338. Fused head attention
  339. Hybrid local-global attention
  340. FFT attention
  341. Additive attention
  342. Multiplicative attention
  343. Graph attention
  344. Attention sink
  345. Attention steering
  346. Bilinear attention
  347. Attention-free methods
  348. Star attention
  349. Ring attention
  350. — Flex attention
  351. — Razor attention
  352. — Contiguous QKV tensor
  353. — Relative Attention Bias (RAB)
  354. Lightning attention
  355. Multihead Latent Attention (MLA (DeepSeek)
  356. — FFT attention
  357. — Round attention
  358. Delta attention
  359. Gated attention
  360. KIVI attention
  361. K=V (KV compute sharing)
  362. Bulging attention (per-layer attention module size increases)

    Attention compute optimizations:
  363. Chunked attention
  364. QKV computation optimizations
  365. Mixture-of-Heads (MOH) Attention (MoE+MHA)
  366. Mixture-of-Attention (MoA) (MoE attention)

    Long context optimizations (attention):
  367. Long context models
  368. Length generalization
  369. Quadratic attention complexity
  370. Long RAG

    RAG Architecture Optimizations:
  371. RAG architectures (overview)
  372. RAG cache
  373. RAG optimizations
  374. — RAG retriever datastore indexing
  375. Advanced RAG
  376. — Speculative RAG
  377. Reranker in RAG
  378. — Chunk-specific global KV caching
  379. — Chunk-specific prefix KV caching
  380. RAG Knowledge Graph
  381. RAG Ontologies/Taxonomies
  382. RAG fusion
  383. Mini-RAG (single-document RAG)

    Non-Multiplication AI Models:
  384. Zero-Multiplication Models (overview)
  385. Binary quantization
  386. Ternary quantization
  387. 2-bit quantization (INT2)
  388. Adder networks
  389. Bitshift-add networks
  390. Bitshift power-of-2 quantization (logarithmic quantization)
  391. Double bitshift quantization
  392. Add-as-integer networks
  393. Logarithmic Models
  394. Bitwise neural networks
  395. Diff-squared networks
  396. Log-sum-exp (LSE) networks
  397. Max-Plus networks
  398. Min-Max-Plus networks
  399. Morphological networks
  400. Trigonometric approximate inference
  401. Weightless Neural Networks (WNNs)
  402. XNOR networks
  403. Hadamard elementwise matrix multiplication models
  404. Other addition-related zero-multiplication networks
  405. Table lookups replace multiplication
  406. Other multiplication-free neural networks

    Advanced Number System optimizations:
  407. Advanced Number Systems (overview)
  408. Posit number system (PNS)
  409. Residue number system (RNS)
  410. Dyadic numbers
  411. Double-base number system (DBNS)
  412. Dynamic number systems
  413. Hybrid number systems
  414. Tropical algebra (max-plus)
  415. MiniMax algebra
  416. Multi-dimensional logarithmic number system (MDLNS)
  417. Multiple-Base Number System (MBNS)
  418. — Semi-Logarithmic Number System (SLNS)
  419. — Lattice algebra

    Logarithmic Number System optimizations:
  420. Logarithmic number system (LNS) (overview)
  421. End-to-end LNS logarithmic model
  422. LNS addition and subtraction
  423. LNS in AI models
  424. LNS Hardware Acceleration
  425. LNS mathematical and algorithmic theory
  426. LNS algebra
  427. LNS extensions

    Parameter Efficient Fine-Tuning (PEFT) subtypes:
  428. PEFT (overview)
  429. LoRA
  430. Multi-LoRA inference
  431. QLoRa (Quantized Low-Rank Adapters)
  432. LoRA inference optimizations (load/unload)
  433. Prompt Tuning (Extended Vocabulary PEFT)
  434. Prefix Tuning

    Ensemble multi-LLM subtypes:
  435. Ensemble inference (overview of multi-model AI engines)
  436. Model selection algorithms
  437. Big-little architectures
  438. Cascades
  439. Collaborative inference
  440. Consensus decoding
  441. — Swarm ensemble architectures
  442. — Committee ensemble architectures
  443. — Ensemble averaging
  444. Easy-hard queries
  445. Submodels (Many-Models-in-One)
  446. Distributed Inference

    Tool Integration Optimizations: LLMs using tools has gone mainstream, and there is also newer research on speeding it up:
  447. Tool optimizations
  448. — Tool execution pipelining (overlap with prefill or decode)
  449. — Speculative tool execution
  450. — Tool token reduction
  451. — Concise tool output
  452. — Disaggregated tool execution
  453. — Multi-tool parallel execution

    Knowledge distillation subtypes:
  454. Knowledge Distillation (overview)
  455. Ensemble Distillation
  456. Unnatural instructions (data sets)
  457. Dataset Distillation
  458. Black Box Distillation
  459. White Box Distillation

    Overall summaries of AI optimizations:
  460. Deslugging AI engines
  461. Accuracy-degrading optimizations
  462. Accuracy-retaining optimizations
  463. Uncommon inference optimizations

Not Enough?

More inference optimization resources:

Free AI and C++ Books

Generative AI programming books:

  1. The Sweetest Lesson: Your Brain Versus AI, November 2025: full text online, free PDF available
  2. RAG Optimization: Accurate and Efficient LLM Applications, June 2025: full text online, free PDF available
  3. Generative AI Applications: Planning, Design and Implementation, November 2024: full text online, free PDF available
  4. Generative AI in C++ (Spuler, March 2024): full text online, free PDF available, table of contents, bonus materials, reference lists, source code

CUDA C++ GPU Programming Books:

  1. CUDA C++ Optimization: Coding Faster GPU Kernels, July 2024: full text online, bonus materials, free PDF available
  2. CUDA C++ Debugging: Safer GPU Kernel Programming, July 2024: full text online, free PDF available

Modern C++ Programming Books

  1. C++ AVX Optimization: CPU SIMD Vectorization, 2025: full text online, free PDF available
  2. C++ Ultra-Low Latency: Multithreading and Low-Level Optimizations, 2025: full text online, free PDF available
  3. Advanced C++ Memory Techniques: Efficiency and Safety, 2025: full text online, free PDF available
  4. Efficient C++ Multithreading: Modern Concurrency Optimization, 2025: free PDF available
  5. Efficient Modern C++ Data Structures: Container and Algorithm Optimizations, 2025: free PDF available
  6. C++ Low Latency: Multithreading and Hotpath Optimizations, 2025: free PDF available
  7. Safe C++: Fixing Memory Safety Issues, Oct 2024: full text online, free PDF available

More AI Research Topics

Read more about: