Skip to content

[SM6.10] Add BFloat16 Support - #8734

Merged
Ashley Coleman (V-FEXrt) merged 3 commits into
microsoft:mainfrom
V-FEXrt:linalg-bfloat16
Aug 5, 2026
Merged

[SM6.10] Add BFloat16 Support#8734
Ashley Coleman (V-FEXrt) merged 3 commits into
microsoft:mainfrom
V-FEXrt:linalg-bfloat16

Conversation

@V-FEXrt

Copy link
Copy Markdown
Collaborator

Fixes #8722

microsoft/hlsl-specs#907 added BFloat16 as an allowed ComponentType in the LinAlg API. This PR adds support for it to the implementation.

Copilot AI balanced review requested due to automatic review settings August 4, 2026 18:13
@V-FEXrt
Ashley Coleman (V-FEXrt) requested review from Chris B (llvm-beanz) and removed request for Copilot August 4, 2026 18:13
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

✅ With the latest revision this PR passed the C/C++ code formatter.

Copilot AI balanced review requested due to automatic review settings August 4, 2026 18:27

Copilot AI 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.

Pull request overview

Adds BFloat16 support to the Shader Model 6.10 LinAlg API and DXIL validation.

Changes:

  • Defines and exposes the BFloat16 component type.
  • Adds packed two-per-uint type traits.
  • Allows BFloat16 matrices in validation and serialization.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
include/dxc/DXIL/DxilConstants.h Defines the DXIL component value.
include/dxc/DxilContainer/RDAT_LibraryTypes.inl Adds RDAT enum serialization.
lib/DxilValidation/DxilValidation.cpp Permits BFloat16 LinAlg matrices.
lib/DxilValidation/DxilValidationUtils.cpp Formats the component name.
tools/clang/lib/Headers/hlsl/dx/linalg.h Exposes BFloat16 and its packing traits.
tools/clang/lib/Sema/SemaHLSL.cpp Adds Sema string conversion.
tools/clang/test/LitDXILValidation/LinAlgMatrix/linalgmatrix-illegal-component-type.ll Verifies validator acceptance.
Suppressed comments (1)

tools/clang/lib/Headers/hlsl/dx/linalg.h:143

  • Marking BFloat16 as non-native invalidates the Matrix class comment at lines 241-242, which says every non-native scalar is an 8-bit type with four elements per scalar. Update that comment to describe packed component types generically (or explicitly include the two-BFloat16 case) so it matches this specialization.
  static const bool IsNativeScalar = false;
  static const uint ElementsPerScalar = 2;

Comment thread include/dxc/DXIL/DxilConstants.h
Comment thread tools/clang/lib/Headers/hlsl/dx/linalg.h
PackedU8x32 = 18,

// BEGIN NEW FOR SM 6.10
// BEGIN NEW FOR SM 6.9

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We didn't ship linalg.h for SM 6.9 did we?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Nope, but we shipped the type in DxilConstants.h in SM6.9!

I updated this here because the header says this type needs to exactly match the DxilConstants.h type

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We could update the type in DxilConstants.h to say "new for 6.10" which would be fine by me but not wholly accurate (I don't think the new types could actually be used for anything even though they are published in 6.9)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🤷

@damyanp Damyan Pepper (damyanp) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Copilot AI 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.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

Suppressed comments (1)

include/dxc/DXIL/DxilConstants.h:203

  • This adds a user-visible Shader Model 6.10 feature, so it needs an entry under Experimental Shader Model 6.10 in docs/ReleaseNotes.md per the release-note policy in CONTRIBUTING.md. Please add the release note (or point to the related PR that will provide the shared coverage).
  BFloat16 = 23,

Copilot AI review requested due to automatic review settings August 4, 2026 22:22

Copilot AI 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.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

Suppressed comments (2)

docs/ReleaseNotes.md:45

  • BFloat16 is gated to experimental SM 6.10, but this entry is under Upcoming Release, which makes it appear to ship in the next non-preview release. Move it under Upcoming Preview ReleaseExperimental Shader Model 6.10 (and match the surrounding past-tense, period-terminated style).
#### LinAlg Matrix
- Adds `BFloat16` to the ComponentType enum in DxilConstants and the linalg
  header [#8722](https://github.com/microsoft/DirectXShaderCompiler/issues/8722)

tools/clang/lib/Headers/hlsl/dx/linalg.h:143

  • This specialization makes a non-native component contain two values per scalar, so the Matrix comment at lines 241–242 (“we have an 8-bit type” and “4 elements”) is now false for BFloat16. Please generalize that comment to describe packed/non-native component types and use ElementsPerScalar rather than asserting the 8-bit layout.
template <> struct ComponentTypeTraits<ComponentType::BFloat16> {
  using Type = uint;
  static const bool IsNativeScalar = false;
  static const uint ElementsPerScalar = 2;

Copilot AI review requested due to automatic review settings August 4, 2026 22:37

Copilot AI 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.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

@V-FEXrt
Ashley Coleman (V-FEXrt) merged commit 32dd9cf into microsoft:main Aug 5, 2026
14 checks passed
@github-project-automation github-project-automation Bot moved this from New to Done in HLSL Roadmap Aug 5, 2026
@V-FEXrt
Ashley Coleman (V-FEXrt) deleted the linalg-bfloat16 branch August 5, 2026 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Add BFloat16 ComponentType

4 participants