Operator-Aware Mixed-Precision Tolerance Calibration for Tensor Kernels
Summary
This paper proposes an operator-aware calibration method for absolute tolerances in tensor kernel correctness tests, using error distribution data to set tighter thresholds. The method achieves a 9.3% absolute recall improvement in bug detection with minimal false positives, demonstrated on the gpuemu corpus.
View Cached Full Text
Cached at: 07/21/26, 06:46 AM
# Operator-Aware Mixed-Precision Tolerance Calibration for Tensor Kernels
Source: [https://arxiv.org/html/2607.16228](https://arxiv.org/html/2607.16228)
11institutetext:Arizona State University, USA
11email:dsarkar3@asu\.edu###### Abstract
Most tensor\-kernel correctness tests go through a fixed\-shape allclose\-style check with hand\-picked absolute and relative tolerances\. The thresholds are copied across the corpus and rarely revisited\. We mine the element\-wise error distribution of every test case from accumulated cloud GPU runs across the 26\-entry gpuemu corpus and 2 dtypes \(8,0768\{,\}076result rows\)\. We then ask one empirical question\. What absolute tolerance would the kernel itself, observed under its correct implementation, justify? The answer is much tighter than the current hand\-picked atol\. The largest tightening is attention\_triton fp16 at2,184×2\{,\}184\\times\. Restricted to the seven LLM\-style buggy variants for which the corpus ships a paired correct counterpart, calibrated per\-\(op, dtype\) tolerances raise bug\-detection recall from 73\.2% \(1,8051\{,\}805of2,4672\{,\}467\) to 82\.4% \(2,0342\{,\}034of2,4672\{,\}467\), an absolute gain of9\.39\.3percentage points \(\+229 new detections\)\. The control false\-positive count rises from 0 to 20 out of1,8821\{,\}882correct\-control cases \(\+1\.1\+1\.1percentage points\)\.
## 1Introduction
Mixed\-precision kernels \(fp16, bfloat16, fp32\) ship in every modern deep\-learning system\[[1](https://arxiv.org/html/2607.16228#bib.bib14),[5](https://arxiv.org/html/2607.16228#bib.bib15)\]\. Their correctness is judged against a higher\-precision reference with absolute and relative tolerances:
torch\.allclose\(out, ref, atol=ε, rtol=δ\)\.\\texttt\{torch\.allclose\(out, ref, atol=$\\varepsilon$, rtol=$\\delta$\)\}\.
The tolerancesε\\varepsilonandδ\\deltaare operator and dtype specific in principle\. In practice they are uniform across an entire benchmark\. KernelBench\[[6](https://arxiv.org/html/2607.16228#bib.bib1)\]usesatol=1e\-5, rtol=1e\-2\. GEAK\[[9](https://arxiv.org/html/2607.16228#bib.bib2)\]uses a per\-op shortlist\. These hand\-picked values serve well most of the time\. The cost of getting them wrong is asymmetric\.
Too loose\.Real bugs slip through\. We quantify the gap below at9\.39\.3percentage points of recall on the gpuemu buggy corpus\[[8](https://arxiv.org/html/2607.16228#bib.bib24)\]\.
Too tight\.Correct kernels at the edge of the tolerance band flap as flaky failures and get disabled in CI\.
This paper makes the trade\-off measurable and proposes a one\-shot calibration that improves both axes at once\. The contributions are three\.
1. 1\.A measurement instrument\. The validator of the companion artefact\[[8](https://arxiv.org/html/2607.16228#bib.bib24)\]records the full element\-wise error distribution per test case: count, num\-exceeding, abs error percentiles, rel error envelope, ULP envelope\. The full schema is listed in Section[3\.1](https://arxiv.org/html/2607.16228#S3.SS1)\. The data is rich enough to drive the calibration below\.
2. 2\.A calibration protocol\. For each \(op, dtype\) we compute the p95 ofmax\_absacross passing cases of the correct kernel and multiply by a1\.51\.5safety factor\. We then apply this calibrated atol to every variant in the op family, including the LLM\-style buggy ones, and re\-classify\.
3. 3\.An empirical result on8,0768\{,\}076result rows\. Calibrated atol recovers an additional 229 buggy\-kernel detections across the seven paired buggy variants\. Recall goes from 73\.2% to 82\.4% \(\+9\.3 percentage points\)\. The cost is a net increase of 20 control false positives \(from 0 to 20 out of1,8821\{,\}882correct\-control cases,\+1\.1\+1\.1percentage points\)\.
## 2Related Work
Mixed\-precision tolerances in practice\.The PyTorch mixed\-precision documentation\[[1](https://arxiv.org/html/2607.16228#bib.bib14)\]describes the dynamic grad\-scaler workaround for fp16 and recommends fp32 master copies for accumulation, but offers no per\-op tolerance guidance for correctness testing\. The BF16 study of Kalamkar et al\.\[[5](https://arxiv.org/html/2607.16228#bib.bib15)\]establishes BF16’s range advantage but does not address kernel\-level tolerance setting\. V\-ABFT\[[4](https://arxiv.org/html/2607.16228#bib.bib16)\]and recent componentwise error analyses\[[3](https://arxiv.org/html/2607.16228#bib.bib17)\]develop analytical bounds for matmul accumulation but require operator\-specific derivation\.
Heuristic calibration\.El Arar et al\.\[[3](https://arxiv.org/html/2607.16228#bib.bib17)\]propose generating positive matrices of representative sizes, computing relative verification error across 100k trials, and setting thresholds to the observed maximum plus a 20% safety margin\. Our protocol differs in three respects\. The workload is the actual fuzz corpus, not synthetic positive matrices\. We use p95 with1\.5×1\.5\\timessafety, robust to single\-case outliers\. We evaluate the recall improvement on a seeded\-buggy corpus rather than reporting only the calibrated threshold\.
DL library testing\.FreeFuzz\[[10](https://arxiv.org/html/2607.16228#bib.bib6)\], DocTer\[[11](https://arxiv.org/html/2607.16228#bib.bib7)\], DeepREL\[[2](https://arxiv.org/html/2607.16228#bib.bib8)\], and NablaFuzz\[[12](https://arxiv.org/html/2607.16228#bib.bib9)\]use cross\-backend or metamorphic oracles to find logical bugs without per\-op atol\. They avoid the calibration problem but can only flag bugs that change the comparison\-against\-another\-implementation result\. Calibrated atol is complementary\. It tightens the same\-implementation reference oracle that is the only option when there is no other backend \(e\.g\., a new Triton kernel\)\.
## 3Method
### 3\.1Captured distribution
The gpuemu validator populates anErrorStatsrecord on every validation\. The record carries eleven fields:count, the number of element comparisons;num\_exceeding, the count exceeding the per\-\(op, dtype\) tolerance; the abs\-error envelope \(max\_abs,mean\_abs\) and percentiles \(p50\_abs,p90\_abs,p99\_abs\); the rel\-error pair \(max\_rel,mean\_rel\); and the ULP pair \(max\_ulp,mean\_ulp\)\.
ULP distance for fp16 and bf16 is computed in the native 16\-bit ordered representation\. For fp32 and fp64 it is computed in 32\-bit and 64\-bit respectively\. NaN and Inf inputs saturate ULP tou64::MAX\. All values ride the same JSON protocol that delivers the verdict, so the calibration data is a free side product of every run\.
### 3\.2Calibration protocol
For each correct kernel in an op family \(e\.g\.,softmax\_tritonin the softmax family\) and each dtype:
```
passing_abs = [ row.max_abs for row in results
if row.kernel == K_correct and row.dtype == DT
and row.passed ]
proposed_atol = percentile(passing_abs, 95) * 1.5
```
We then applyproposed\_atolto every kernel in the family, both correct and buggy, and recount\.
The1\.5×1\.5\\timessafety multiplier is a single fixed hyperparameter\. A formal sensitivity sweep across1\.25×1\.25\\timesto2\.0×2\.0\\timesis noted as a v2 follow\-up in Section[6](https://arxiv.org/html/2607.16228#S6)\.
### 3\.3Calibration source mapping
The mapping from a buggy variant to its correct counterpart is currently hard\-coded by naming convention in the calibration script \(for example, thesoftmax\_llm\_buggyvariant maps tosoftmax\_triton\)\. A future revision should read acalibrate\-againstfield from each kernel’s metadata file\.
### 3\.4Assumptions
The calibration depends on four assumptions\.
1. 1\.The corpus contains at least one correct kernel per op family\. The calibration percentile is meaningful only over correct samples\. The 26\-entry gpuemu corpus satisfies this by construction\.
2. 2\.The fp64 reference is the ground truth for each \(op, dtype\) pair\. The error distribution we calibrate against is therefore the kernel’s intrinsic error against fp64\.
3. 3\.The1,8821\{,\}882correct\-control cases are representative of the operator’s typical workload\. The corpus spans boundary and regular shapes plus three value distributions \(uniform, NaN\-injected, adversarial\), which we judge representative for the LLM\-Triton class\.
4. 4\.The1\.5×1\.5\\timessafety multiplier is set a priori\. A formal sensitivity sweep is a v2 follow\-up\.
## 4Evaluation
Data\.8,0768\{,\}076result rows accumulated from cloud GPU runs of the 26\-entry gpuemu corpus at 2 dtypes \(16 controls plus 10 LLM\-style buggy variants; see the companion paper\[[8](https://arxiv.org/html/2607.16228#bib.bib24)\]for the canonical corpus table\)\. Each correct\-kernel \(op, dtype\) cell produces a calibration sample\. The headline below is restricted to the seven buggy variants that ship a paired correct counterpart\. The full tightening table spans 14 \(op, dtype\) cells with a finite calibrated tolerance \(Table[2](https://arxiv.org/html/2607.16228#S4.T2)\)\. Runs captured on RTX 3060 between 2026\-05\-27 and 2026\-06\-11; all error\-stats payloads persist to a Backblaze B2 bucket\.
Headline\.Applyingp95×1\.5p\_\{95\}\\times 1\.5from each correct kernel as the calibrated atol changes the verdict on the corpus as shown in Table[1](https://arxiv.org/html/2607.16228#S4.T1)\.
Table 1:Calibrated atol vs current per\-op atol, seven paired\-buggy subset\.That is 9\.3 percentage points of recall on the seven paired\-buggy subset, at the cost of 20 net new control false positives\. The 20 new failures cluster on \(op, dtype\) cells where the kernel’s typical max\-abs error is small enough that the calibrated p95 tightens below a few hand\-picked outliers \(layernorm fp32 and fp16, sigmoid\_triton fp16, softmax fp16, rmsnorm\_triton fp16, and a couple of matmul cells\)\. Table[2](https://arxiv.org/html/2607.16228#S4.T2)reports the per\-\(op, dtype\) tightening factor on representative entries\.
Table 2:Tightening factor per \(op, dtype\), selected entries from 14 total\.Medians are between100×100\\timesand200×200\\times, which suggests hand\-picked tolerances are routinely chosen with a wide safety margin that swallows real bugs\.
Figure 1:Tightening factor \(current / calibrated atol\), log scale\. Bars right of1\.01\.0mark current tolerances looser than calibration\.Per\-buggy\-kernel recall improvement under calibrated atol\(selected entries\) is in Table[3](https://arxiv.org/html/2607.16228#S4.T3)\.
Table 3:Per\-buggy\-kernel recall, current vs calibrated atol, selected entries\.The largest recall gains are on the shape\-dependent tail\-mask bugs \(softmax\_\*\)\. These are exactly the cases where the hand\-picked atol was wide enough to mask the bug at most shapes\.
## 5Discussion
Calibration interacts with input generation\[[7](https://arxiv.org/html/2607.16228#bib.bib26)\]\. When boundary fuzzing already catches every case of a uniformly wrong bug \(gelu\_triton\_buggy, for example\), tightening atol changes nothing\. The calibration’s value is concentrated on shape\-dependent bugs and on dtypes where the hand\-picked atol was guessed pessimistically\.
The1\.5×1\.5\\timessafety multiplier could be replaced with an analytical bound from the operator’s known error structure\. Examples areO\(K⋅εdtype\)O\(K\\cdot\\varepsilon\_\{\\text\{dtype\}\}\)for matmul accumulation andO\(N⋅εdtype\)O\(N\\cdot\\varepsilon\_\{\\text\{dtype\}\}\)for reductions\. That upgrade would replace empirical calibration with an operator\-aware error model\. The measurement infrastructure \(the validator’sErrorStatsrecord\) supports it directly\. We leave the model fit to future work\.
## 6Limitations
The calibration is per\-\(op, dtype\) atol only\. A magnitude\-scaled \(atol\+rtol⋅\|r\|\\texttt\{atol\}\+\\texttt\{rtol\}\\cdot\|r\|\) variant would track output magnitude and would likely tighten further on operators whose output range varies across shapes \(matmul, l2norm\)\.
The1\.5×1\.5\\timessafety factor was fixed a priori\. A formal sensitivity sweep across1\.25×1\.25\\timesto2\.0×2\.0\\timesand a leave\-one\-run\-out validation against held\-out runs are noted follow\-ups for a v2 of this paper\.
All data is from a single GPU model \(RTX 3060\)\. Distribution shift across GPU generations, especially across SM\_80 vs SM\_90, is unstudied here\. The companion paper\[[8](https://arxiv.org/html/2607.16228#bib.bib24)\]reports identical verdicts across five GPU classes on the correctness oracle, which suggests the calibration would carry across, but we have not measured the per\-GPU error distribution directly\.
## 7Conclusion
A one\-shot p95\-from\-controls calibration turns hand\-picked per\-op atol from a coarse rule of thumb into a measured envelope\. The calibration uses the error distribution the validator already records on every run\. On the seven paired\-buggy subset of the gpuemu corpus, it recovers9\.39\.3percentage points of bug\-detection recall \(1,805→2,0341\{,\}805\\to 2\{,\}034of2,4672\{,\}467\), at the cost of 20 net new control false positives \(0→200\\to 20of1,8821\{,\}882,\+1\.1\+1\.1pp\)\. The calibration itself runs in seconds against accumulated run records\. The headline tightening factors \(median roughly200×200\\times, up to2,184×2\{,\}184\\timeson attention\_triton fp16\) suggest hand\-picked tolerances across the LLM\-kernel ecosystem are routinely far looser than the operator’s intrinsic error envelope\.
#### Artefact\.
#### License\.
This preprint is released under[CC\-BY 4\.0](https://creativecommons.org/licenses/by/4.0/)\.
## References
- \[1\]S\. Ahmedet al\.\(2022\)What every user should know about mixed precision training in PyTorch\.Note:PyTorch blogUpdated November 2024External Links:[Link](https://pytorch.org/blog/what-every-user-should-know-about-mixed-precision-training-in-pytorch/)Cited by:[§1](https://arxiv.org/html/2607.16228#S1.p1.1),[§2](https://arxiv.org/html/2607.16228#S2.p1.1)\.
- \[2\]Y\. Deng, C\. Yang, A\. Wei, and L\. Zhang\(2022\)Fuzzing deep\-learning libraries via automated relational API inference\.InProc\. 30th ACM Joint Eur\. Softw\. Eng\. Conf\. and Symp\. Found\. Softw\. Eng\. \(ESEC/FSE\),pp\. 44–56\.External Links:[Document](https://dx.doi.org/10.1145/3540250.3549085)Cited by:[§2](https://arxiv.org/html/2607.16228#S2.p3.1)\.
- \[3\]E\. El Arar, S\. Filip, T\. Mary, and E\. Riccietti\(2025\)Mixed precision accumulation for neural network inference guided by componentwise forward error analysis\.arXiv preprint\.External Links:2503\.15568,[Link](https://arxiv.org/abs/2503.15568)Cited by:[§2](https://arxiv.org/html/2607.16228#S2.p1.1),[§2](https://arxiv.org/html/2607.16228#S2.p2.1)\.
- \[4\]Y\. Gao, Q\. Hua, and Z\. Chen\(2026\)V\-ABFT: variance\-based adaptive threshold for fault\-tolerant matrix multiplication in mixed\-precision deep learning\.arXiv preprint\.External Links:2602\.08043,[Link](https://arxiv.org/abs/2602.08043)Cited by:[§2](https://arxiv.org/html/2607.16228#S2.p1.1)\.
- \[5\]D\. Kalamkar, D\. Mudigere, N\. Mellempudi, D\. Das, K\. Banerjee, S\. Avancha, D\. T\. Vooturi, N\. Jammalamadaka, J\. Huang, H\. Yuen, J\. Yang, J\. Park, A\. Heinecke, E\. Georganas, S\. Srinivasan, A\. Kundu, M\. Smelyanskiy, B\. Kaul, and P\. Dubey\(2019\)A study of BFLOAT16 for deep learning training\.arXiv preprint\.External Links:1905\.12322,[Link](https://arxiv.org/abs/1905.12322)Cited by:[§1](https://arxiv.org/html/2607.16228#S1.p1.1),[§2](https://arxiv.org/html/2607.16228#S2.p1.1)\.
- \[6\]A\. Ouyang, S\. Guo, S\. Arora, A\. L\. Zhang, W\. Hu, C\. Ré, and A\. Mirhoseini\(2025\)KernelBench: can LLMs write efficient GPU kernels?\.arXiv preprint\.External Links:2502\.10517,[Link](https://arxiv.org/abs/2502.10517)Cited by:[§1](https://arxiv.org/html/2607.16228#S1.p3.2)\.
- \[7\]D\. Sarkar\(2026\)Test\-input generation for tensor programs: what actually finds kernel bugs\.Note:Manuscript in preparation\. Draft source at[https://github\.com/sarkar\-dipankar/gpuemu\-arxiv\-paper/tree/main/p3](https://github.com/sarkar-dipankar/gpuemu-arxiv-paper/tree/main/p3)\.Cited by:[§5](https://arxiv.org/html/2607.16228#S5.p1.1)\.
- \[8\]D\. Sarkar\(2026\)The correctness illusion in LLM\-generated GPU kernels\.arXiv preprint\.External Links:2606\.20128,[Link](https://arxiv.org/abs/2606.20128)Cited by:[item Too loose\.](https://arxiv.org/html/2607.16228#S1.I1.ix1.p1.1),[item 1](https://arxiv.org/html/2607.16228#S1.I2.i1.p1.1),[§4](https://arxiv.org/html/2607.16228#S4.p1.1),[§6](https://arxiv.org/html/2607.16228#S6.p3.1)\.
- \[9\]J\. Wang, V\. Joshi, S\. Majumder, Xu Chao, B\. Ding, Z\. Liu, P\. P\. Brahma, D\. Li, Z\. Liu, and E\. Barsoum\(2025\)GEAK: introducing Triton kernel AI agent & evaluation benchmarks\.arXiv preprint\.External Links:2507\.23194,[Link](https://arxiv.org/abs/2507.23194)Cited by:[§1](https://arxiv.org/html/2607.16228#S1.p3.2)\.
- \[10\]A\. Wei, Y\. Deng, C\. Yang, and L\. Zhang\(2022\)Free lunch for testing: fuzzing deep\-learning libraries from open source\.InProc\. 44th Int\. Conf\. Software Engineering \(ICSE\),pp\. 995–1007\.External Links:2201\.06589,[Document](https://dx.doi.org/10.1145/3510003.3510041),[Link](https://arxiv.org/abs/2201.06589)Cited by:[§2](https://arxiv.org/html/2607.16228#S2.p3.1)\.
- \[11\]D\. Xie, Y\. Li, M\. Kim, H\. V\. Pham, L\. Tan, X\. Zhang, and M\. W\. Godfrey\(2022\)DocTer: documentation\-guided fuzzing for testing deep learning API functions\.InProc\. 31st ACM SIGSOFT Int\. Symp\. Software Testing and Analysis \(ISSTA\),pp\. 176–188\.External Links:2109\.01002,[Document](https://dx.doi.org/10.1145/3533767.3534220),[Link](https://arxiv.org/abs/2109.01002)Cited by:[§2](https://arxiv.org/html/2607.16228#S2.p3.1)\.
- \[12\]C\. Yang, Y\. Deng, J\. Yao, Y\. Tu, H\. Li, and L\. Zhang\(2023\)Fuzzing automatic differentiation in deep\-learning libraries\.InProc\. 45th Int\. Conf\. Software Engineering \(ICSE\),pp\. 1174–1186\.External Links:2302\.04351,[Document](https://dx.doi.org/10.1109/ICSE48619.2023.00105),[Link](https://arxiv.org/abs/2302.04351)Cited by:[§2](https://arxiv.org/html/2607.16228#S2.p3.1)\.Similar Articles
Conformally Calibrated Adaptive Computation in Neural Operators
This paper applies conformal calibration to adaptively select Fourier modes or channel width per input in neural operators, finding that while adaptive computation controls error, it often fails to reduce complete runtime compared to matched static baselines.
Neural means and kernel corrections for operator learning
This paper presents a method combining neural network means with exact Matérn kernel corrections for operator learning in PDEs, achieving competitive or improved performance on public benchmarks like structural mechanics and OCO-2 radiative transfer emulation.
MetaKernelBench: Measuring GPU Kernel Knowledge Transfer Beyond Code
MetaKernelBench introduces a benchmark measuring whether experience distilled by GPU kernel optimization agents in one DSL (CuTeDSL) transfers to another (TIRx) on the same problem, finding mixed results with lift ranging from -19% to +29% across six models.
Training-Inference Kernel Contracts: Bounding Divergence in Post-Training and Deployment
This paper formalizes the numerical divergence between training and inference kernels in modern AI post-training pipelines, proposing a kernel contract specification and a chain of Lipschitz-style bounds to mitigate off-policy bias, slice-level regressions, and reproducibility issues.
Temperature Scaling Is Not Enough: Calibration Gaps Under Human Label Distributions
This paper investigates the calibration gap that arises when temperature scaling, a common post-hoc calibration method relying on one-hot labels, is applied to models trained with soft label distributions reflecting genuine human disagreement. Experiments across vision and language domains show that temperature scaling calibrated on hard labels consistently underperforms direct soft-label calibration, with larger gaps in language tasks, highlighting risks for safety-critical deployments.