f16b Primitive Type
| Metadata | |
|---|---|
| Point of contact | James |
| Status | Proposed |
| compiler champion | David Wood |
| lang champion | Tyler Mandry |
| Teams | compiler, lang |
| Task owners | (none) |
Arm’s Rust team is David Wood, Adam Gemmell, Rémy Rakic and James. This goal will be primarily worked on by James
Summary
Implementation of a f16b type in core::num for the 16-bit
Brain Floating Point format.
Motivation
A first-class f16b type for the is primarily useful for target-specific SIMD and
Matrix APIs. It is also useful where memory bandwidth, storage size, and vector
throughput matter more than decimal precision. The main use case is machine
learning and AI workloads, where values are often stored or multiplied in
f16b while accumulation happens in wider precision.
b16 is increasingly found in hardware across multiple architecutues such as
AArch64 Neoverse N2, x86_64 Cooper Lake and
RISC-V. All offering a level of native support for scalar and vector
operations with discoverability through target-feature mechanisms.
The status quo
Presently bf16 is present through wrapper types over a u16 with adhoc
lowering rules. Using a u16 preserves the raw bits, but it loses the meaning
of the value. It also cannot use the usual floating-point surface of the
language, such as casts, literals, constants, formatting, arithmetic traits,
or generic bounds over floating-point types.
As such, workarounds are required to use a bf16 type today.
rust-lang/rust#140763 is an example of the current workaround: it adds
temporary codegen bypasses so Rust signatures using i16 / i16xN can call
LLVM intrinsics whose real signatures use bf16 / bf16xN.
What we propose to do about it
We propose a f16b type in core::num that can be used across architectures
for FFI and with target-specific intrinsics.
This goal does not propose to make it a general-purpose arithmetic type, so does not propose portable rust operations, portable library methods, etc.
Work items over the next year
| Task | Owner(s) | Notes |
|---|---|---|
| Draft RFC | Jamesbarford | |
| Resolve feedback on the RFC | Jamesbarford | |
Approval for an experiement behind a !feature(f16b) | Jamesbarford | |
| Implement experiment | Jamesbarford | |
| Stabilisation concerns | Jamesbarford | |
| Write documentation, references and limitations | Jamesbarford | |
| Stabilise | Jamesbarford |
Team asks
| Team | Support level | Notes |
|---|---|---|
| lang | Medium | Review of RFC |
| compiler | Medium | PR Reviews, both of the RFC and of the subsequent implementation work |
Funding
The f16b is being worked on by the Rust team at Arm and the goal owners have
sufficient capacity to do the work.
Frequently asked questions
- What does the
binf16bmean? Thebstands forbrain