Skip to content

[HLSL] Add LinAlg Wave matrix arithmetic coverage#8673

Draft
JoeCitizen wants to merge 19 commits into
microsoft:mainfrom
JoeCitizen:linalg-hlk-wave-arithmetic
Draft

[HLSL] Add LinAlg Wave matrix arithmetic coverage#8673
JoeCitizen wants to merge 19 commits into
microsoft:mainfrom
JoeCitizen:linalg-hlk-wave-arithmetic

Conversation

@JoeCitizen

@JoeCitizen JoeCitizen commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • intersect MatrixConstruction and WaveMatrixMultiply support at one concrete wave size, then add non-uniform rectangular F16 multiply, mixed F16-to-F32 multiply, F32-accumulating MMA, B-use MatrixAccumulate, and capability-gated I32 multiply coverage
  • derive every expected result from a checked host integer matrix-product oracle, including a hand-derived 2x3 by 3x2 self-test and exact integer-valued F16/F32 cases
  • make MatrixQueryAccumulatorLayout select an observable A-use or B-use accumulation path, producing distinct exact results while avoiding a lane race on the queried-layout output
  • require multiply-accumulate cases to provide exactly M*N accumulator values and multiply-only cases to provide none, preventing wrong-sized data from being silently ignored

The five new arithmetic cases compile at the exact wave size shared by construction and multiply support. Existing mandatory F16 baselines keep their ranged-wave behaviour.

Validation

  • built the Release ExecHLSLTests target
  • ran all 9 Wave matrix arithmetic and accumulator-layout methods on WARP 1.65535.20-preview, Agility SDK 1.721.2-preview, and ExperimentalShaders=*: 9 passed
  • ran the complete 50-case stack selection: 47 passed, the two unchanged capability cases skipped, and only the already-documented mandatory MatVec native-F32/SInt8 WARP defect failed
  • inspected emitted DXIL for rectangular F16 inputs with F32 output, an independent F32 MMA accumulator, B-use MatrixAccumulate, and both query-controlled A-use/B-use paths
  • compiled HlslExecTestUtils.cpp and LinAlgTests.cpp against the preview D3D12 headers
  • clang-format 17.0.1, git diff --check, and an independent graphics correctness review pass
  • after the MatVec and Wave review corrections were propagated through the complete stack, the 66-method suite on the compatible local runtime reported 61 passed, 0 failed, and 5 capability-backed skips

No physical GPU or packaged-HLK execution is claimed.

Stack

This draft is stacked on PR #8672, which is stacked on PR #8671, PR #8670, PR #8669, PR #8668, PR #8667, PR #8666, PR #8665, and PR #8662. Until those ancestors land, this diff contains their commits as well. The Wave arithmetic implementation is commit 0edf569f4; review correction f4e6697e8 makes the accumulator-data invariant explicit.

This remains a draft for named human review. The reviewer should verify the capability intersection and selected wave size, M/K/N indexing, component-use encodings, exact host oracle, B-use accumulation path, and observable accumulator-layout branch before requesting maintainer review.

Refs #7841
Refs #8556
Refs #8557
Refs #8558
Refs #8648
Refs #8652

Assisted-by: GitHub Copilot

Jack Elliott and others added 3 commits July 23, 2026 14:52
Use the shared MatrixUse parameter for the OuterProduct result and set it to Accumulator, matching proposal 0035 and the public dx::linalg API. Add a host-side invariant to prevent the legacy A-use declaration from returning.

Assisted-by: GitHub Copilot

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 83725f5d-8e98-4c1d-91ee-ad47629e007b
Create SRV buffers without UAV flags and transition them for both pixel and non-pixel shader access. Use a direct resource-initialization list so the graphics-only pixel state is legal.

Assisted-by: GitHub Copilot

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 83725f5d-8e98-4c1d-91ee-ad47629e007b
Add typed F16, F32, I32, and U32 matrix data with safe byte encoding, rectangular row/column-major storage mapping, and explicit exact, permitted-result, or excluded comparison policy. Cover offsets and padded strides with independent host goldens, and migrate the existing CopyConvert tests onto the oracle.

Assisted-by: GitHub Copilot

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 83725f5d-8e98-4c1d-91ee-ad47629e007b
Jack Elliott and others added 3 commits July 25, 2026 12:59
Handle packed row or column byte-count overflow before using the result, and include raw F32 bits in exact mismatch diagnostics. Cover adjacent float bit patterns in the host oracle test.

Assisted-by: GitHub Copilot

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 83725f5d-8e98-4c1d-91ee-ad47629e007b
Add ABI-checked wrappers for the six D3D12 Linear Algebra capability
query categories and explicit applicability classification. Gate the
rectangular F32 CopyConvert case using concrete supported wave sizes.

Assisted-by: GitHub Copilot

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 83725f5d-8e98-4c1d-91ee-ad47629e007b
Compile capability-gated CopyConvert coverage at the exact wave size whose MatrixConstruction support was queried. Keep mandatory baseline cases on the existing ranged WaveSize attribute.

Assisted-by: GitHub Copilot

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 83725f5d-8e98-4c1d-91ee-ad47629e007b
@JoeCitizen
JoeCitizen force-pushed the linalg-hlk-wave-arithmetic branch from 00d0a7b to c04a99a Compare July 25, 2026 01:03
Jack Elliott added 2 commits July 25, 2026 14:10
Validate multiplication support flags per operation, exhaustively check the preview D3D12 ABI mirrors, and preserve query-backed optional skips in HLK mode.

Assisted-by: GitHub Copilot

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 83725f5d-8e98-4c1d-91ee-ad47629e007b
Add rectangular Length/GetCoordinate/GetElement coverage and the specified Get/Set out-of-bounds behaviour. Capture thread-local matrix records without UAV races and gate optional F32 cases at the exact queried wave size.

Assisted-by: GitHub Copilot

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 83725f5d-8e98-4c1d-91ee-ad47629e007b
@JoeCitizen
JoeCitizen force-pushed the linalg-hlk-wave-arithmetic branch from c04a99a to 274ca29 Compare July 25, 2026 02:27
Jack Elliott and others added 2 commits July 25, 2026 14:51
Seed OOB Get outputs with non-zero sentinels and require every lane in the selected wave to execute and write the specified zero result.

Assisted-by: GitHub Copilot

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 83725f5d-8e98-4c1d-91ee-ad47629e007b
Add bounded raw descriptor-table bindings and independent whole-buffer
oracles for LinAlg descriptor operations. Cover non-zero offsets, padded
strides, row/column-major transfer, descriptor bounds, and capability-gated
atomic accumulation.

Assisted-by: GitHub Copilot

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 83725f5d-8e98-4c1d-91ee-ad47629e007b
@JoeCitizen
JoeCitizen force-pushed the linalg-hlk-wave-arithmetic branch from 274ca29 to 50eb0a7 Compare July 25, 2026 02:55
Jack Elliott added 2 commits July 25, 2026 15:21
Reject invalid raw-buffer views, conflicting shader-visible resource heaps, and ambiguous root-parameter bindings before ShaderOp execution.

Assisted-by: GitHub Copilot

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 83725f5d-8e98-4c1d-91ee-ad47629e007b
Add race-free Wave and ThreadGroup group-shared transfer coverage for row/column-major layouts, non-zero offsets, padded strides, and exact whole-buffer guards. Add capability-gated Wave atomic accumulation with coordinate-derived values, while keeping cross-component conversion out of scope pending runtime conformance.

Assisted-by: GitHub Copilot

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 83725f5d-8e98-4c1d-91ee-ad47629e007b
@JoeCitizen
JoeCitizen force-pushed the linalg-hlk-wave-arithmetic branch from 50eb0a7 to 829cfaf Compare July 25, 2026 03:23
Jack Elliott and others added 2 commits July 25, 2026 15:48
Extend each group-shared backing array by four typed sentinel elements so transfer and accumulation tests verify writes do not overrun the matrix extent.

Assisted-by: GitHub Copilot

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 83725f5d-8e98-4c1d-91ee-ad47629e007b
Add mixed F16/F32 CopyConvert cases and verify that conversion leaves the source matrix unchanged.

Cover exact integer widening, RTNE plus saturating float narrowing, and capability-gated FP8 encoding and round-trip semantics with independent host oracles.

Assisted-by: GitHub Copilot
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 83725f5d-8e98-4c1d-91ee-ad47629e007b
@JoeCitizen
JoeCitizen force-pushed the linalg-hlk-wave-arithmetic branch from 829cfaf to 60b0fa5 Compare July 25, 2026 03:51
Jack Elliott added 2 commits July 25, 2026 18:37
Feed host-derived packed FP8 bytes through an SRV for decode so the F16 result cannot false-pass through a folded shader encode/decode chain.

Assisted-by: GitHub Copilot

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 83725f5d-8e98-4c1d-91ee-ad47629e007b
Refactor MatVec execution tests around independent matrix, vector, bias, and output resources with host-derived exact expectations.

Add required interpreted input tuples, non-uniform layout coverage, unsigned output, and independent bias validation behind the runtime ThreadVectorMatrixMultiply capability query. The mandatory native F32-to-SInt8 case remains active and exposes the current preview WARP conversion defect.

Assisted-by: GitHub Copilot

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 83725f5d-8e98-4c1d-91ee-ad47629e007b
@JoeCitizen
JoeCitizen force-pushed the linalg-hlk-wave-arithmetic branch from 60b0fa5 to fecb015 Compare July 25, 2026 06:40
Jack Elliott added 2 commits July 25, 2026 19:50
Separate native F32 inputs from hand-derived SInt8 values so MatVec exercises RTNE saturation, and use high-bit UInt8 lanes to distinguish unsigned packed interpretation.

Assisted-by: GitHub Copilot

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 83725f5d-8e98-4c1d-91ee-ad47629e007b
Add capability-gated Wave matrix multiply, multiply-accumulate, and B-use accumulate cases with independent exact host oracles. Make the accumulator-layout query select an observable A-use or B-use execution path.

Assisted-by: GitHub Copilot

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 83725f5d-8e98-4c1d-91ee-ad47629e007b
@JoeCitizen
JoeCitizen force-pushed the linalg-hlk-wave-arithmetic branch from fecb015 to 0edf569 Compare July 25, 2026 07:52
Require multiply-only case data to leave the accumulator vector empty so malformed inputs cannot pass validation and then be silently ignored.

Assisted-by: GitHub Copilot

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 83725f5d-8e98-4c1d-91ee-ad47629e007b
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.

1 participant