You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NKI: ScalarE activation rsqrt error on Trn2 reaches ~349,000 ULP (2.9% relative) inside its documented range; documented bound is 40,000 ULP #1501
Summary: on Trn2 (NeuronCore-v3), ScalarE nisa.activation(op=nl.rsqrt) reaches a maximum error of 348,900 ULP, 2.9% relative, for inputs inside its documented valid range [2⁻⁸⁷, 2⁹⁷]. The NKI API "Supported Activation Functions" table documents a bound of 40,000 ULP.
The p99.9 error is about 2.8e5 ULP, so the errors are spread across the range, not confined to its edges. The same probe measured:
ScalarE sqrt: 65,520 ULP max, within the documented 65,536;
ScalarE log: 396 ULP away from x = 1, against the documented 40, and 8,445 ULP near x = 1, where log x → 0 inflates the relative error;
ScalarE exp and reciprocal: 22 and 122 ULP, both better than the documented 400.
Environment: trn2.3xlarge, Deep Learning AMI Neuron torch-neuronx 2.14.0 (Ubuntu 24.04) SDK 2.33.1, neuronx-cc 2.28.7631, nki 0.7.0, runtime 2.35.33, LNC=2.
Method:
262,144 fp32 inputs, log-uniform over [2⁻⁸⁷, 2⁹⁷], laid out as a [128, 2048] SBUF tile;
nisa.activation(dst=r, op=nl.rsqrt, data=x);
ULP error measured against the fp64 result rounded to fp32.
The probe is open source: scripts/probe_lut_ulp.py in trnsci/trnblas#134. Its full table also covers the GpSimd and VectorE alternatives. GpSimd tensor_scalar(op0=rsqrt) and GpSimd tensor_tensor(op=power) are ≤ 1 ULP, and VectorE nisa.reciprocal is correctly rounded.
I ran the minimal reproduction above as written on the same trn2.3xlarge (SDK 2.33.1). It prints 348703.0 186587.39 0.029394751: max ULP, p99.9 ULP and max relative error. The p99.9 for this input set is 1.87e5. The 2.8e5 in the description came from the full probe's input distribution; the max and relative error match.
Correction to the description (measured per input range, same box and toolchain): the large errors are concentrated at the extremes of the documented range, not spread across it. My p99.9 figure was inflated by log-uniform sampling of a very wide range. ScalarE activation rsqrt, max ULP / max relative error per input band (262,144 log-uniform inputs per band):
input band
max ULP
p99.9 ULP
max rel err
[2⁻⁸⁷, 2⁻⁶⁴]
349,157
296,517
2.94e-2
[2⁻⁶⁴, 2⁻⁵²]
10,904
10,584
6.5e-4
[2⁻⁵², 2⁻³²]
10,860
10,383
6.5e-4
[2⁻³², 2³²]
7
7
4.5e-7
[2³², 2⁵²]
1,044
953
6.5e-5
[2⁵², 2⁸⁰]
21,408
20,708
1.35e-3
[2⁸⁰, 2⁹⁷]
32,878
26,169
2.08e-3
So the documented 40,000-ULP bound is exceeded only in [2⁻⁸⁷, 2⁻⁶⁴]. The function is accurate (7 ULP) over [2⁻³², 2³²]. The ask becomes:
correct the bound, or narrow the documented valid range for v3 (e.g. state the bound per sub-range, or start the valid range at 2⁻⁶⁴);
ideally publish the per-range accuracy for the other LUT functions.
A sibling measurement for ScalarE sqrt shows the same pattern: 8.4e-7 over [2⁻⁵², 2⁵²], degrading toward both ends.
Activity
scttfrdmn commentedon Nov 24, 2026
I ran the minimal reproduction above as written on the same trn2.3xlarge (SDK 2.33.1). It prints
348703.0 186587.39 0.029394751: max ULP, p99.9 ULP and max relative error. The p99.9 for this input set is 1.87e5. The 2.8e5 in the description came from the full probe's input distribution; the max and relative error match.github-actions commentedon Nov 24, 2026
Hi @scttfrdmn, Thank you for filing the issue! We will take a look and get back to you.
scttfrdmn commentedon Nov 25, 2026
Correction to the description (measured per input range, same box and toolchain): the large errors are concentrated at the extremes of the documented range, not spread across it. My p99.9 figure was inflated by log-uniform sampling of a very wide range. ScalarE
activationrsqrt, max ULP / max relative error per input band (262,144 log-uniform inputs per band):So the documented 40,000-ULP bound is exceeded only in [2⁻⁸⁷, 2⁻⁶⁴]. The function is accurate (7 ULP) over [2⁻³², 2³²]. The ask becomes:
A sibling measurement for ScalarE sqrt shows the same pattern: 8.4e-7 over [2⁻⁵², 2⁵²], degrading toward both ends.