betaFeedback

WorksComputer Science

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

Introduction

The Kullback–Leibler (KL) divergence (Kullback & Leibler, [32]) between two distributions is non-negative, and zero only if they coincide, but code does not always agree. Since 2019, users of PyTorch (Paszke et al., [45]) have repeatedly reported negative values from both of its KL functions, and the answer has been the same each time: this is floating-point error, clamp the result at zero (Appendix § 12.§ 1.1). Clamping hides the symptom and leaves the error. Clamping negative KL estimates sets their values and backpropagated gradients to zero. Many inaccurate KL estimates are positive and finite.

The KL divergence is the regulariser of variational autoencoders (Kingma & Welling, [29]), the trust-region constraint of policy optimisation (Schulman et al., [49, 50]; Shao et al., [51]), the loss of knowledge distillation (Hinton et al., [20]; Agarwal et al. [1]), and a standard metric for how far a compressed model has moved (Nagel et al., [42]; Xin et al. [60]). These applications often compare closely related distributions: consecutive policies, a student and its teacher, or a model and its quantized copy. Among the 116 PyTorch-based packages we inspected, 39 call at least one of the two KL interfaces (Appendix § 12).

Closeness is exactly where the textbook formulas break down. If PP and QQ differ by a relative amount δ\delta, then typically KL⁡(P∥Q)=O(δ2)\operatorname{KL}(P \mathbin{\|} Q) = O(\delta^2), while almost every closed form computes it as a sum of O(1)O(1) or O(δ)O(\delta) terms of mixed sign. The rounding error of those terms is of the order of the unit roundoff uu (about 6×10−86 \times10^{-8} in FP32, 5×10−45 \times10^{-4} in FP16), so the computed divergence is noise once the true KL is of the order of uu or smaller (Figure 1). It may be negative, zero for distinct distributions, or non-zero for identical ones, and its gradient need not point downhill. Low-precision formats (Micikevicius et al., [38]; Kalahar et al. (2019)) move this threshold into the range of practical values.

Figure 1. The problem and one consequence. The official PyTorch code is shown in red and ours in blue, with solid lines for FP32 and dashed lines for FP16. (a) Relative error of the returned KL between two Exponential distributions as they approach each other (median over 3000 parameter pairs per point, with FP16 shown while the true value is a normal number). The official closed form is implemented correctly, yet its error reaches 100% once the true KL falls below about 4×10−84 \times10^{-8} in FP32 (4×10−44 \times10^{-4} in FP16), where it returns zero or a negative number. The repaired divergence stays at the accuracy of the format. (b) A student initialised as an exact copy of its teacher and trained with the KL loss alone (vocabulary 151,936, Adam, learning rate 10−210^{-2}, median and range over 10 seeds, other settings in Appendix § 11). With the official loss the student’s top-1 predictions leave the teacher’s, whereas with our logits path they do not move.

Numerical failures of softmax and cross-entropy explain stalled grokking (Prieto et al., [46]) and distillation drift (Barron et al., [2]), but the KL divergence itself, across distribution families and interfaces, has not been measured. We measure it in both KL interfaces of PyTorch, torch.distributions.kl_divergence (interface A, closed forms between two distribution objects) and torch.nn.functional.kl_div (interface B, the loss behind nn.KLDivLoss), and show how to remove the error:

  • The failure is systematic, and silent (§ 2). On

7.5 million parameter pairs for the 18 same-family closed forms of interface A and 0.94 million batches for interface B, stratified by the true KL from 10−1510^{-15} to 1 and certified by interval arithmetic, the official results degrade steadily as the distributions approach each other, for every family, on CPU and GPU.

  • More precision is not the fix, but a different formula is (§ 3). Across 18 closed forms, we combine non-negative decompositions, compensated arithmetic, special-function evaluation, and analytic gradients. For F.kl_div, we repair signed elements, reductions, and gradients. The rewrites remove over 97% of significant errors in the working precision, and strict repairs yield no significant errors on 7.2 million scored closed-form samples and correctly round all 567 million interface-B components.

  • Two error sources must be told apart (§ 1.1): the operator error of F.kl_div on the inputs it receives, and the input-representation error already present in rounded (log-)probabilities, which no implementation of F.kl_div can repair and which requires a divergence computed from logits.

  • The errors change outcomes (§ 4), from fitting a single distribution and a sequential Bayesian experiment to distillation, KL-based decisions for a quantized LLM and circuit analysis of GPT-2 models.

Background and Error Model

Floating point. We use the standard model fl⁡(a∘b)=(a∘b)(1+ϵ)\operatorname{fl}(a \circ b)=(a \circ b)(1+\epsilon), ∣ϵ∣≤u|\epsilon| \le u, for ∘∈{+,−,×,/}\circ\in\{+,-,\times,/ \} (Higham, [19]), for binary16 (FP16), binary32 (FP32), binary64 (FP64) (IEEE, [23]) and bfloat16 (BF16). A result is correctly rounded if it equals the exact value rounded to nearest in the output format, and errors in ULP are in units of the spacing of the format at the exact value. Subtracting two nearby floating-point numbers is exact (Sterbenz, [54]), but exposes the rounding errors already present in them (cancellation) (Goldberg, [14]).

Cancellation near equality

Take two Exponential distributions with rates λp,λq\lambda_p,\lambda_q, for which KL=r−1−log⁡r\mathrm{KL}=r-1-\log r with r=λq/λp=1+xr=\lambda_q/\lambda_p=1+x. The exact value is x2/2+O(x3)x^2/2+O(x^3), but r−1−log⁡rr-1-\log r is evaluated near 1, where the absolute rounding error is about 2u2u, and the relative error is therefore about 2u/x22u/x^2, which exceeds 100% once ∣x∣<2u≈3.5×10−4|x| < \sqrt{2u} \approx3.5 \times10^{-4} in FP32. For example, for λp=1\lambda_p=1 and λq=fl⁡(1.0001)\lambda_q=\operatorname{fl}(1.0001) in FP32 the true value is 5.0013×10−95.0013 \times10^{-9}, but r−log⁡r=1.000000005…r-\log r=1.000000005\ldots rounds to 1 and the official formula returns exactly 0, so two different distributions are reported as identical (Figure 1a). The same structure, a second-order quantity obtained from first-order or zeroth-order terms, appears in the closed forms we examined (Appendix § 8). When only the support changes (Uniform, Pareto), the KL is first order. It is not removed by more precision alone, because FP32 parameters can differ by x=2−24x=2^{-24}, for which the same formula in FP64, whose unit roundoff is u64=2−53u_{64}=2^{-53}, can have a relative error of 2u64/x2≈0.062u_{64}/x^2 \approx0.06.

Interfaces. Interface A, kl_divergence(P,Q), dispatches on the types of the two distribution objects to a closed form in their parameters. Gradients come from automatic differentiation, and for families with two parameterisations (probs or logits) the constructors convert and clamp the parameters first. Interface B, F.kl_div(x, t), takes a tensor xx of log-probabilities and a target tt of probabilities (or of log-probabilities when log_target=True), evaluates t(log⁡t−x)t(\log t-x) or et(t−x)e^{t}(t-x) element-wise, and reduces.

Operator error versus input-representation error. For interface B the inputs are themselves outputs of a rounded computation, typically log_softmax of model logits. Let TopT_{\mathrm{op}} be the exact operator result on its stored inputs and Te2eT_{\mathrm{e2e}} the corresponding result from the original logits, with the same reduction. We call the difference between the computed output and TopT_{\mathrm{op}} the operator error, and Top−Te2eT_{\mathrm{op}}-T_{\mathrm{e2e}} the input-representation error. Only the first belongs to F.kl_div. A related backward error is Softmax Cancellation [2]. The gradient of the forward KL with respect to xx involves no cancellation. The cancellation happens afterwards, in the backward pass of log_softmax, where q−pq-p, the difference between the input distribution q=exq=e^{x} and the target p=tp=t, is formed from two rounded probability vectors, and the result is non-zero even when the two distributions are identical.

Numerical Errors in PyTorch

We first measure the failure, with a reference that is exact for the bit patterns the library receives, so that every reported error belongs to the implementation and not to the test.

