Skip to content

[HLSL] Add LinAlg accumulation contention coverage#8676

Draft
JoeCitizen wants to merge 25 commits into
microsoft:mainfrom
JoeCitizen:linalg-hlk-accumulation-contention
Draft

[HLSL] Add LinAlg accumulation contention coverage#8676
JoeCitizen wants to merge 25 commits into
microsoft:mainfrom
JoeCitizen:linalg-hlk-accumulation-contention

Conversation

@JoeCitizen

@JoeCitizen JoeCitizen commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • extend the descriptor, group-shared and vector accumulation harnesses to drive deterministic contention from multiple Waves, threads and dispatch groups while preserving the existing single-invocation defaults
  • add a guarded F32 descriptor case with two Waves in each of two thread groups; four exactly representable 0.5 additions to initial 1.0 produce the unique exact result 3.0
  • add a guarded F16 group-shared case with two Waves contending in one thread group and a guarded F16 vector case with eight threads in each of two thread groups
  • retain capability-gated I32 descriptor-matrix, group-shared-matrix and descriptor-vector cases for implementations that advertise integer atomic support
  • add a checked host oracle for repeated integer accumulation totals and a host self-test

The runnable F16/F32 controls ensure every destination path executes locally. The I32 cases are not success-shaped fallbacks: they remain selected only when the runtime reports the matching atomic destination support.

Validation

  • built the Release ExecHLSLTests target
  • compiled LinAlgTests.cpp directly against the preview D3D12 headers
  • ran the 14-case accumulation selection with the ABI-corrected disposable WARP: 11 passed and the 3 I32 capability cases skipped because WARP reports both integer atomic destinations unsupported
  • positively executed the F32 descriptor and F16 group-shared contention cases on unmodified public preview WARP
  • positively executed the F16 vector contention case, plus all three existing vector accumulation regressions, on the disposable WARP decoder corrected for current handle-first DXIL operands
  • reran the capability-policy host test and the non-accumulating descriptor round-trip regression
  • inspected emitted DXIL for exact wave size 4, two active Waves, Wave-scope Accumulator matrices, guarded descriptor offsets/strides, group-shared addrspace(3) accumulation, eight-thread dispatches and handle-first vector operands
  • clang-format 17.0.1, git diff --check and a focused graphics correctness review pass

Runtime compatibility notes

WARP advertises MatrixConstruction for I32 but reports UAV=0 and groupshared=0 for I32 AtomicAccumulateStore, so those three cases correctly report NotApplicable. Public preview WARP also retains the known obsolete vector-first VectorAccumulate decoder; vector execution used the previously documented disposable decoder correction. No runtime change is included here.

  • after the MatVec, Wave, ThreadGroup, and outer-vector review corrections were propagated through this stack, the complete 66-method suite on the compatible local runtime reported 61 passed, 0 failed, and 5 capability-backed skips
  • serial review confirmed the matrix paths issue one collective update per active Wave, the vector path issues one update per Thread, all group barriers are uniform, and every floating intermediate is exactly representable and order-independent
  • after restoring the clang-format form disturbed by the K/L propagation conflict, the focused six contention methods reported 3 passed and 3 authoritative I32 skips; the full 66-method suite again reported 61 passed, 0 failed, and 5 skips

No physical GPU or packaged-HLK qualification is claimed.

Stack

This draft is stacked on PR #8675, which is stacked on PR #8674, PR #8673, PR #8672, 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 contention implementation is commit 45da2a4882; serial-review formatting correction 9452edd22 restores the repository-required clang-format form without changing behaviour.

This remains a draft for named human review. The reviewer should verify the atomic invocation counts, uniform Wave participation, group-shared barriers, exact/order-independent value choices, destination guards, capability gating and checked host totals before requesting maintainer review.

Refs #7841
Refs #8561
Refs #8562
Refs #8565
Refs #8654

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-accumulation-contention branch from 9c0260c to 2321b4d 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-accumulation-contention branch from 2321b4d to da9ba30 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-accumulation-contention branch from da9ba30 to a2a4fd6 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-accumulation-contention branch from a2a4fd6 to d41f605 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-accumulation-contention branch from d41f605 to 2b3a93e 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-accumulation-contention branch from 2b3a93e to 964c0f3 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-accumulation-contention branch from 964c0f3 to b959aa9 Compare July 25, 2026 07:52
Jack Elliott added 2 commits July 25, 2026 20:17
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
Add capability-gated ThreadGroup matrix multiply and multiply-accumulate cases with typed group-shared staging and exact host-derived results. Select and compile at the concrete wave and thread-group sizes advertised for each type and shape.

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-accumulation-contention branch from b959aa9 to c43c28e Compare July 25, 2026 08:18
Jack Elliott added 2 commits July 25, 2026 22:43
Prefer the smallest advertised multi-wave thread-group size when available so ThreadGroup operations cannot pass by behaving only at Wave scope. Add typed trailing guards to the group-shared result store and verify the complete guarded readback.

Assisted-by: GitHub Copilot

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

Copilot-Session: 83725f5d-8e98-4c1d-91ee-ad47629e007b
Add non-uniform Thread OuterProduct coverage with exact host readback through the preview matrix-conversion ABI. Add length-eight F16/F32 VectorAccumulate cases with non-zero destinations, capability-gate both operation families, and remove the released-SDK OuterProduct skip through SDK-neutral ABI mirrors.

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-accumulation-contention branch from c43c28e to 5d906d7 Compare July 25, 2026 10:46
Jack Elliott added 2 commits July 25, 2026 23:44
Require OuterProduct cases to advertise both the outer-product operation and descriptor accumulation they execute. Assert every field offset in the preview matrix-conversion ABI mirrors, and add typed trailing guards to all vector-accumulation outputs.

Assisted-by: GitHub Copilot

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

Copilot-Session: 83725f5d-8e98-4c1d-91ee-ad47629e007b
Add deterministic descriptor-matrix, group-shared-matrix, and descriptor-vector contention across multiple Waves, threads, and dispatch groups. Preserve destination guards, derive repeated totals with checked host arithmetic, execute exact F16/F32 controls on WARP, and retain capability-gated I32 cases for implementations that advertise integer atomic support.

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-accumulation-contention branch from 5d906d7 to 45da2a4 Compare July 25, 2026 11:46
@github-actions

github-actions Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

✅ With the latest revision this PR passed the C/C++ code formatter.

Keep the vector accumulation case validation in the repository's clang-format form after the outer-vector propagation conflict resolution.

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