The KL Divergence Is Never Negative, Except in PyTorch
Abstract: A Kullback--Leibler (KL) divergence is never negative, yet PyTorch users have reported negative values for years, and the standard advice is to clamp them at zero. The sign is only the visible part of a silent failure. Many machine-learning applications compare nearby distributions, where conventional KL formulas lose accuracy. On 8.5 million inputs with certified references across 18 closed-form KL families and F.kl_div, we find widespread errors in values and gradients on CPU and GPU. Among scalar families in ordinary parameter ranges, over 85% of FP32 values have at least 1% relative error near KL 10-7 (FP16: 10-3), and about 30% become negative at smaller divergences. More precision is not the cure: evaluated one precision higher, the same formulas still leave 7--51% of FP32 values significantly wrong for 22 of 23 configurations. Stable closed-form decompositions, compensated arithmetic, and analytic gradients remove over 97% of significant errors in the working format. Strict repairs eliminate significant errors on 7.2 million scored closed-form samples and correctly round all 567 million scored F.kl_div components. The errors affect parameter fitting, Bayesian decisions, identical-start distillation (up to 97% top-1 disagreement), KL-based layer rankings in a quantized LLM, and 19--59% of GPT-2 circuit edge scores. With the repaired code they all but vanish. Code and data: https://github.com/xi-xiaoran/stablekl
Paper Prompts
Sign up for free to create and run prompts on this paper.
Explain it Like I'm 14
1. What is this paper about?
This paper investigates a surprising problem in PyTorch, a popular tool for building artificial intelligence systems.
The problem involves something called KL divergence. KL divergence measures how different one probability distribution is from another. For example, it could measure how different a student AI’s answers are from a teacher AI’s answers.
Mathematically, KL divergence can never be negative. It should be:
- Zero when two distributions are exactly the same.
- Positive when they are different.
However, PyTorch sometimes reports negative values, zero when the distributions are different, or other inaccurate answers.
The paper argues that negative values are only the most obvious symptom. Many incorrect results still look normal because they are positive and finite.
2. What questions did the researchers ask?
The researchers wanted to find out:
- How often does PyTorch calculate KL divergence incorrectly?
- Does the problem happen only for certain kinds of probability distributions?
- Does it happen on both computers and graphics cards?
- Can using a higher-precision number format solve the problem?
- Can the researchers design better formulas that are both accurate and stable?
- Do these errors actually affect machine-learning tasks?
The last question is especially important. A tiny numerical error might seem harmless, but in an AI system it can affect training, rankings, or important choices.
3. How did the researchers investigate the problem?
Testing many distributions
The researchers tested PyTorch’s KL-divergence calculations for 18 different families of probability distributions, including:
- Normal distributions
- Exponential distributions
- Bernoulli distributions
- Categorical distributions
- Beta and Gamma distributions
- Multivariate normal distributions
They created more than 7 million pairs of distributions for one PyTorch interface. They also tested nearly 1 million groups of inputs for another interface, called F.kl_div.
Some pairs were very different, while others were almost identical.
Creating a trustworthy answer
To know whether PyTorch was wrong, the researchers needed a highly accurate answer for comparison. They used interval arithmetic, a technique that calculates a safe range containing the true answer.
An everyday analogy is measuring the length of a pencil with a very precise ruler and saying, “The true length must be between 14.9999 and 15.0001 centimeters.” This gave the researchers a reliable reference.
Testing different number formats
Computers store numbers with limited precision. Common formats include:
- FP16, which uses fewer bits and is faster but less accurate.
- FP32, commonly used in machine learning.
- FP64, which stores numbers more accurately but requires more memory and computation.
The researchers tested these formats on both CPUs and GPUs.
Testing improved formulas
The researchers did not only test the old PyTorch formulas. They designed improved versions using several ideas:
- Rewriting formulas to avoid subtracting nearly equal numbers.
- Breaking the answer into parts that cannot be negative.
- Using more careful addition and multiplication.
- Computing gradients directly instead of letting automatic differentiation work on unstable formulas.
- Computing KL divergence directly from model logits, which are the raw scores produced before probabilities are calculated.
4. Why do the errors happen?
The main problem is called cancellation.
Imagine calculating:
1 |
1.00000001 - 1.00000000 |
The answer is very small. But if the computer rounds both numbers before subtracting them, it might store them as the same number and produce zero.
KL divergence often has the same problem. When two distributions are very similar, the true KL divergence is extremely small. But the formula may calculate it by subtracting or combining much larger numbers.
For example, the real answer might be:
1 |
0.000000005 |
But the computer may round the calculation to:
1 |
0 |
It might even produce a small negative number, despite the mathematical answer being positive.
This is similar to trying to hear a quiet whisper while standing next to a loud machine: the small signal gets hidden by the noise.
5. What did the researchers find?
PyTorch often gives wrong answers for very small KL values
When the true KL divergence was around in FP32, about 86% of the tested values were wrong by at least 1%.
For even smaller values, roughly 30% became negative.
The problem appeared across all the tested distribution families. It was not limited to one special type of probability distribution.
The problem also appeared on both CPUs and GPUs.
More precision alone is not enough
The researchers tried calculating the existing formulas with one higher precision level. This helped somewhat, but it did not solve the problem.
For many settings, between 7% and 51% of FP32 results were still significantly wrong.
The reason is that the original input numbers may already have been rounded. Using more precision afterward cannot recover information that was lost earlier.
The gradients can also be wrong
A gradient tells a machine-learning system which direction to change its parameters to improve.
If the KL value is inaccurate, its gradient may also be inaccurate. In some extremely small cases, the gradient pointed in almost the opposite direction from the correct one.
This can cause an AI system to learn incorrectly.
The improved formulas worked much better
The researchers’ rewritten formulas removed more than 97% of significant errors in ordinary working precision.
Their strict version had:
- No significant errors in more than 7.2 million tested closed-form examples.
- Correctly rounded results for all tested components of
F.kl_div. - No negative KL values.
- Exact zero results when the two distributions were truly identical.
The improved methods were slower because they performed more careful calculations. On some GPU tests, they took about 2.4 to 5.9 times longer than the original code.
The errors changed real machine-learning results
The paper tested several applications.
| Application | What went wrong with the original calculations |
|---|---|
| Parameter fitting | The system sometimes failed to learn a target distribution it was given exactly |
| Bayesian decision-making | The system selected the wrong experiment or probability group in many rounds |
| Knowledge distillation | A student model changed even when it started as an exact copy of its teacher |
| Quantized LLMs | Incorrect KL values caused bad rankings of model layers |
| GPT-2 circuit analysis | Many small importance scores were wrong or negative |
One especially striking result came from knowledge distillation. A student model began as an exact copy of its teacher, so it should not have changed when trained only to match the teacher. With the original PyTorch calculations, it did change. In one large-vocabulary FP16 experiment, its final top prediction disagreed with the teacher on 97.4% of examples.
With the repaired calculation, the student did not move at all, as expected.
6. Why are these findings important?
KL divergence is used in many parts of modern AI, including:
- Training generative models
- Comparing a student model with a teacher model
- Reinforcement learning
- Bayesian statistics
- Studying how much a model changes after compression or quantization
- Analyzing which parts of a neural network are important
If KL divergence is wrong, an AI system may:
- Stop learning too early.
- Change when it should stay the same.
- Choose the wrong option.
- Rank model components incorrectly.
- Report misleading scientific results.
Simply forcing negative answers to zero, called clamping, does not really solve the problem. It hides the visible symptom but leaves other inaccurate positive answers and incorrect gradients unchanged.
7. What should developers do?
The paper recommends several practical improvements:
- Do not assume that a negative KL value is the only problem. Positive values may also be inaccurate.
- Avoid calculating KL divergence from already-rounded probabilities when possible.
- Calculate it directly from logits or original distribution parameters.
- Use formulas designed to remain accurate when distributions are very close.
- Use higher precision when exact rounding is especially important.
- Test numerical software against highly accurate reference calculations.
Conclusion
The paper shows that KL divergence is mathematically safe, but computer programs can calculate it badly because computers use rounded numbers.
The problem is most serious when two distributions are nearly identical—the exact situation found in many AI applications. The old PyTorch formulas can return inaccurate, zero, or negative answers, and these errors can affect training and scientific decisions.
The researchers developed more careful formulas that greatly reduce or eliminate the errors. Their work suggests that reliable numerical code is not just a minor programming detail. It is an important part of making AI systems behave correctly and producing trustworthy research results.
Practical Applications
Immediate Applications
The paper’s central practical recommendation is to replace cancellation-prone KL implementations with stable decompositions, compensated arithmetic, analytic gradients, or a logits-based computation path. These applications can be implemented now, although production deployment should include validation against high-precision references and performance testing.
- Numerically stable PyTorch KL operators — software infrastructure and ML tooling
- Replace calls to
torch.distributions.kl_divergenceandtorch.nn.functional.kl_divwith the paper’s repaired implementations or equivalent stable formulas. - Package the methods as a drop-in library, for example:
stablekl.distributions.kl_divergencestablekl.functional.kl_div- a fused categorical loss accepting teacher and student logits directly.
- This would prevent negative, zero-for-distinct, non-finite, or materially inaccurate KL values in FP16, BF16, and FP32 workflows.
- Dependencies: The implementation must cover the relevant distribution families, preserve PyTorch autograd semantics, support CPU and GPU kernels, and be benchmarked because the reference repairs cost approximately
2.4–5.9×more than standard calls for several families.
- Replace calls to
- A numerical audit for existing machine-learning pipelines — industry and academia
- Search codebases for KL-dependent components, including VAEs, Bayesian neural networks, policy optimization, distillation, model compression, circuit analysis, and probabilistic programming.
- Add tests covering:
- identical distributions,
- distributions differing by one or a few ULPs,
- very small positive KL values,
- FP16/BF16 and FP32 execution,
- forward and backward gradients,
- CPU/GPU consistency.
- Treat negative KL as a diagnostic failure rather than simply applying
torch.clamp(kl, min=0). - Dependencies: Teams need access to original logits or distribution parameters and must distinguish operator error from errors already introduced when probabilities or log-probabilities were rounded.
- Stable knowledge distillation — education technology, foundation models, and model serving
- Compute teacher–student divergence directly from teacher and student logits rather than from separately rounded softmax probabilities or log-probabilities.
- Use the logits path in:
- language-model distillation,
- speech-recognition distillation,
- vision-model compression,
- student–teacher anomaly detection,
- deployment of smaller models on edge devices.
- This can eliminate spurious parameter updates when the student is initialized as a copy of the teacher. The paper reports up to
97%top-1 disagreement under some unstable FP16 settings, compared with no observed drift using the repaired path. - Dependencies: Teacher and student logits must be available, and the fused implementation must handle masking, temperature scaling, large vocabularies, distributed training, and mixed precision.
- Reliable KL-based model quantization and mixed-precision selection — hardware and AI deployment
- Use the logits-based KL to rank the sensitivity of layers to quantization and to select which layers should remain in FP16 or FP32.
- Integrate the computation into workflows for RTN, GPTQ, AWQ, pruning, and mixed-precision deployment.
- The result can prevent incorrect layer rankings caused by negative or tied KL values and avoid selecting a mixed-precision configuration that increases the true divergence.
- Dependencies: Quantization evaluation must compare the same stored logits or model outputs, and the ranking should be validated on held-out inputs rather than assumed to generalize from a single calibration set.
- More reliable reinforcement-learning and policy-optimization diagnostics — robotics and autonomous systems
- Replace unstable KL calculations in PPO-style trust-region constraints, policy-monitoring dashboards, policy rollback systems, and RL fine-tuning pipelines.
- Compute policy divergence from policy logits, especially when consecutive policies are close and low precision is used.
- This can prevent inaccurate trust-region penalties, incorrect early stopping, or acceptance of policy updates that actually exceed a divergence threshold.
- Dependencies: The repair must be integrated consistently into both the forward loss and gradient computation; action masking, variable-length trajectories, distributed reductions, and policy parameterization must be handled correctly.
- Improved Bayesian experimental design and adaptive sampling — healthcare, science, and finance
- In sequential Bayesian design, use stable Beta, Bernoulli, Dirichlet, or categorical KL implementations when selecting the next experiment, patient subgroup, financial scenario, or sensor measurement.
- An immediate workflow is:
- 1. compute the expected information gain for each candidate action;
- 2. evaluate it with a stable KL routine;
- 3. validate close decisions with higher precision or interval arithmetic;
- 4. choose the action only when the ranking is numerically reliable.
- This is particularly relevant when posterior updates become large and incremental information gains become very small.
- Dependencies: The chosen action may still be sensitive to modeling assumptions, prior specification, Monte Carlo error, and ties between nearly equal information gains. Stable arithmetic does not correct a misspecified Bayesian model.
- Correct probabilistic parameter fitting — statistics and scientific computing
- Use stable KL values and analytic gradients when fitting one distribution to another, calibrating probabilistic forecasts, or optimizing variational parameters.
- Applicable families include Normal, Gamma, Beta, Dirichlet, categorical, geometric, Poisson, and related distributions supported by the repair.
- This is useful for variational inference, calibration, synthetic-data fitting, and likelihood-free optimization where the optimum requires both the loss and gradient to approach exact zero.
- Dependencies: Stable arithmetic cannot resolve errors from poorly scaled parameters, invalid supports, inaccurate special functions outside the tested range, or an unsuitable optimizer.
- Trustworthy interpretability and circuit-discovery scores — research tooling
- Replace standard KL calls in activation patching, edge ablation, causal tracing, and circuit-discovery libraries.
- Compute the divergence between clean and ablated outputs from logits and use stable scores for thresholding and ranking.
- This can reduce false negative scores, negative edge importances, and incorrect top-edge selections, especially in FP16/BF16 or for large models where most effects are tiny.
- Dependencies: The score definition must be compatible with a logits-based divergence, and researchers should report numerical precision, score stability, and sensitivity to thresholds.
- Numerical-regression tests for ML frameworks and hardware backends — academia and industry
- Add certified tests based on interval or arbitrary-precision arithmetic to continuous integration for PyTorch-like frameworks, GPU kernels, compilers, and accelerator libraries.
- Test both value and gradient correctness, including correct rounding, exact identity behavior, and CPU/GPU consistency.
- Such tests could detect regressions when kernels are rewritten, fused, or lowered to specialized hardware.
- Dependencies: Reference generation is computationally expensive, and “correctly rounded” behavior may require architecture-specific handling of reductions, fused operations, and transcendental functions.
- Better user-facing diagnostics and monitoring
- Implement warnings when:
- KL is negative,
- KL is exactly zero despite materially different inputs,
- a distribution comparison is below the estimated precision floor,
- probabilities were computed in a lower precision than the divergence requires,
- CPU and GPU results disagree materially.
- A practical diagnostic tool could report whether the dominant problem is operator cancellation or input-representation error.
- Dependencies: Diagnostics need thresholds adapted to dtype, dimension, reduction mode, and distribution family; warnings should not be interpreted as proof that the underlying model is incorrect.
Long-Term Applications
The following applications require further engineering, broader validation, or changes to numerical libraries and hardware ecosystems before they can become standardized.
- Upstream integration into PyTorch and other numerical libraries
- Incorporate stable closed forms, compensated reductions, analytic gradients, and logits-based categorical KL directly into PyTorch, TensorFlow Probability, JAX, Stan, Pyro, and related libraries.
- A mature API could offer:
- a fast approximate mode,
- a stable mode,
- a strict correctly rounded mode,
- automatic fallback based on the estimated divergence scale.
- Dependencies: Upstream adoption requires backward compatibility, kernel optimization, API agreement, support for all relevant distribution families, and evidence that the runtime cost is acceptable for large-scale training.
- Adaptive-precision KL computation
- Develop algorithms that estimate cancellation risk and dynamically select FP16, BF16, FP32, FP64, compensated arithmetic, or interval arithmetic.
- For example, a library could use a fast low-precision path for large KL values and automatically invoke a stable or strict path when the divergence approaches the unit-roundoff scale.
- Dependencies: Reliable error estimators must be developed for high-dimensional distributions, GPU reductions, sparse probabilities, and batched workloads. Adaptive switching must not introduce unacceptable latency or nondeterminism.
- Hardware-supported accurate divergence primitives
- Design GPU, TPU, and edge-AI instructions for:
- correctly rounded
log1pandexpm1, - compensated summation,
- error-free transformations,
- accurate log-sum-exp and softmax,
- fused logits-to-KL operations.
- Such primitives could make stable KL affordable in real-time robotics, autonomous control, and large-scale model training.
- Dependencies: Hardware support must balance silicon area, power consumption, throughput, reproducibility, and compatibility with IEEE-754 behavior.
- Certified numerical guarantees for safety-critical AI
- Extend the paper’s interval-arithmetic approach into certification frameworks for medical decision systems, autonomous vehicles, industrial control, and financial risk models.
- A system could certify that:
- a divergence is positive,
- a policy update remains within a trust region,
- a Bayesian action ranking is not changed by rounding,
- a quantization decision preserves a specified output tolerance.
- Dependencies: Numerical certification addresses arithmetic uncertainty, not data uncertainty, distribution shift, model misspecification, or software defects elsewhere in the pipeline. End-to-end certification will require compositional error bounds.
- Reliable information-theoretic control for robotics
- Use certified KL estimates in active sensing, belief-space planning, multi-robot coordination, and adaptive exploration.
- Robots could select observations or actions based on expected information gain without being misled by vanishing or negative numerical estimates.
- Dependencies: Real-time constraints, non-Gaussian beliefs, online updates, sensor noise, and high-dimensional state spaces may require new stable approximations beyond the closed forms evaluated in the paper.
- Numerically robust privacy and distribution-shift monitoring
- Deploy stable KL or related divergence estimators for monitoring whether production data, model outputs, or user populations differ from reference distributions.
- Potential uses include:
- detecting demographic or geographic drift,
- monitoring privacy-preserving synthetic data,
- auditing federated-learning updates,
- comparing data distributions across hospitals or financial institutions.
- Dependencies: Practical monitoring often uses histograms, samples, smoothing, or estimated probabilities, so input-representation error may dominate even after the KL operator is repaired. Privacy constraints may also limit access to logits or raw distribution parameters.
- Standardized benchmarking for low-precision probabilistic computation
- Create community benchmarks spanning FP16, BF16, FP32, FP64, quantized probabilities, logits, GPU architectures, batch sizes, reduction modes, and distribution families.
- Benchmarks could become part of procurement and deployment requirements for AI accelerators and scientific libraries.
- Dependencies: The sampling design must reflect real workloads rather than oversampling extreme small-KL cases, while still testing the failure modes that are difficult to observe in ordinary benchmarks.
- Compiler-assisted numerical rewriting
- Extend compiler and graph-optimization systems so that they automatically recognize cancellation-prone KL expressions and replace them with stable decompositions while preserving gradients.
- This could be integrated into TorchInductor, XLA, MLIR, or domain-specific probabilistic-programming compilers.
- Dependencies: Automatic rewriting requires formal equivalence proofs, differentiation-aware transformations, support for control flow and batching, and cost models that decide when stability justifies extra arithmetic.
- Stable divergence layers for compressed and edge-deployed models
- Develop standardized divergence-monitoring layers that operate directly on logits during quantization-aware training, federated aggregation, continual learning, and on-device adaptation.
- These layers could trigger recalibration, preserve selected layers at higher precision, or detect unintended model drift.
- Dependencies: On-device memory and energy budgets may prohibit FP64 or interval arithmetic; efficient fixed-point or compensated implementations will be needed.
- Improved reproducibility standards for ML experiments
- Require papers and production reports using KL to specify:
- the KL direction,
- the input representation,
- dtype and accumulation precision,
- reduction mode,
- CPU/GPU backend,
- whether logits or rounded probabilities were used,
- numerical validation procedures.
- This would make results in distillation, RL, Bayesian inference, compression, and interpretability more reproducible.
- Dependencies: Community standards must distinguish meaningful numerical discrepancies from harmless last-bit variation and must be adopted by frameworks, reviewers, and benchmark maintainers.
Overall, the most immediately actionable intervention is to stop computing close-distribution KL values from rounded probabilities when original logits or parameters are available, and to replace cancellation-prone formulas rather than merely clamping negative outputs. The main long-term challenge is making these stable methods fast, standardized, and automatically available across numerical libraries and hardware platforms.
Glossary
- Ablation: Removal or disabling of a model component to measure its effect. “Circuit discovery scores each edge of a model by the KL between the clean output and the output with that edge ablated”
- Adaptive precision: A numerical method that increases arithmetic precision when the current precision cannot guarantee a reliable result. “If the FP64 value is closer to a rounding boundary than its a-priori error bound, the sum is re-evaluated with interval arithmetic at increasing precision”
- Analytic gradient: A gradient derived symbolically rather than computed through automatic differentiation. “We implement the derivative of the rewritten form directly”
- Arb ball arithmetic: Arbitrary-precision interval arithmetic representing values with a midpoint and an error radius. “The exact KL and every gradient component are then enclosed with Arb ball arithmetic”
- Automatic differentiation: Algorithmic computation of derivatives by applying the chain rule to a computational graph. “Gradients come from automatic differentiation”
- Bfloat16 (BF16): A 16-bit floating-point format with a wider exponent range and fewer significand bits than IEEE FP16. “for binary16 (FP16), binary32 (FP32), binary64 (FP64) and bfloat16 (BF16)”
- Bregman divergence: A discrepancy measure generated from a differentiable convex function and its first-order approximation. “sums of terms and Bregman divergences of convex functions for Gamma, Beta and Dirichlet”
- Cancellation: Loss of significant numerical information when nearly equal quantities are subtracted. “Subtracting two nearby floating-point numbers is exact ..., but exposes the rounding errors already present in them (cancellation)”
- Compensated arithmetic: Numerical techniques that track and correct rounding errors during arithmetic operations. “Stable closed-form decompositions, compensated arithmetic, and analytic gradients remove over 97% of significant errors”
- Compensated difference: A carefully computed subtraction designed to preserve accuracy when operands are close. “form the compensated, centred differences”
- Correct rounding: Producing the representable floating-point number nearest to the exact mathematical result. “A result is correctly rounded if it equals the exact value rounded to nearest in the output format”
- Cross-entropy: A loss measuring the discrepancy between a target probability distribution and a predicted distribution. “Numerical failures of softmax and cross-entropy explain stalled grokking”
- Distillation drift: Unintended divergence of a student model from an identical teacher caused by numerical errors during knowledge distillation. “The official losses are F.kl on softmax/log_softmax outputs”
- Double rounding: Error introduced when a value is rounded successively to two intermediate formats instead of directly to the final format. “FP64FP32FP16 is a double rounding”
- Error-free transformation: An arithmetic procedure that represents an operation’s exact result as a leading term plus a correction term. “from error-free transformations”
- Expected information gain (EIG): The expected reduction in uncertainty from obtaining a new observation. “Bayesian experimental design chooses the next observation by its expected information gain (EIG)”
- Floating-point underflow: A condition in which a nonzero value is too small to be represented normally in a floating-point format. “about 38% of the FP16 softmax probabilities underflow to zero”
- Fused implementation: An implementation that combines multiple computational operations to reduce intermediate rounding and representation errors. “show that a fused implementation stops distillation drift”
- Gradient component: One coordinate of a vector of partial derivatives with respect to model parameters. “correctly round all 567 million scored F.kl_div components”
- Interval arithmetic: Arithmetic that represents each quantity as an interval guaranteed to contain the exact value. “the sum is re-evaluated with interval arithmetic at increasing precision”
- Input-representation error: Error caused by finite-precision representations of inputs before an operator is applied. “the input-representation error already present in rounded (log-)probabilities”
- Kendall’s : A rank-correlation statistic that accounts for ties between two orderings. “Kendall's (1 indicates perfect agreement)”
- Low-rank factor: A compact matrix representation using factors whose rank is smaller than the original matrix dimension. “different low-rank factors of one covariance”
- Logits: Unnormalized real-valued scores that become probabilities after applying softmax. “This logits path, a row-vectorised form of the Categorical(logits) repair”
- Log-sum-exp: A numerically stabilized method for computing the logarithm of a sum of exponentials. “Accurately Computing the -Sum-Exp and Softmax Functions”
- Mixed precision: Use of multiple numerical precisions within one computation or training process. “Low-precision training and inference”
- Operator error: Error introduced by an operation acting on already stored, possibly rounded inputs. “We call the difference between the computed output and $T_{\mathrm{op}$ the operator error”
- Quantization: Mapping numerical values to a representation with fewer bits or discrete levels. “a standard metric for how far a compressed model has moved”
- Relative error: The magnitude of an error divided by the magnitude of the reference value. “The relative error is therefore about ”
- Softmax cancellation: Numerical cancellation occurring when probability vectors are subtracted during the backward pass of log-softmax. “A related backward error is Softmax Cancellation”
- Softmax collapse: A numerical failure in which softmax computations lose distinctions between probabilities, often because of extreme exponentials or rounding. “Softmax Collapse (first diagnosed by \citet{prieto2025})”
- Special-function evaluation: Numerically computing functions such as logarithms or inverse hyperbolic functions with accuracy guarantees. “non-negative decompositions, compensated arithmetic, special-function evaluation, and analytic gradients”
- Stratified sampling: Sampling designed to ensure representation across predefined ranges or categories. “from logits stratified in the same way”
- Trust-region constraint: A restriction requiring an optimization update to remain close to a reference policy or parameter state. “the trust-region constraint of policy optimisation”
- Unit roundoff: A bound characterizing the maximum relative rounding error in a floating-point format. “The rounding error of those terms is of the order of the unit roundoff ”
- ULP (unit in the last place): The spacing between adjacent representable floating-point values near a specified number. “errors in ULP are in units of the spacing of the format at the exact value”
- Variational autoencoder: A generative model that learns a probabilistic latent representation using variational inference. “The KL divergence is the regulariser of variational autoencoders”
- Vectorized computation: Applying an operation simultaneously to many vector or matrix elements rather than iterating individually. “a row-vectorised form of the Categorical(logits) repair”
- Zero crossing: A point where a function or derivative changes sign by passing through zero. “Where a gradient has a genuine zero crossing”





