Repository navigation
Model L: D3D12 port of the C = 32 Swin block, byte for byte against its HIP kernel - #117
Merged
Merged
Conversation
…ts HIP kernel l_swin.hlsl instantiates swin_block.hlsl as l_swin_block_c32_nc (C = 32, 2 heads, MLP 128, HIP's GELU chain and MLP unit cut), the D3D12 port of #102's HIP kernel. swin_block.hlsl (and the generated fused_swin.hlsl) gain the RMS-norm scale for C = 32 (1/32); Model M's DXILs are unchanged. vgpr_limits.json bounds the kernel at 96 VGPRs and build_dx12.py checks l_swin_* kernels too. kernel_replay.cpp runs single kernels on the native D3D12 device from case files; l_d3d12_check.py drives HIP and D3D12 on the same synthetic inputs and compares whole output buffers byte for byte, with Model M's swin_block_c96_nc as a control. Refs #89 Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…ative control Review of #117: the HIP output's downloaded bytes are compared as they are (no decode and encode, so the two FP8 NaN codes stay distinct), and each back end's output buffer starts filled with its own non-zero sentinel (HIP 0xA5, D3D12 0x5A; kernel_replay's arg out takes a fill byte), so a byte either path leaves unwritten differs. A negative control runs one case on D3D12 with half its workgroups and must be caught. Refs #89 Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
phantoslayer21
marked this pull request as ready for review
November 14, 2026 01:36
j0nsh1n
pushed a commit
to j0nsh1n/wronggpu
that referenced
this pull request
Nov 14, 2026
…l-linear-d3d12-pr Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
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.
Model L (#89): the D3D12 port of Model L's C = 32 Swin block, byte for byte against its merged HIP kernel
(
l_swin_block_c32_ncofl_swin.co, #102).clean/dx12/kernels/l_swin.hlsl(new): instantiatesswin_block.hlslasl_swin_block_c32_nc:SW_GELU=0) and HIP's MLP unit cut (SW_HPU=8);_ncform, as Model M's ports.clean/dx12/kernels/swin_block.hlsl: the RMS-norm scale had only the C = 64 and 96 cases. This addsSW_C == 32(scale 1/32). Without it, most output bytes differed.
fused_swin.hlsl, generated from it, gets the same two lines(
fused_swin_gen.py --check: up to date). Model M's DXILs are unchanged (below).clean/dx12/vgpr_limits.json:l_swin_block_c32_ncbounded at 96 VGPRs.clean/dx12/build_dx12.pychecksl_swin_*kernels too.clean/dx12/tests/kernel_replay.cpp(new): runs single kernels on the native D3D12 device (the project's DeviceAPI) from a case file of modules, a launch and its arguments.
clean/l/runner/l_d3d12_check.py(new): the harness.--prepare(CPU) builds the HIP code objects, the D3D12ports and
kernel_replay.exe.--run(one GPU slot) runs each case on HIP, then the same inputs throughkernel_replayon D3D12, and compares the whole output buffers withbytes ==. Counts only, no timing.What "byte for byte" is checked on:
packing.pack_blockatC = 32, heads 2, MLP 128) on both back ends;
and encoded again, so for example the two FP8 NaN codes stay distinct;
kernel_replay'sarg outtakes a fill byte). A byte that either path, or both, leaves unwritten therefore differs;swin_block_c96_nc(HIPswin.coagainst its existing D3D12 port) as a control on the same harness, so theharness itself is proven too.
Refs #89
Tested
Local, Windows, Radeon RX 9000 series card, main cf8e8ac plus this commit:
GPU (one GPU slot, 12.5 s),
l_d3d12_check.py --run --seeds 6, raw bytes and sentinels (after the review):l_swin_block_c32_nc: 48 of 48 cases identical (6 seeds x 8 grid / offset cases; 23,911,488 output bytes inall; 0 differing bytes in every case);
swin_block_c96_nc: 48 of 48 identical (71,734,464 bytes, 0 differing);kernel_replay: 0 cases failed.The first run, before the review fixes, decoded and re-encoded the HIP output and zero-filled both outputs: also 48 of
48 and 48 of 48.
--prepare(CPU): builds clean. VGPR check:l_swin_block_c32_nc95 / 96,swin_block_c96_nc192 / 192.Model M's DXILs unchanged: the 9 Swin kernels of
swin_block.hlsl,swin_c64w2.hlslandfused_swin.hlsl(
swin_block_c96_nc,swin_block_c96_add_ex_nc,swin_block_c64_nc,swin_block_c96_pm_nc,swin_block_c96_pm_rev_nc,swin_block_c96_add_xe_rev_nc,swin_block_c96_add_xe_nc,swin_block_c96_add_xe_xo_nc,swin_block_c96_add_xe_xd_nc) were built from main and from this branch under the same output names(
build_dx12.py --only ... -j 1). DXIL SHA-256: 9 of 9 identical (for exampleswin_block_c96_nc0d8bea45c7803504...,
swin_block_c64_nc9f7c47f23ff1174c...,swin_block_c96_add_xe_xd_nc2767e993c6ca1d46...).python tools/ci/check_line_endings.py: 0 problems. Public gates (secrets, personal data, licence, chunks) pass.Not tested
compare.pyfor Model L (waits for the L runtime frame).kernel_replay.exeis not built by CI (it needs a GPU to be useful).