Data and ground truth. For interface A we test the 18 distribution-specific same-family closed forms in 23 parameter and dimension configurations (five generic or delegated registrations are out of scope, and the two multivariate families are scored in FP32 only). For each we draw PP from an ordinary parameter region R0 and from stress regions (very large or small parameters, probabilities near 0 or 1), and construct QQ so that the true KL(P∥Q)(P\mathbin{\|}Q) falls in a prescribed decade: one control bin [10−1,1)[10^{-1},1) and 14 bins down to [10−15,10−14)[10^{-15},10^{-14}). Two further groups contain pairs whose parameters differ by 1–8 ULP, and identical pairs. This gives 7,542,469 samples, of which 7,234,454 are scored. Cells that the floating-point grid cannot populate remain empty. For interface B we generate 942,200 batches over log_target, FP16/FP32, K∈{2,4,16,256,1024}K \in\{2, 4, 16, 256, 1024\} classes, two batch sizes and all four reductions, from logits stratified in the same way. Parameters are stored in the target format first. The exact KL and every gradient component are then enclosed with Arb ball arithmetic [24] tightly enough to determine a unique correctly rounded value in that format (Appendices A and H).

Methods and metrics. OFFICIAL is PyTorch 2.15.0 on CPU, and we repeated the evaluation on an NVIDIA A100 GPU (Appendix D). OFFICIAL+, the natural “just use more precision” baseline, evaluates the unchanged official code after promoting the parameters exactly to the next format (FP32 for FP16 inputs, FP64 for FP32 inputs) and rounds the result once. An output is a significant error if it is off by at least 8 ULP or is qualitatively wrong (negative, NaN or infinite KL where the truth is finite and positive; spurious zero or non-zero; sign-flipped gradient component).

Errors near equality. The error grows as the true KL approaches the unit roundoff uu (Figure 2, which pools the 16 scalar-family configurations in R0, with details in Appendix A.1). In the control bin the official values are accurate (0.1% of the FP32 values are off by 1% or more). As the KL approaches u≈6×10−8u \approx6 \times10^{-8} most are wrong (86% at 10−710^{-7}), and below that nearly all are, with about three in ten negative from 10−1010^{-10} down. FP16 follows the same curve four decades earlier, as its roundoff predicts. Gradients, being first-order quantities, survive longer but fail in a worse way. At 10−1310^{-13} a fifth of the gradient vectors have a cosine below 0.99 with the true one, and at 10−1510^{-15}, 6.8% point into the opposite half-space. No family is exempt (Table 1, columns OFFICIAL).

Figure 2. Errors of the official interface-A implementation (red) and of the same formula evaluated in the next higher precision (green) versus the true KL, for the 16 scalar-family configurations in the ordinary parameter region R0. Solid lines are FP32 inputs and dashed lines FP16 inputs. The inset enlarges the lower right corner of the last panel. FP16 relative error is shown only while the true KL is a normal number (above about 6×10−56 \times10^{-5}).

DistributionNNFP16 inputs OFFICIALOFF.+REWRITEOURSFP32 inputs OFFICIALOFF.+REWRITEOURS
Cauchy345,02864.0510.600.003088.8834.8400
Uniform181,79851.6200075.080.01200
Exponential308,00072.5700085.6433.4900
Poisson323,49875.649.750.002085.8234.4400
Normal339,49942.4000082.1813.8400
Laplace339,69258.322.241.46085.8731.9500
Pareto206,95073.5200083.766.9900
Bernoulli (probs)327,09961.430.290.41081.0627.1500
Bernoulli (logits)353,39249.921.290.012075.9525.480.0120
Binomial (probs)329,88583.8610.430.32085.6037.5100
Binomial (logits)345,71569.6934.930.020086.9543.790.0310
Geometric (probs)304,86191.1736.530094.1948.3500
Geometric (logits)352,17894.3542.770.17096.6251.47<0.001<0.0010
Gumbel339,24966.1813.780.007090.0238.4200
Gamma331,06778.479.090.003088.6736.920.0020
Beta329,15685.3840.322.11092.6243.770.650
Dirichlet (K=2,4,16K=2, 4, 16)314,45184.3–89.029.6–55.90.009–2.45092.1–93.841.6–49.80.003–0.690
Categorical (probs; K=2,4,16K=2, 4, 16)372,42946.6–47.63.4–4.6≤0.01\le0.01086.0–86.932.2–32.5≤0.01\le0.010
Categorical (logits; K=2,4,16K=2, 4, 16)367,74659.4–62.712.4–18.3<0.01<0.01088.3–90.535.8–38.400
Cont. Bernoulli (probs)342,07078.376.270.09089.7538.920.040
Cont. Bernoulli (logits)376,69186.1727.81<0.01<0.01090.8942.56<0.01<0.010
Multivariate Normal (d=2,4d=2, 4)202,000FP16 unsupported88.6–88.935.800
Low-rank MVN (d=2,4;r=1,2d=2, 4; r=1, 2)202,000FP16 unsupported91.1–93.439.5–41.900

