Skip to content
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

[docs] Clarify that Float16 is supported natively when possible #57725

Merged
merged 4 commits into from
Mar 15, 2025

Conversation

giordano
Copy link
Contributor

@giordano giordano commented Mar 11, 2025

@giordano giordano added docs This change adds or pertains to documentation float16 backport 1.10 Change should be backported to the 1.10 release backport 1.11 Change should be backported to release-1.11 backport 1.12 Change should be backported to release-1.12 labels Mar 11, 2025
@@ -334,8 +334,7 @@ julia> typeof(x)
Float64
```

Half-precision floating-point numbers are also supported ([`Float16`](@ref)), but they are
implemented in software and use [`Float32`](@ref) for calculations.
Half-precision floating-point numbers are also supported ([`Float16`](@ref)) on all platforms, with native instructions used on hardware which supports this number format, otherwise operations are implemented in software and use [`Float32`](@ref) for intermediate calculations.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe point out that this equivalent to gcc -fexcess-precision=ieee

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I presume you meant -fexcess-precision=standard?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we actually implement -fexcess-precision=16 https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-fexcess-precision

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On x86 targets with SSE2 enabled, without -mavx512fp16, all operations will be emulated by software emulation and the float instructions. The default behavior for FLT_EVAL_METHOD is to keep the intermediate result of the operation as 32-bit precision. This may lead to inconsistent behavior between software emulation and AVX512-FP16 instructions. Using -fexcess-precision=16 will force round back after each operation.

Yeah we force round back after each operation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We techically just do the LLVM default nowadays, the demote float16 pass is basically unused since #55486

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I tried to incorporate both comments above, explaining this is an implementation detail (but I think some non-Julia people reading the manual may be interested in knowing it)

@gbaraldi
Copy link
Member

LGTM

Co-authored-by: Jishnu Bhattacharya <jishnub.github@gmail.com>
@giordano giordano merged commit 3e57a8a into master Mar 15, 2025
7 checks passed
@giordano giordano deleted the giordano-patch-1 branch March 15, 2025 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 1.10 Change should be backported to the 1.10 release backport 1.11 Change should be backported to release-1.11 backport 1.12 Change should be backported to release-1.12 docs This change adds or pertains to documentation float16
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants