microsoft / microsoft/DirectXShaderCompiler
LinAlg HLK: Add bfloat16 coverage once DXIL gains a bfloat16 ComponentType
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
Goal
Extend the LinAlg CPU oracle and the DxilConf_SM610_LinAlg execution tests to cover bfloat16 matrices, once the prerequisites below have landed.
Why
hlsl-specs#907 adds a bfloat16 format to HLSL proposal 0035. The LinAlg CPU oracle added in #8666 models F16, F32, I32 and U32 only, so bfloat16 matrices cannot currently be constructed, encoded or compared against an independent host reference.
#907 defines bfloat16 as "an optional feature that hardware vendors can choose to support", so coverage must be capability-gated rather than unconditional. An implementation that does not support bfloat16 must not fail conformance for it.
Blocked on
- hlsl-specs#907 merges.
- DXIL
ComponentTypegains a bfloat16 member.include/dxc/DXIL/DxilConstants.hcurrently ends atF8_E5M2 = 22, so there is no enumerator for the oracle to switch on. - A host-side bfloat16 type exists in
tools/clang/unittests/HLSLExec/HlslTestDataTypes.h. There is no equivalent ofHLSLHalf_tfor bfloat16 today.
Required work
- Add a bfloat16 alternative to
cpu_oracle::TypedMatrixValuesand a matchingComponentTraitsspecialisation.TypedMatrix::compType()derives the component type from the active alternative, so there is no separate tag to update. - Add bfloat16 arms to
isSupportedComponentType,componentTypeNameandmakeSequentialMatrix, including a representable-value range check equivalent to the existing F16 and F32 checks. - Add a bfloat16 case to
elementSize. - Gate bfloat16 tests on the reported capability so unsupported implementations report not-applicable rather than failed.
- Add execution test coverage for the operations that accept bfloat16.
Acceptance criteria
- The oracle can construct, encode, decode and compare bfloat16 matrices against hand-derived expected values.
- Expected values come from an independent host reference, not from the shader under test.
- Implementations without bfloat16 support report not-applicable, not failed.
- Coverage matches the operation set that hlsl-specs#907 permits for bfloat16.
Public references
- Raised in review of #8666: https://github.com/microsoft/DirectXShaderCompiler/pull/8666#discussion_r3685978024
- Parent tracker #7841
- hlsl-specs#907
LinAlgTests.cpp
Out of scope
- Adding the bfloat16 enumerator to DXIL, or any compiler-side bfloat16 support.
- Expanding non-bfloat16 type coverage.
Assisted-by: GitHub Copilot
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
After hlsl-specs#907 and the prerequisite DXIL and host-type changes land, read tools/clang/unittests/HLSLExec/HlslTestDataTypes.h, the CPU oracle helpers, and LinAlgTests.cpp; check DxilConstants.h for the new component type. Run the LinAlg execution tests and verify construction, encoding, decoding, independent expected values, capability-gated not-applicable results, and permitted operation coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers, testing-qa
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100