Skip to content

Model L D3D12: dec1 block with two windows per wave (byte-identical, -7/-17 us at 1080p/1440p) - #171

Merged
phantoslayer21 merged 1 commit into
mainfrom
model-l/dec1-w2
Nov 14, 2026
Merged

phantoslayer21 merged 1 commit into
mainfrom
model-l/dec1-w2

Conversation

@phantoslayer21

Copy link
Copy Markdown
Owner

Refs #89

Model L's dec1 block swin_block_c64_add_ex_nc now runs in the launch shape of Model M's enc1 block (swin_c64w2.hlsl): two windows per wave in 128-lane workgroups. Each window's arithmetic is unchanged and so are the bytes it writes. Oversight approved this form on condition that it is byte-identical, recorded, and leaves Model M untouched.

What changes

  • swin_c64w2.hlsl:
    • The block input can be x + xadd (SW_ADD), with the fused expand (SW_ECL). The expand writes the 8 windows' records into the second staging buffer, as swin_block.hlsl does, and each wave reads back its two windows' records.
    • The kernel name is now a switch (SW_W2_NAME, default swin_block_c64_nc).
  • swin_block.hlsl: fused_expand runs with the workgroup's wave count THREADS / 32, which is 8, or 4 in the 128-lane form. It used to be a literal 8. fused_swin.hlsl is its generated copy.
  • swin_c64ex.hlsl: dec1's declaration moves to the two-window form. The header documents the switch back: the one-window line rebuilds main's DXIL byte for byte (checked).
  • vgpr_limits.json: dec1's bound goes from 128 to 192, which allows 4 workgroups of 4 waves per CU. It builds at 192 VGPRs, 0 spills, 16 KB LDS.
  • No runtime change. The manifest's group / gscale already drive the launch, as for enc1.

Timing

1080p and 1440p Quality, synthetic models. Main's dec1 DXIL and this branch's were swapped into one runtime build, interleaved, 3 rounds, each run in its own GPU slot. Values are medians in ms. Records: k-<shape>-{dkbase,w2a}-r<n>.json and the summary dec1w2-time.txt.

main this PR difference
dec1, 1080p Quality 0.1678 0.1607 −7.1 µs
dec1, 1440p Quality 0.3005 0.2834 −17.1 µs
frame span, 1080p 2.0847 2.0800
frame span, 1440p 3.5107 3.4884

Every PR round beat every main round at both shapes.

Tested

  • DXILs: full build_dx12.py --model-l builds of this branch and of main (f0fd94c), all 64 DXILs compared.
    • Only swin_block_c64_add_ex_nc.dxil differs.
    • Every Model M DXIL is unchanged, including swin_block_c64_nc (the two-window enc1 block), swin_block_c96_add_ex_nc and the fused c96 kernels, which share fused_expand.
  • Kernel check: l_d3d12_ops_check.py --kernels swin_block_c64_add_ex_nc --seeds 3, raw bytes against HIP with per-backend sentinels. Record dec1w2-identity.json.
    • 42/42 cases byte-identical: 7 grids × 2 window offsets × 3 seeds, including grids with fewer windows than a workgroup's 8.
    • Negative control (half grid): caught, 10752 bytes differ.
    • Model M control swin_block_c96_nc: 18/18.
  • Frame check: main's raw frame check (l_frame_check: byte identity on raw defined bytes, per-run sentinels, missing outputs fail #165), l_frame_check.py --run --backend d3d12 / d3d12-stages then --compare-d3d12, both models, 11 frames, pass. It ran on a build with this branch's dec1 kernel swapped in. Record dec1w2-framecheck-raw-d3d12.json.
    • Per stage against the reference: 11/11.
    • Default kernels against that run (raw bytes): 11/11 identical.
    • Model M D3D12 against HIP: 11/11.
    • Negative controls (history, reduced, reduced_frame, missing): all caught.
  • Frames against main: every recorded D3D12 array, both models, both configurations, 11 frames, byte for byte: 0 differing. Record dec1w2-frames-vs-main.json.
  • Unit test: test_kernel_sets.py.
  • Gates: public_gates.py passes; the LOOK lines are at baseline.

Not tested

  • The knobs of the two-window form on dec1 (GELU pattern, MLP step). Each build takes about 5 minutes; that tuning is left for a follow-up.
  • HIP: unchanged, since the HIP kernels don't use these files.
  • Real models and real game frames.

…ws per wave (the same bytes)

swin_c64w2.hlsl (Model M's enc1 block in 128-lane workgroups, two windows per wave) takes the block input x + xadd
(SW_ADD) and the fused expand (SW_ECL) under a kernel name switch (SW_W2_NAME); swin_block.hlsl's fused_expand runs
with the workgroup's wave count (8, or 4 here). dec1's declaration (swin_c64ex.hlsl) moves to that form; its VGPR bound
is 192 (4 workgroups of 4 waves per CU). Model M's DXILs are unchanged; the one-window line rebuilds main's dec1 byte
for byte.

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
@phantoslayer21
phantoslayer21 marked this pull request as ready for review November 14, 2026 15:06
@phantoslayer21
phantoslayer21 merged commit e8f6c22 into main Nov 14, 2026
9 checks passed
@phantoslayer21
phantoslayer21 deleted the model-l/dec1-w2 branch November 14, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant