Skip to content

[SYCL][libdevice] return qNaN for (float/double)sNaN to bfloat16 conversion - #23084

Merged
KornevNikita merged 1 commit into
intel:syclfrom
Maetveis:libdevice-float-to-bfloat-snan
Sep 4, 2026
Merged

[SYCL][libdevice] return qNaN for (float/double)sNaN to bfloat16 conversion#23084
KornevNikita merged 1 commit into
intel:syclfrom
Maetveis:libdevice-float-to-bfloat-snan

Conversation

@Maetveis

@Maetveis Maetveis commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

#22114 introduced a fix to return NaN for some specific float or double sNaN bit patterns when converting to bfloat16.
Together with that change it also changed the behavior and added a test specifically for the case of converting sNaN to bfloat16. The new behaviour in that PR is to return sNaN for all sNaN inputs.

This is not the correct behaviour, IEEE 754 specifies conversions should signal and then return a quiet NaN. We do not implement raising exceptions in the device library, so we cannot signal, but we should still return a quiet NaN for all sNaN inputs.
The new behaviour matches the host conversion (from glibc/compiler-rt), see this example on compiler explorer: https://godbolt.org/z/E7ezaPxEd (assisted by Claude Opus 5 noreply@anthropic.com).

…ersion

intel#22114 introduced a fix to return
NaN for some specific float or double sNaN bit patterns when converting
to bfloat16.
Together with that change it also changed the behavior and added a test
specifically for the case of converting sNaN to bfloat16. The new
behaviour in that PR is to return sNaN for all sNaN inputs.

This is not the correct behaviour, IEEE 754 specifies conversions should
signal and then return a quiet NaN. We do not implement raising exceptions
in the device library, so we cannot signal, but we should still return
a quiet NaN for all sNaN inputs.
The new behaviour matches the host conversion (from glibc/compiler-rt),
see this example on compiler explorer: https://godbolt.org/z/E7ezaPxEd
(assisted by Claude Opus 5 <noreply@anthropic.com>).
@Maetveis
Maetveis requested a review from a team as a code owner September 2, 2026 09:42
Comment thread sycl/test-e2e/DeviceLib/imf/double2bfloat16.cpp
@Maetveis

Maetveis commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

I believe the L0 Windows Arc GPU failure is unrelated, I see it on other workflow runs too. Reported to: #23100

@Maetveis

Maetveis commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

@intel/llvm-gatekeepers I believe this can be merged :)

@KornevNikita
KornevNikita merged commit bf6137c into intel:sycl Sep 4, 2026
56 of 64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants