Repository navigation
Open
Description
-inf E!33222222222222222222222222222222222222222222222221111111111111111111111111111111111111111111222333!
-3e35 EEE!3322221111111111111111111111111111111111111111111111111111111111111111111111111111111111122333333
-3e32 EEEEE!33222222222222222222222222222222222222222222211111111111111111111111111111111111111122233223321
-3e29 EEEEEEE!332222222222222222222222222222222222222222211111111111111111111111111111111111112223332!32121
-3e26 EEEEEEEEE!3322222222222222222222222222222222222222211111111111111111111111111111111111122233333212121
-3e23 EEEEEEEEEEE!33222222222222222222222222222222222222211111111111111111111111111111111122232322222222111
-3e20 EEEEEEEEEEEEE!332222111111111111111111111111111111111111111111111111111111111111111222333322112222121
-3e17 EEEEEEEEEEEEEEE!3322222222222222222222222222222222211111111111111111111111111111222332333321222122122
-3e14 EEEEEEEEEEEEEEEEE!33222222222222222222222222222222211111111111111111111111111112223333322111221222112
-3e11 EEEEEEEEEEEEEEEEEEE!332222222222222222222222222222211111111111111111111111111223333322222222221222122
-2e8 EEEEEEEEEEEEEEEEEEEE!!3322211111111111111111111111111111111111111111111111222333333222212222111122122
-2e5 EEEEEEEEEEEEEEEEEEEEEEE!32222222222222222222222222211111111111111111111112223332332211222221222212112
-2e2 EEEEEEEEEEEEEEEEEEEEEEEE!!32222222222222222222222221111111111111111111122333333221221221212211122222E
-2e-1 EEEEEEEEEEEEEEEEEEEEEEEEEEE!3322222222222222222222211111111111111111222233333211222112211111221112EEE
-2e-4 EEEEEEEEEEEEEEEEEEEEEEEEEEEEE!232222222222222222222111111111111111222223333222222221211221212212EEEEE
-2e-7 EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE!!32222222222222222221111111111111222232333221212212112122212222EEEEEEE
-2e-10 EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE!!3322222222222222211111111111222223333222212222222212222122EEEEEEEEE
-2e-13 EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE!!332222222222222111111111122222332211222222221222122122EEEEEEEEEEE
-2e-16 EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE!!33222111111111111111122333333212121122221112211222EEEEEEEEEEEEE
-2e-19 EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE!!3222222222211111122232333221211111222212211111EEEEEEEEEEEEEEE
-2e-22 EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE!!322222222111122323333221122112112222221222EEEEEEEEEEEEE====
-2e-25 EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE!!32222221222233333211222222122111222222EEEEEEEEEEE========
-2e-28 EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE!!2222222223333322222122211211222222EEEEEEEEE============
-2e-31 EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE!!33!233323222212222221211222221EEEEEEE================
-1e-34 EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE!!E3333222211112122211222221EEEEE====================
-1e-37 EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE========================
1e-37 EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE!!E3333211122222221212122122EEEEE====================
1e-34 EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE!22E223333221122222121222212122EEEEEEE================
2e-31 EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE!!3222222233333222122212121121222112EEEEEEEEE============
2e-28 EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE!!22222221122323333222211212112222211212EEEEEEEEEEE========
2e-25 EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE!!322222222111122333333212222122122121112222EEEEEEEEEEEEE====
2e-22 EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE!!3222222222211111222223333211121222222221221111EEEEEEEEEEEEEEE
2e-19 EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE!!33222222222221111111222322333222221221222222221221EEEEEEEEEEEEE
2e-16 EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE!332222222222222111111111122223333212112211222121222112EEEEEEEEEEE
2e-13 EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE!2222222222222222211111111111222233333211122112222112211222EEEEEEEEE
2e-10 EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE!332222222222222222211111111111112223!3333211222112112111222222EEEEEEE
2e-7 EEEEEEEEEEEEEEEEEEEEEEEEEEEEE!332222222222222222222111111111111111222332333121222222222112221122EEEEE
2e-4 EEEEEEEEEEEEEEEEEEEEEEEEEEE!3322222222222222222222211111111111111111122332322222222122222221111222EEE
2e-1 EEEEEEEEEEEEEEEEEEEEEEEEE!32222222222222222222222221111111111111111111222222333221211222212121112222E
3e2 EEEEEEEEEEEEEEEEEEEEEEE!33222222222222222222222222211111111111111111111112223233322121211221222212111
3e5 EEEEEEEEEEEEEEEEEEEEE!3222111111111111111111111111111111111111111111111111122232332222222212221221221
3e8 EEEEEEEEEEEEEEEEEEE!322222222222222222222222222222211111111111111111111111111222333332221222222222212
3e11 EEEEEEEEEEEEEEEEE!33222222222222222222222222222222211111111111111111111111111122223233221222221222221
3e14 EEEEEEEEEEEEEEE!2222222222222222222222222222222222211111111111111111111111111111222322322221221222222
4e17 EEEEEEEEEEEEE!332222222222222222222222222222222222211111111111111111111111111111111222223332121122122
4e20 EEEEEEEEEEE!33222222222222222222222222222222222222211111111111111111111111111111111122233333221122112
4e23 EEEEEEEEE!2322222222222222222222222222222222222222211111111111111111111111111111111111222333333222222
4e26 EEEEEEE!3322222222222222222222222222222222222222222111111111111111111111111111111111111112233!2332122
4e29 EEEEE!33222222222222222222222222222222222222222222211111111111111111111111111111111111111122233333312
5e32 EEE!3322222222222222222222222222222222222222222222211111111111111111111111111111111111111111222332!32
5e35 E!332222222222222222222222222222222222222222222222211111111111111111111111111111111111111111112223333
-inf -3e29 -2e20 -1e11 -1e2 -8e-8 -6e-1 -4e-2 -3e-3 1e-33 1e-24 2e-15 3e-6 4e3 5e12 8e21 1e31
| ULP-difference | z | jax:sqrt(z) | mpmath:sqrt(z) | numpy:sqrt(z) |
|---|---|---|---|---|
| 2776169144 | (-2.5428434e+38-7.351875e+30j) | (-697034700000-1.5946295e+19j) | (230519850000-1.5946295e+19j) | (230519850000-1.5946295e+19j) |
| 2775681077 | (-2.5428434e+38+7.096847e+30j) | (-697034700000+1.5946295e+19j) | (222523360000+1.5946295e+19j) | (222523380000+1.5946295e+19j) |
| 2738163479 | (-1.03440016e+37-3.0757338e+29j) | (-140584980000-3.2162092e+18j) | (47816135000-3.2162092e+18j) | (47816135000-3.2162092e+18j) |
| 2738152442 | (-2.0803932e+37-3.0757338e+29j) | (-199373440000-4.5611327e+18j) | (33716775000-4.5611327e+18j) | (33716777000-4.5611327e+18j) |
| 2737853831 | (-2.9728335e+38+2.9819733e+29j) | (-753667700000+1.7241907e+19j) | (8647458000+1.7241907e+19j) | (8647458000+1.7241907e+19j) |
| 2737807613 | (-1.03440016e+37+2.9819733e+29j) | (-140584980000+3.2162092e+18j) | (46358508000+3.2162092e+18j) | (46358508000+3.2162092e+18j) |
| 2696201819 | (-3.1419312e+35-9.563026e+27j) | (-24501514000-5.605293e+17j) | (8530352600-5.605293e+17j) | (8530353000-5.605293e+17j) |
| 2695606269 | (-3.1419312e+35+9.221191e+27j) | (-24501514000+5.605293e+17j) | (8225431000+5.605293e+17j) | (8225431600+5.605293e+17j) |
| 2654230250 | (-3.859487e+34-2.973245e+26j) | (-8587354600-1.9645577e+17j) | (756721200-1.9645577e+17j) | (756721200-1.9645577e+17j) |
| 2654201544 | (-9.535506e+33-2.973245e+26j) | (-4268413200-9.764991e+16j) | (1522400100-9.764991e+16j) | (1522400300-9.764991e+16j) |
| 2654194257 | (-6.3200903e+35-2.973245e+26j) | (-34750110000-7.949899e+17j) | (186998900-7.949899e+17j) | (186998910-7.949899e+17j) |
| 2654145114 | (-2.9728335e+38-2.973245e+26j) | (-753667700000-1.7241907e+19j) | (8622146-1.7241907e+19j) | (8622146-1.7241907e+19j) |
| 2653744756 | (-3.859487e+34+2.851161e+26j) | (-8587354600+1.9645577e+17j) | (725649600+1.9645577e+17j) | (725649600+1.9645577e+17j) |
| 2653736471 | (-1.8116494e+37+2.851161e+26j) | (-186050850000+4.2563475e+18j) | (33493048+4.2563475e+18j) | (33493048+4.2563475e+18j) |
| 2653733019 | (-4.4711593e+36+2.851161e+26j) | (-92428240000+2.1145116e+18j) | (67418904+2.1145116e+18j) | (67418904+2.1145116e+18j) |
| 2653713177 | (-9.535506e+33+2.851161e+26j) | (-4268413200+9.764991e+16j) | (1459889200+9.764991e+16j) | (1459889200+9.764991e+16j) |
| 2611504461 | (-2.8913991e+32+8.8146873e+24j) | (-743273500+1.7004115e+16j) | (259192780+1.7004115e+16j) | (259192770+1.7004115e+16j) |
| 2607982269 | (-2.4813286e+32-6.8212866e+24j) | (-688552000-1.5752234e+16j) | (216518080-1.5752234e+16j) | (216518060-1.5752234e+16j) |
| 2570223272 | (-3.859487e+34-2.8738707e+23j) | (-8587354600-1.9645577e+17j) | (731429.44-1.9645577e+17j) | (731429.44-1.9645577e+17j) |
| 2570220601 | (-1.1707111e+33-2.8738707e+23j) | (-1495613800-3.4215655e+16j) | (4199643-3.4215655e+16j) | (4199643-3.4215655e+16j) |
| ... | ... | ... | ... | ... |
Metadata
Metadata
Assignees
Labels
No labels
Activity
pearu commentedon Dec 21, 2024
#79 implements complex sqrt algorithm.
Add complex_sqrt_polar as a reproducer to issue #53
Add complex_sqrt_polar as a reproducer to issue #53 (#81)
pearu commentedon Dec 22, 2024
The origin of errors reported in the description is
https://github.com/openxla/xla/blob/dc7aaf834a0bb5a543f6cf98626284783a4a921c/xla/service/elemental_ir_emitter.cc#L2315
that implements complex sqrt in polar form.
As a reproducer, #81 provides
complex_sqrt_polarthat when enabled, produces the same accuracy pattern as given in the description:Details
The PR #79 provides a more accurate algorithm for complex
sqrtfunction that has the following accuracy pattern:pearu commentedon Dec 28, 2024
With https://github.com/pearu/stablehlo/tree/pearu/sqrt and applying the following patch to XLA:
the accuracy pattern of JAX sqrt with CPU platform is:
The accuracy pattern of JAX sqrt with CUDA platform is
Details
pearu commentedon Dec 28, 2024
The difference of JAX complex sqrt on CUDA and CPU samples could be explained by the fact that
JAX real sqrt on CUDA samples is less accurate than on CPU samples: the maximal ULP difference for CPU samples is 0 while for CUDA samples we have:
pearu commentedon Dec 28, 2024
Applying a single Newton iteration improves the accuracy of JAX sqrt on CUDA inputs:
but this may diverge the result from reference value for other samples.
pearu commentedon Dec 28, 2024
Read also https://docs.nvidia.com/cuda/floating-point/index.html that explains the reasons for platform dependent results.
pearu commentedon Dec 29, 2024
cref: openxla/stablehlo#2679