Skip to content

Add low-precision floating point data types explainer - #938

Merged
huningxin merged 3 commits into
webmachinelearning:mainfrom
mklimenko-nv:low-precision-fp
Oct 12, 2026
Merged

huningxin merged 3 commits into
webmachinelearning:mainfrom
mklimenko-nv:low-precision-fp

Conversation

@mklimenko-nv

Copy link
Copy Markdown
Contributor

This PR is a first step to add low-precision floating point data types to the WebNN specification. It's a follow-up to #930 with a conservative addition of bfloat16 and float8 types only, with a potential follow-up for microscaled data types.

@fdwr fdwr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Tis a nice document, thanks for preparing, and I support adding low precision data types (I may just have "are we sure xyz" questions 馃檪).

Comment thread low-precision-data-types-explainer.md Outdated
Comment thread low-precision-data-types-explainer.md Outdated
Comment thread low-precision-data-types-explainer.md Outdated
Comment thread low-precision-data-types-explainer.md Outdated
Comment thread low-precision-data-types-explainer.md Outdated
Comment thread low-precision-data-types-explainer.md Outdated
@anssiko

anssiko commented Aug 24, 2026

Copy link
Copy Markdown
Member

I observe general support and no concerns, see also meeting minutes.

@mklimenko-nv, any pending changes you'd still like to integrate into this v1 PR? Otherwise, editors are free to merge this by our next meeting.

@mklimenko-nv

Copy link
Copy Markdown
Contributor Author

@anssiko, I've made some minor modifications to the explainer based on the discussion above (thanks @fdwr!).

@anssiko

anssiko commented Sep 7, 2026

Copy link
Copy Markdown
Member

@mklimenko-nv thank you, it looks like all feedback has been addressed. The editor are free to merge this explainer PR.

@mklimenko-nv are you interested in taking the first stab at the spec PR for this?

@mklimenko-nv

Copy link
Copy Markdown
Contributor Author

@anssiko, yeah, sounds good to me, let me prepare a spec PR for this. Thanks!

@fdwr fdwr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

馃憤

@huningxin huningxin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM with a nit

Comment thread low-precision-data-types-explainer.md Outdated
We propose extending the MLOperandDataType enum and define, how these types interact with typed arrays, since JavaScript lacks native `bfloat16` and `float8` arrays.

### 1. Extend MLOperandDataType
```javascript

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Label the IDL snippet as idl or webidl?

Comment thread low-precision-data-types-explainer.md Outdated
Currently, buffer validation checks that the `ArrayBufferView`'s type matches the operand's data type exactly. There is already precedent for relaxing this: before `Float16Array` existed, `float16` operands accepted a `Uint16Array` as the underlying storage. Following the same pattern, `bfloat16` and `float8e4m3` operands would accept `Uint16Array` and `Uint8Array` respectively as type-punned storage. The validation algorithm needs to be updated to allow this substitution while still validating that the buffer's element count and byte length match the operand's shape and per-element size.

## Data types and Q/DQ nodes handling
Due to a significant variety of hardware available to users, spanning across multiple generations, it is expected that some data types could be unsupported. WebNN delegates the graph execution to the underlying framework (like DirectML, CoreML, Windows ML).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Mention LiteRT instead of DirectML, which is consistent with the explainer: https://github.com/webmachinelearning/webnn/blob/main/explainer.md?plain=1#L44

@fdwr fdwr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

馃憤

@huningxin huningxin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@huningxin
huningxin merged commit 5a51c0c into webmachinelearning:main Oct 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants