Skip to content

[HLSL] Add FP8 Convert coverage for LinAlg - #8805

Open
Jack Elliott (JoeCitizen) wants to merge 1 commit into
microsoft:mainfrom
JoeCitizen:linalg-hlk-convert-fp8-reenable
Open

[HLSL] Add FP8 Convert coverage for LinAlg#8805
Jack Elliott (JoeCitizen) wants to merge 1 commit into
microsoft:mainfrom
JoeCitizen:linalg-hlk-convert-fp8-reenable

Conversation

@JoeCitizen

@JoeCitizen Jack Elliott (JoeCitizen) commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Adds Convert_F16_ToE4M3FN_AndBack and Convert_F16_ToE5M2_AndBack, covering the two FP8 formats in both directions: converting F16 to packed FP8 and storing the result, and converting packed FP8 loaded from a resource back to F16. These tests were deferred because of a WARP bug.

Adds Convert_F16_ToE4M3FN_AndBack and Convert_F16_ToE5M2_AndBack, which
cover the two FP8 formats in both directions: converting F16 to packed
FP8 and storing the result, and converting packed FP8 loaded from a
resource back to F16.

These tests were written alongside the rest of the Convert coverage but
were held back because WARP did not implement either direction. It
emulated FP8 as F16-quantised F32 in a JIT-side shadow map, so a store of
a converted value wrote unpacked F32 words instead of packed FP8 bytes,
and a convert out of FP8 read the shadow map rather than decoding the
operand. That has since been fixed in WARP, which now packs at the
instruction's declared LLVM type and decodes the real operand, keeping
the shadow map only as a side channel for linear algebra consumers.

Both directions compare against hand-derived byte tables rather than a
shader round trip. The decode input is a fixed hand-encoded byte string
that is deliberately not the encode expectation, so a shader that echoed
its input could not pass. Input values were chosen to avoid mantissa ties
so the rounding mode is not in question.

The host FP8 encoder that derives those tables from first principles is
exercised by LinAlgCPUOracleTests::FP8HostOracle rather than by the
execution tests, following MatVecHostOracle. That class carries no Kits
metadata, so a defect in test-only code cannot fail a driver during
certification. Confirmed by perturbing the encoder: FP8HostOracle fails
while both execution tests still pass.

The suite is 62 total, 61 passed, 0 failed, 1 skipped on a current D3D12
runtime, with no regressions against the 59 tests already on main. Run
against the older WARP that carried the defect, both execution tests fail
with the documented byte pattern, so they detect the condition they
describe.

Assisted-by: GitHub Copilot
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 83725f5d-8e98-4c1d-91ee-ad47629e007b
Copilot AI balanced review requested due to automatic review settings August 19, 2026 01:43

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 conformance coverage for bidirectional F16 conversion with both supported FP8 formats.

Changes:

  • Adds E4M3FN and E5M2 execution tests.
  • Adds independent host-side FP8 test vectors and oracle validation.
  • Extends conversion helpers to support input buffers.
Suppressed comments (1)

tools/clang/unittests/HLSLExec/LinAlgTests.cpp:8239

  • The reverse conversion is logically F8_E5M2 -> F16; uint is only the packed carrier type in the shader. Querying U32 -> F16 can skip this test on a device that supports the required FP8 conversion but does not advertise integer conversion, and it never verifies that FP8 is supported as a conversion source.
  if (!convertTypesApplicable(D3DDevice, ComponentType::U32, ComponentType::F16,

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tools/clang/unittests/HLSLExec/LinAlgTests.cpp

@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

I'm still concerned that there are many error paths that are actually bugs in the test (eg passing an unsupported component type to makeFP8ConvertData) that should really be a fail fast / assert / abort, get reported as if the device under test failed via a VERIFY_IS_TRUE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

3 participants