You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running bfloat16 models, such as Muse Glimmer, natively through ET-VK. This stack adds the bfloat16 dtype and the elementwise operators that exercise it. This commit teaches shader codegen about bfloat16.
Rationale
What: Shader YAML can set DTYPE: bfloat16. The generated shader stores such tensors as bfloat16_t / bf16vec4 (GL_EXT_bfloat16), computes in fp32, and rounds every conversion to bfloat16 to nearest even.
Why: There is no bfloat16 image format and GLSL allows no arithmetic on bfloat16, so bfloat16 needs its own type mapping. Some drivers truncate fp32 to bfloat16 conversions; NVIDIA driver 580 does so even when the shader requests the SPIR-V RoundingModeRTE execution mode.
Details
Buffer types are bfloat16_t / bf16vecN; texel and compute types are float / vec4. GLSL forbids implicit conversion to bfloat16, so a shader that forgets to widen fails to compile.
For bfloat16, the extension helpers emit GL_EXT_bfloat16 and round_to_bf16. Macros route the single-argument bfloat16_t and bf16vec4 constructors through round_to_bf16, which rounds the fp32 bit pattern to nearest even and keeps NaNs quiet, so a NaN payload in the dropped bits cannot truncate to infinity. This mirrors the existing rounding of rgba16f image stores. Other conversions, such as to bf16vec2, are not rounded; no shader uses them.
Variants that pair DTYPE: bfloat16 with texture storage in any *STORAGE parameter are skipped, so a shader with several storage parameters, such as STORAGE and WEIGHT_STORAGE, keeps only all-buffer bfloat16 variants.
get_higher_precision_dtype ranks bfloat16 with half. Neither represents the other, so a half and bfloat16 pair gives float.
No shader uses bfloat16 yet, so the generated shaders are unchanged.
This comment was automatically generated by Dr. CI and updates every 15 minutes.
meta-claBot
added
the
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
label
Nov 18, 2026
If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.
To add a label, you can comment to pytorchbot, for example @pytorchbot label "release notes: none"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CLA SignedThis label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.meta-exported
1 participant
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack from ghstack (oldest at bottom):
Ulterior Motive
Running bfloat16 models, such as Muse Glimmer, natively through ET-VK. This stack adds the bfloat16 dtype and the elementwise operators that exercise it. This commit teaches shader codegen about bfloat16.
Rationale
What: Shader YAML can set
DTYPE: bfloat16. The generated shader stores such tensors asbfloat16_t/bf16vec4(GL_EXT_bfloat16), computes in fp32, and rounds every conversion to bfloat16 to nearest even.Why: There is no bfloat16 image format and GLSL allows no arithmetic on bfloat16, so bfloat16 needs its own type mapping. Some drivers truncate fp32 to bfloat16 conversions; NVIDIA driver 580 does so even when the shader requests the SPIR-V
RoundingModeRTEexecution mode.Details
bfloat16_t/bf16vecN; texel and compute types arefloat/vec4. GLSL forbids implicit conversion to bfloat16, so a shader that forgets to widen fails to compile.GL_EXT_bfloat16andround_to_bf16. Macros route the single-argumentbfloat16_tandbf16vec4constructors throughround_to_bf16, which rounds the fp32 bit pattern to nearest even and keeps NaNs quiet, so a NaN payload in the dropped bits cannot truncate to infinity. This mirrors the existing rounding of rgba16f image stores. Other conversions, such as tobf16vec2, are not rounded; no shader uses them.DTYPE: bfloat16with texture storage in any*STORAGEparameter are skipped, so a shader with several storage parameters, such asSTORAGEandWEIGHT_STORAGE, keeps only all-buffer bfloat16 variants.get_higher_precision_dtyperanks bfloat16 with half. Neither represents the other, so a half and bfloat16 pair gives float.Authored with Claude Code.
Differential Revision: D132361766