Table 1. Significant KL error rates (%) for interface A, across all KL bins and parameter regions. Entries are percentages of scored inputs with ≥8\ge8 ULP error or a qualitative failure. NN counts scored inputs across supported formats. OFFICIAL is PyTorch, OFF.+ the promoted official formula, REWRITE our same-format formula and OURS the strict repair. Ranges span dimension settings. The two multivariate families lack official FP16 support. Gradient results are in Appendix § 8.

Precision promotion. Evaluating the same formula one format higher moves the failure; it does not remove it, because two inputs can still differ by one unit in the last place of the input format (§ 1.1). For FP32 inputs OFFICIAL+ shifts the curve of Figure 2 about nine decades down (56% off by ≥1%\ge1\% at 10−1510^{-15}), and for FP16 inputs it leaves a residue (13% at 10−510^{-5}). Over all bins and regions it leaves 7–51% of the FP32 KL values significantly wrong in 22 of 23 configurations (Table 1), Uniform being the only exception.

Loss-operator errors. F.kl_div fails in a different way. Its element t(log⁡t−x)t(\log t-x) cancels whenever t≈ext \approx e^{x}. For probability targets 35–70% of the FP32 sum outputs are off by at least 1%, and scaled reductions produce large target-gradient errors (FP16, mean, K=256K=256: 95.4% of gradient rows contain a component of the wrong sign). Unlike the closed forms, these operator errors essentially disappear in FP64, but the error inherited from the inputs does not, since TopT_{\mathrm{op}} differs from Te2eT_{\mathrm{e2e}} by ≥1%\ge1\% on 40–99% of the batches, in any precision of the operator (Appendix C).

CPU and GPU. The failure persists on the GPU. On an A100 the aggregate significant-error rates for interface A differ from the CPU rates by at most 1.5 percentage points. For F.kl_div, 50.0% of forward and 71.1% of non-boundary backward components are correctly rounded (CPU: 52.5% and 76.4%). The two devices nevertheless do not return the same bits, and 27% of the FP32 KL values of OFFICIAL differ. Our strict repair OURS (§ 3) has no significant error on either device (Appendix D).

Stable KL Computation

The repairs of the 18 closed forms differ in detail (Appendix § 8) but share four ingredients, which we illustrate with the smallest example that needs each. F.kl_div additionally requires accurate signed elements and reductions (Appendix § 9).

Stable decompositions. The function

φ(x)=x−log⁡1p(x)≥0,x>−1,(1)\varphi(x) = x - \log1p(x) \ge0,\qquad x > -1, \tag*{(1)}

is the Exponential KL with x=(λq−λp)/λpx = (\lambda_q - \lambda_p)/\lambda_p, and it is the building block of almost every other family. For example, for two normal distributions Np=N(μp,σp2)N_p = \mathcal{N}(\mu_p,\sigma_p^2) and Nq=N(μq,σq2)N_q = \mathcal{N}(\mu_q,\sigma_q^2), with e=(σp−σq)/σqe = (\sigma_p-\sigma_q)/\sigma_q and w=(μp−μq)/σqw = (\mu_p-\mu_q)/\sigma_q,

KL⁡(Np∥Nq)=φ(e)+12e2+12w2,(2)\operatorname{KL}(N_p\mathbin{\|}N_q) = \varphi(e) + \frac{1}{2}e^2 + \frac{1}{2}w^2, \tag*{(2)}

whereas the official code evaluates 12(r2+w2−1−log⁡r2)\frac{1}{2}(r^2+w^2-1-\log r^2) with r=σp/σqr=\sigma_p/\sigma_q, in which w2w^2 is absorbed by r2≈1r^2\approx1. Analogous identities (Appendix § 8, which defines each argument) give KL⁡=log⁡1p(r)\operatorname{KL}=\log1p(r) with r≥0r\ge0 for Cauchy and Uniform, pφ(x1)+(1−p)φ(x2)p\varphi(x_1)+(1-p)\varphi(x_2) for Bernoulli, ∑kpkφ(ρk)\sum_k p_k\varphi(\rho_k) for Categorical, ∑iφ(Nii)+12∥N∥F2+12∥v∥2\sum_i\varphi(N_{ii})+\frac{1}{2}\lVert N\rVert_F^2+\frac{1}{2}\lVert v\rVert^2 for the multivariate normal, and sums of φ\varphi terms and Bregman divergences of convex functions for Gamma, Beta and Dirichlet. Every term is non-negative, so the sum is as accurate as its terms, cannot be negative, and is exactly zero when all terms are. φ\varphi itself still cancels as x→0x\to0, so on −34≤x≤3-\frac{3}{4}\le x\le3 we use the exact identities log⁡1p(x)=2atanh⁡(s)\log1p(x)=2\operatorname{atanh}(s), s=x/(2+x)s=x/(2+x), to write

φ(x)=x22+x−2s3∑k≥1s2(k−1)2k+1,(3)\varphi(x)=\frac{x^2}{2+x}-2s^3\sum_{k\ge1}\frac{s^{2(k-1)}}{2k+1}, \tag*{(3)}

a convergent series whose truncation after 9/17/36 terms (FP16/FP32/FP64) is bounded rigorously by u/16u/16 relative to φ\varphi.

