[HLSL] Add FP8 Convert coverage for LinAlg - #8805
Open
Jack Elliott (JoeCitizen) wants to merge 1 commit into
Open
[HLSL] Add FP8 Convert coverage for LinAlg#8805Jack Elliott (JoeCitizen) wants to merge 1 commit into
Jack Elliott (JoeCitizen) wants to merge 1 commit into
Conversation
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
Contributor
There was a problem hiding this comment.
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;uintis only the packed carrier type in the shader. QueryingU32 -> F16can 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.
Damyan Pepper (damyanp)
approved these changes
Aug 19, 2026
Member
There was a problem hiding this comment.
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.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds
Convert_F16_ToE4M3FN_AndBackandConvert_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.