Subscribe
Topic

Optimization

Techniques that make AI models faster to run and better to train, explained in depth. Recent posts cover Flash-Decoding, speculative decoding, FlashAttention, preference optimization with SimPO and ORPO, and multi-task gradient methods like PCGrad.

Articles

1-20
  1. Flash-Decoding: Mathematical Foundations, Split-KV Parallelism, Online Softmax Reduction, and Serving Latency Optimization

    Large language model inference consists of two distinct computational regimes: the compute-bound prefill phase and the memory-bandwidth-bound autoregressive decoding phase. While the prefill phase processes prompt tokens in parallel across dense matrix multiplication units, generation proceeds token by token. At each generation step, a single newly generated query vector must attend to the entire historical Key-Value (KV) cache stored in High-Bandwidth Memory (HBM). As context windows scale fro

    AI
    8 min read
  2. Anthropic Researchers Use Claude to Optimize Quantum Computing Circuits by Up to 17x

    Anthropic researchers, in collaboration with physicists from Harvard University and QuEra Computing, have demonstrated that large language models operating in automated feedback loops can optimize quantum computing circuits beyond human-designed baselines. Led by STEM Fellow Andi Gu and mentor Alek Kemeny at Anthropic, alongside Susanne Yelin and Mikhail Lukin at Harvard and QuEra, the team tasked Claude Mythos 5 with designing quantum circuits across eight computational primitives spanning che

    Anthropic
    3 min read
  3. Reference-Free Preference Optimization: Mathematical Foundations of SimPO and ORPO, Length-Normalized Implicit Rewards, Target Margins, and Monolithic Alignment

    Reference-Free Preference Optimization: Mathematical Foundations of SimPO and ORPO, Length-Normalized Implicit Rewards, Target Margins, and Monolithic Alignment Post-training alignment has shifted from complex multi-stage reinforcement learning pipelines toward direct preference optimization paradigms. While Proximal Policy Optimization (PPO) requires maintaining four concurrent models in memory (policy, value, reference, and reward networks), Direct Preference Optimization (DPO) reduced this f

    AI
    13 min read
  4. FlashAttention: Mathematical Foundations, Online Softmax Tiling, IO-Awareness, and Exact Attention Scaling

    Standard multi-head self-attention in the Transformer architecture exhibits quadratic time and memory complexity with respect to sequence length $N$. While the $O(N^2)$ computational complexity is widely cited, the primary performance bottleneck in production hardware is not arithmetic throughput, but memory access overhead. On modern GPU architectures such as NVIDIA A100 and H100, tensor processing cores execute matrix multiplications at teraflop and petaflop scales, but memory bandwidth betwee

    AI
    13 min read
  5. Transformers as Support Vector Machines: Mathematical Foundations of Implicit Bias, Margin Maximization, and Hard-Attention Convergence

    Understanding why overparameterized deep neural networks generalize well despite possessing sufficient capacity to memorize training data remains a fundamental question in theoretical machine learning. In classical linear models trained on separable data under exponential-tailed losses (such as logistic or cross-entropy loss), gradient descent exhibits an implicit bias: parameter iterates diverge in norm while their directions asymptotically converge to the maximum-margin hyperplane, known as th

    AI
    9 min read
  6. Projecting Conflicting Gradients (PCGrad): Mathematical Foundations, Orthogonal Projections, and Multi-Task Optimization in Deep Learning

    Projecting Conflicting Gradients (PCGrad): Mathematical Foundations, Orthogonal Projections, and Multi-Task Optimization in Deep Learning In modern machine learning systems, models rarely optimize for a single objective. Foundation models are trained simultaneously on diverse data distributions spanning natural language, source code, mathematical reasoning, and multimodal inputs. Similarly, post-training alignment pipelines must simultaneously optimize for helpfulness, factual accuracy, harmles

    AI
    11 min read
  7. The Muon Optimizer: Mathematical Foundations, Newton-Schulz Polar Iterations, and Spectral Steepest Descent in LLM Pre-Training

    Transformer pre-training has long relied on AdamW as the default first-order optimizer. While AdamW provides coordinate-wise scale invariance through running estimates of first and second gradient moments, it treats every weight parameter as an isolated scalar. For modern neural networks composed primarily of two-dimensional linear projections, attention transformations, and feed-forward weight matrices, this coordinate-wise factorization neglects the structural transformation properties of matr

    AI
    6 min read
  8. Decoupled Weight Decay Regularization (AdamW): Mathematical Foundations, L2 Regularization Failure in Adaptive Gradient Methods, and Hyperparameter Dynamics

    Decoupled weight decay regularization, formalized by Ilya Loshchilov and Frank Hutter in 2017 and published at ICLR 2019, resolved a fundamental flaw in how adaptive gradient algorithms like Adam implemented weight regularization. Prior to AdamW, deep learning frameworks implemented weight decay as L2 regularization by adding the gradient of the squared L2 norm directly to the loss gradient. While mathematically identical for standard stochastic gradient descent (SGD), this formulation breaks do

    AI
    5 min read
  9. Curriculum Learning in Large Language Models: How Difficulty Pacing, Competence Progression, and Task Scheduling Shape Training Dynamics

    In standard large language model pre-training and fine-tuning pipelines, training batches are almost universally sampled uniformly and independently at random from a static corpus: $$\mathcal{D} = \{z_i = (x_i, y_i)\}_{i=1}^N$$ While this independent and identically distributed (i.i.d.) sampling paradigm aligns with empirical risk minimization (ERM), it ignores the non-convex geometry of deep transformer loss surfaces. Early in training, when network parameters are randomly initialized or unal

    Explainers
    12 min read
  10. Trust Region Policy Optimization: Mathematical Foundations, Monotonic Improvement Guarantees, and Conjugate Gradient Updates

    Trust Region Policy Optimization: Mathematical Foundations, Monotonic Improvement Guarantees, and Conjugate Gradient Updates In policy gradient reinforcement learning, optimization dynamics differ fundamentally from standard supervised learning. In supervised regression or classification, the underlying data distribution $P(x, y)$ remains stationary throughout training; a sub-optimal parameter update merely yields high loss on the current batch without corrupting future sample collection. In re

    AI
    9 min read
  11. The Fisher Information Matrix and Natural Gradient Descent: How Information Geometry, Riemannian Manifolds, and Curvature Invariance Reshape Neural Optimization

    The Fisher Information Matrix and Natural Gradient Descent: How Information Geometry, Riemannian Manifolds, and Curvature Invariance Reshape Neural Optimization Standard gradient descent operates under an implicit, often unexamined assumption: that parameter space is Euclidean. When an optimizer updates network weights via $\theta_{t+1} = \theta_t - \eta \nabla_\theta \mathcal{L}(\theta)$, it calculates the direction of steepest descent within an arbitrary coordinate system. If the network is r

    AI
    10 min read
  12. Temperature Scaling and Model Calibration in Deep Neural Networks: Mathematical Foundations, Expected Calibration Error, and Post-Hoc Logit Optimization

    Modern deep neural networks achieve high classification accuracy and generative benchmark performance across vision, language, and decision-making tasks. However, optimization for raw accuracy does not ensure that predicted softmax probabilities correspond to true posterior probabilities. A model that assigns a 0.90 probability to an output should be correct exactly 90% of the time. When empirical accuracy systematically diverges from predicted confidence, the model is miscalibrated. Research b

    Deep Learning
    11 min read
  13. Loss Landscapes in Deep Neural Networks: How Filter Normalization, Hessian Curvature, and Basin Flatness Explain Generalization

    The parameter space of modern deep learning models spans millions to hundreds of billions of dimensions. In this high-dimensional space, the empirical risk objective forms a complex geometric surface known as the loss landscape. Despite the extreme non-convexity of deep neural networks, standard first-order optimization algorithms such as stochastic gradient descent (SGD) and Adam regularly converge to parameter configurations that achieve both low training error and robust test set generalizati

    AI
    9 min read
  14. The Score Function Estimator: Mathematical Foundations of REINFORCE, Log-Derivative Tricks, and Baseline Variance Reduction

    In modern artificial intelligence, standard backpropagation relies on continuous differentiability: every operation between model parameters and the final loss must provide well-behaved analytical Jacobian matrices. However, many of the most critical optimization challenges in machine learning break this continuity. Autoregressive token generation in large language models, discrete tool invocation, programmatic compiler execution, and black-box reward environments are fundamentally non-different

    Reinforcement Learning
    10 min read
  15. Stochastic Weight Averaging: How Geometric Ensembling Finds Flatter Optima and Improves Generalization

    Stochastic Weight Averaging (SWA): How Geometric Ensembling Finds Flatter Optima and Improves Generalization During the optimization of deep neural networks, standard Stochastic Gradient Descent (SGD) and adaptive optimizers often struggle to find solutions that generalize robustly to unseen data. While learning rate decay allows optimizers to settle into local minima on the empirical training loss surface, empirical and theoretical analyses reveal that standard gradient descent tends to halt n

    AI
    8 min read
  16. Data Pruning and Core-Set Selection in Deep Learning: How EL2N, GraNd, and Memorization Dynamics Break Power-Law Scaling

    Modern foundation models are trained on tens of trillions of tokens, requiring millions of GPU hours. Yet empirical analyses consistently reveal that massive portions of web-crawled corpora and large-scale vision datasets are either highly redundant, uninformative, or dominated by unlearnable noise. Standard empirical scaling laws (such as those formulated by Kaplan et al. and Chinchilla) model generalization error as a power-law function of total training samples ($L(N) \propto N^{-\alpha}$). H

    AI
    7 min read
  17. Kronecker-Factored Approximate Curvature (K-FAC) and Shampoo: How Kronecker Preconditioning Scales Second-Order Optimization

    Kronecker-Factored Approximate Curvature (K-FAC) and Shampoo: How Kronecker Preconditioning Scales Second-Order Optimization Standard deep neural network pre-training relies almost exclusively on first-order stochastic gradient methods. Optimizers such as AdamW maintain running averages of individual parameter gradients and uncentered second moments, applying a coordinate-wise diagonal preconditioner. While computationally efficient, diagonal scaling ignores off-diagonal cross-layer and intra-l

    AI
    9 min read
  18. The Edge of Stability: How Progressive Sharpening and Hessian Dynamics Govern Deep Learning Optimization

    In classical convex optimization, the behavior of gradient descent is dictated by the Lipschitz smoothness constant of the objective function. If a function $f(\theta)$ has an $L$-smooth gradient—meaning the largest eigenvalue of its Hessian matrix is bounded by $\lambda_{\max}(\nabla^2 f(\theta)) \le L$—gradient descent with learning rate $\eta$ is guaranteed to monotonically reduce the loss if and only if $\eta < 2/L$. When the step size exceeds this threshold ($\eta > 2/\lambda_{\max}$), stan

    AI
    7 min read
  19. Gradient Low-Rank Projection (GaLore): How Dynamic Subspaces Enable Full-Parameter LLM Pre-Training with Low-Rank Memory

    Pre-training foundation large language models has historically required massive compute clusters, largely due to the memory footprint of optimizer states rather than the model weights themselves. While parameter-efficient fine-tuning methods such as Low-Rank Adaptation (LoRA) freeze weights and introduce small adapter matrices, they fail when applied to pre-training from scratch because they restrict parameter updates to a fixed, static low-rank manifold. Gradient Low-Rank Projection (GaLore),

    AI
    8 min read
  20. Identity Preference Optimization (IPO): How Exact Loss Inversion Prevents Overfitting in Direct Alignment

    The post-training alignment of large language models underwent a structural shift with the introduction of Direct Preference Optimization (Rafailov et al., 2023). By reparameterizing the closed-form optimal policy under a Kullback-Leibler (KL) constrained Reinforcement Learning from Human Feedback (RLHF) objective, DPO eliminated the need to fit an explicit reward model or maintain complex actor-critic rollout loops. However, standard DPO introduces a distinct mathematical pathology: under dete

    AI
    7 min read