microsoft / microsoft/DirectXShaderCompiler

LinAlg HLK: Add bfloat16 coverage once DXIL gains a bfloat16 ComponentType

Open
#8,720 0 comments 0 reactions 0 assignees View on GitHub

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 ComponentType gains a bfloat16 member. include/dxc/DXIL/DxilConstants.h currently ends at F8_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 of HLSLHalf_t for bfloat16 today.

Required work

  • Add a bfloat16 alternative to cpu_oracle::TypedMatrixValues and a matching ComponentTraits specialisation. TypedMatrix::compType() derives the component type from the active alternative, so there is no separate tag to update.
  • Add bfloat16 arms to isSupportedComponentType, componentTypeName and makeSequentialMatrix, 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

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.