References

  1. [1]Agarwal, R., Vieillard, N., Zhou, Y., Stanczyk, P., Ramos, S., Geist, M., and Bachman, O. On-policy distillation of language models: Learning from self-generated mistakes. In International Conference on Learning Representations (ICLR), 2024.
  2. [2]Barron, J. T., Gnanapragasam, D., and Tschannen, M. A fix for softmax and cross-entropy. arXiv preprint arXiv:2610.31642, 2026.arxiv.org/abs/2610.31642
  3. [3]Bingham, E., Chen, J. P., Jankowiak, M., Obermeyer, F., Pradhan, N., Karaletsos, T., Singh, R., Szerlip, P., Horsfall, P., and Goodman, N. D. Pyro: Deep universal probabilistic programming. Journal of Machine Learning Research, 20(28):1–6, 2019.arxiv.org/abs/1810.09538
  4. [4]Blanchard, P., Higham, D. J., and Higham, N. J. Accurately computing the log-sum-exp and softmax functions. IMA Journal of Numerical Analysis, 41(4):2311–2330, 2021.DOI
  5. [5]Bradbury, J., Frostig, R., Hawkins, P., Johnson, M. J., Leary, C., Maclaurin, D., Necula, G., Paszke, A., VanderPlas, J., Wanderman-Milne, S., and Zhang, Q. JAX: Composable transformations of Python+NumPy programs. http://github.com/jax-ml/jax, 2018.
  6. [6]Cai, Y., Yao, Z., Dong, Z., Gholami, A., Mahoney, M. W., and Keutzer, K. ZeroQ: A novel zero shot quantization framework. In IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2020.arxiv.org/abs/2001.00281
  7. [7]Carpenter, B., Gelman, A., Hoffman, M. D., Lee, D., Goodrich, B., Betancourt, M., Brubaker, M., Guo, J., Li, P., and Riddell, A. Stan: A probabilistic programming language. Journal of Statistical Software, 76(1), 2017.DOI
  8. [8]Chaloner, K. and Verdinelli, I. Bayesian experimental design: A review. Statistical Science, 10(3):273–304, 1995.
  9. [9]Conmy, A., Mayor-Parker, A. N., Lynch, A., Heimersheim, S., and Garriga-Alonso, A. Towards automated circuit discovery for mechanistic interpretability. In Advances in Neural Information Processing Systems, 2023.arxiv.org/abs/2304.14997
  10. [10]Dekker, T. J. A floating-point technique for extending the available precision. Numerische Mathematik, 18(3):224–242, 1971.DOI
  11. [11]Dillon, J. V., Langmore, I., Tran, D., Brevdo, E., Vasudevan, S., Moore, D., Patton, B., Alemi, A., Hoffman, M., and Sarous, R. A. TensorFlow distributions. arXiv preprint arXiv:1711.10604, 2017.arxiv.org/abs/1711.10604
  12. [12]Dong, Z., Yao, Z., Gholami, A., Mahoney, M., and Keutzer, K. HAWQ: Hessian aware quantization of neural networks with mixed-precision. In IEEE/CVF International Conference on Computer Vision (ICCV), 2019.arxiv.org/abs/1905.03696
  13. [13]Frantar, E., Ashkboos, S., Hoefler, T., and Alistarh, D. GPTQ: Accurate post-training quantization for generative pre-trained transformers. In International Conference on Learning Representations (ICLR), 2023.arxiv.org/abs/2210.17323
  14. [14]Goldberg, D. What every computer scientist should know about floating-point arithmetic. ACM Computing Surveys, 23(1):5–48, 1991.DOI
  15. [16]Hanna, M., Liu, O., and Variengien, A. How does GPT-2 compute greater-than?: Interpreting mathematical abilities in a pre-trained language model. In Advances in Neural Information Processing Systems, 2023.arxiv.org/abs/2305.00586
  16. [17]Heimersheim, S. and Janiak, J. A circuit for Python doc-strings in a 4-layer attention-only transformer. AI Alignment Forum, https://www.alignmentforum.org/posts/u6KXXmKfbXfWzoAXn, 2023.
  17. [18]Higgins, I., Matthey, L., Pal, A., Burgess, C., Glorot, X., Botvinick, M., Mohamed, S., and Lerchner, A. beta-VAE: Learning basic visual concepts with a constrained variational framework. In International Conference on Learning Representations (ICLR), 2017.
  18. [19]Higham, N. J. Accuracy and Stability of Numerical Algorithms. SIAM, 2nd edition, 2002.
  19. [20]Hinton, G., Vinyals, O., and Dean, J. Distilling the knowledge in a neural network. arXiv preprint arXiv:1503.02531, 2015.arxiv.org/abs/1503.02531
  20. [22]Humbatova, N., Jahangirova, G., Bavota, G., Riccio, V., Stocco, A., and Tonella, P. Taxonomy of real faults in deep learning systems. In International Conference on Software Engineering (ICSE), 2020.
  21. [23]IEEE. IEEE standard for floating-point arithmetic. IEEE Std 754-2019, 2019.
  22. [24]Johansson, F. Arb: Efficient arbitrary-precision midpoint-radius interval arithmetic. IEEE Transactions on Computers, 66(8):1281–1292, 2017.arxiv.org/abs/1611.02831
  23. [25]Kahan, W. Pracniques: Further remarks on reducing truncation errors. Communications of the ACM, 8(1):40, 1965.DOI
  24. [26]Kalamkar, D., Mudigere, D., Mellempudi, N., Das, D., Banerjee, K., Avancha, S., Vooturi, D. T., Jammalamadaka, N., Huang, J., Yuen, H., et al. A study of BFLOAT16 for deep learning training. arXiv preprint arXiv:1905.12322, 2019.arxiv.org/abs/1905.12322
  25. [27]Kim, T., Oh, J., Kim, N. Y., Cho, S., and Yun, S.-Y. Comparing Kullback-Leibler divergence and mean squared error loss in knowledge distillation. In International Joint Conference on Artificial Intelligence (IJCAI), 2021.
  26. [28]Kingma, D. P. and Ba, J. Adam: A method for stochastic optimization. In International Conference on Learning Representations (ICLR), 2015.arxiv.org/abs/1412.6980
  27. [29]Kingma, D. P. and Welling, M. Auto-encoding variational Bayes. In International Conference on Learning Representations (ICLR), 2014.arxiv.org/abs/1312.6114
  28. [30]Kloberdanz, E., Kloberdanz, K. G., and Le, W. DeepStability: A study of unstable numerical methods and their solutions in deep learning. In International Conference on Software Engineering (ICSE), 2022.
  29. [31]Knuth, D. E. The Art of Computer Programming, Volume 2: Seminumerical Algorithms. Addison-Wesley, 3rd edition, 1997.
  30. [32]Kullback, S. and Leibler, R. A. On information and sufficiency. The Annals of Mathematical Statistics, 22(1):79–86, 1951.DOI
  31. [33]Lin, J., Tang, J., Tang, H., Yang, S., Chen, W.-M., Wang, W.-C., Xiao, G., Dang, X., Gan, C., and Han, S. AWQ: Activation-aware weight quantization for LLM compression and acceleration. In Proceedings of Machine Learning and Systems (MLSys), 2024.
  32. [34]Lindley, D. V. On a measure of the information provided by an experiment. The Annals of Mathematical Statistics, 27(4):986–1005, 1956.
  33. [35]Liu, Z., Oguz, B., Zhao, C., Chang, E., Stock, P., Mehidad, Y., Shi, Y., Krishnamoorthi, R., and Chandraker, V. LLM-QAT: Data-free quantization aware training for large language models. In Findings of the Association for Computational Linguistics (ACL), 2024.
  34. [36]Loaiza-Ganem, G. and Cunningham, J. P. The continuous Bernoulli: Fixing a pervasive error in variational autoencoders. In Advances in Neural Information Processing Systems (NeurIPS), 2019.
  35. [37]Merity, S., Xiong, C., Bradbury, J., and Socher, R. Pointer sentinel mixture models. In International Conference on Learning Representations (ICLR), 2017.arxiv.org/abs/1609.07843
  36. [38]Micikevicius, P., Narang, S., Alben, J., Diamos, G., Elsen, E., Garcia, D., Ginsburg, B., Houston, M., Kuchaiev, O., Venkatesh, G., and Wu, H. Mixed precision training. In International Conference on Learning Representations (ICLR), 2018.arxiv.org/abs/1710.03740
  37. [39]Miller, J., Chughtai, B., and Saunders, W. Transformer circuit faithfulness metrics are not robust. In Conference on Language Modeling (COLM), 2024.
  38. [40]Mishne, G., Wan, Z., Wang, Y., and Yang, S. The numerical stability of hyperbolic representation learning. In International Conference on Machine Learning (ICML), 2023.
  39. [41]Muller, J.-M., Brunie, N., de Dinechin, F., Jeannerod, C.-P., Joldes, M., Lefèvre, V., Melquiond, G., Revol, N., and Torres, S. Handbook of Floating-Point Arithmetic. Birkhäuser, 2nd edition, 2018.
  40. [42]Nagel, M., Fournarakis, M., Amjad, R. A., Bondarenko, Y., van Baalen, M., and Blankevoort, T. A white paper on neural network quantization. arXiv preprint arXiv:2106.08295, 2021.
  41. [43]Ogita, T., Rump, S. M., and Oishi, S. Accurate sum and dot product. SIAM Journal on Scientific Computing, 26(6):1955–1988, 2005.DOI
  42. [44]Panchekha, P., Sanchez-Stern, A., Wilcox, J. R., and Tatlock, Z. Automatically improving accuracy for floating point expressions. In ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), 2015.
  43. [45]Paszke, A., Gross, S., Massa, F., Lerer, A., Bradbury, J., Chanan, G., Killeen, T., Lin, Z., Gimelshein, N., Antiga, L., et al. PyTorch: An imperative style, high-performance deep learning library. In Advances in Neural Information Processing Systems (NeurIPS), 2019.
  44. [46]Prieto, L., Barsbey, M., Mediano, P. A. M., and Birdal, T. Grokking at the edge of numerical stability. In International Conference on Learning Representations (ICLR), 2025.arxiv.org/abs/2501.04697
  45. [48]Schulman, J. Approximating KL divergence. Blog post, http://joschu.net/blog/kl-approx.html, 2020.
  46. [49]Schulman, J., Levine, S., Abbeel, P., Jordan, M., and Moritz, P. Trust region policy optimization. In International Conference on Machine Learning (ICML), 2015.arxiv.org/abs/1502.05477
  47. [50]Schulman, J., Wolski, F., Dhariwal, P., Radford, A., and Klimov, O. Proximal policy optimization algorithms. arXiv preprint arXiv:1707.06347, 2017.arxiv.org/abs/1707.06347
  48. [51]Shao, Z., Wang, P., Zhu, Q., Xu, R., Song, J., Bi, X., Zhang, H., Zhang, M., Li, Y. K., Wu, Y., and Guo, D. DeepSeek-Math: Pushing the limits of mathematical reasoning in open language models. arXiv preprint arXiv:2402.03300, 2024.arxiv.org/abs/2402.03300
  49. [52]Shewchuk, J. R. Adaptive precision floating-point arithmetic and fast robust geometric predicates. Discrete & Computational Geometry, 18(3):305–363, 1997.DOI
  50. [53]Sibidanov, A., Zimmermann, P., and Glondu, S. The CORE-MATH project. In IEEE Symposium on Computer Arithmetic (ARITH), 2022.DOI
  51. [54]Sterbenz, P. H. Floating-Point Computation. Prentice-Hall, 1974.
  52. [55]The mpmath development team. mpmath: a Python library for arbitrary-precision floating-point arithmetic. https://mpmath.org/, 2023.
  53. [56]von Werra, L., Belkada, Y., Tunstall, L., et al. TRL: Transformer reinforcement learning. https://github.com/huggingface/trl, 2020.
  54. [57]Wang, G., Wang, Z., Chen, J., Chen, X., and Yan, M. An empirically study on numerical bugs in deep learning programs. In IEEE/ACM International Conference on Automated Software Engineering (ASE), 2022.DOI
  55. [58]Wang, K., Variengien, A., Conmy, A., Shlegeris, B., and Steinhardt, J. Interpretability in the wild: a circuit for indirect object identification in GPT-2 small. In International Conference on Learning Representations, 2023.arxiv.org/abs/2211.00593
  56. [60]Xin, M., Priyadarshi, S., Xin, J., Kartal, B., Vavre, A., et al. Quantization-aware distillation for NVFP4 inference accuracy recovery. arXiv preprint arXiv:2601.20088, 2026.arxiv.org/abs/2601.20088
  57. [61]Yan, M., Chen, J., Zhang, X., Tan, L., Wang, G., and Wang, Z. Exposing numerical bugs in deep learning via gradient back-propagation. In ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering (ESEC/FSE), 2021.DOI
  58. [62]Yang, A., Yang, B., Zhang, B., Hui, B., Zheng, B., Yu, B., Li, C., Liu, D., Huang, F., et al. Qwen2.5 technical report. arXiv preprint arXiv:2412.15115, 2024.arxiv.org/abs/2412.15115
  59. [63]Yuan, J., Li, H., Ding, X., Xie, W., Li, Y.-J., Zhao, W., Wan, K., Shi, J., Hu, X., and Liu, Z. Give me FP32 or give me death? Challenges and solutions for reproducible reasoning. arXiv preprint arXiv:2506.09501, 2025.
  60. [64]Zamirai, P., Zhang, J., Aberger, C. R., and De Sa, C. Revisiting BFloat16 training. arXiv preprint arXiv:2010.06192, 2020.arxiv.org/abs/2010.06192
  61. [65]Zhang, Y., Chen, Y., Cheung, S.-C., Xiong, Y., and Zhang, L. An empirical study on TensorFlow program bugs. In ACM SIGSOFT International Symposium on Software Testing and Analysis (ISSTA), 2018.DOI
  62. [66]Zhang, Y., Ren, L., Chen, L., Xiong, Y., Cheung, S.-C., and Xie, T. Detecting numerical bugs in neural network architectures. In ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering (ESEC/FSE), 2020.DOI
  63. [67]Ziv, A. Fast evaluation of elementary mathematical functions with correctly rounded last bit. ACM Transactions on Mathematical Software, 17(3):410–423, 1991.DOI

Paper details

vlnc:W_ujn5ah6z
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

ChatGPT, Claude

View statement
Looking for related papers…
Contents