-
Notifications
You must be signed in to change notification settings - Fork 339
Widen tanh acceptable range (output values) #5199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Widen tanh acceptable range (output values) #5199
Conversation
Previews, as seen when this build job started (b4f9a70): |
Assuming this pr gets approved this pull is waiting in the wings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please attach images of the errors you found for the NVIDIA and Intel devices.
This spec change will need approval by the WG, but I think the CTS change should land sooner.
I evaluated the precision of existing webgpu tanh on nvidia (hlsl) and intel (vulkan) Here is the data shared via sheets (chromium account) |
Waiting on |
I'm fine with this change to the spec. I just wanted to note what I assume is the history here, which is pretty funny:
|
Unlike the standard trig functions which may be implemented as natural calculations or as hyperbolic aproximations, the hyperbolic functions are guaranteed to be hyperbolc aproximations and thus have consistent precision characteristics. These can all be guaranteed within 2 ULP, which gives a better match and will resolve the test failures on AMD GPUs. The `cosh.16` test is not updated in this PR because it is already using ULP rules and 2 ULP range specification. I've captured a spec issue to follow up on the very wide range requirements for `tanh` on NVIDIA GPUs: microsoft/hlsl-specs#601 This issue has also been observed by WGSL and is reflected in their spec: gpuweb/gpuweb#5199 Fixes #326
GPU Web WG 2025-07-30 Atlantic-time
|
After a bit of investigation it has been determined that tanh has a max Absolute error of 1e-5 for some devices (nvidia)
We discussed polyfilling this function (sinh/cosh) but this inaccuracy is likely intentional as tanh is commonly used in sigmoid functions for ML.
crbug.com/390221422