Skip to content

Model L: D3D12 port of dec1's block with its fused expand (swin_block_c64_add_ex_nc), byte for byte against its HIP kernel - #139

Merged
phantoslayer21 merged 3 commits into
mainfrom
model-l/c64-add-ex-d3d12-pr
Nov 14, 2026
Merged

phantoslayer21 merged 3 commits into
mainfrom
model-l/c64-add-ex-d3d12-pr

Conversation

@phantoslayer21

Copy link
Copy Markdown
Owner

Model L (#89): the D3D12 port of dec1's Swin block with its fused expand, swin_block_c64_add_ex_nc of swin.co
(clean/kernels/swin.hip, WG_FUSED_KERNEL(swin_block_c64_add_ex, 64, 2, 256, true, 0, 96)), byte for byte against
its HIP kernel.

Why: Model M's D3D12 route always runs dec1 fused with its pack12 decoder (d1p12/swin_block_c64_add_dec0*), so dec1's
block on its own had no port. Model L's decoder reads dec1's map, so Model L's frame refuses the fused dec1 + dec0
forms. With the default swin_fuse_stages=dec1,dec2 it then launches:

  • dec2: swin_block_c96_add_ex_nc, already ported (the xe fusion needs the fused dec1 + dec0, so it is off);
  • dec1: swin_block_c64_add_ex_nc, this PR.

swin_block_c64_add_nc is only on the non-default unfused route (swin_fuse_stages without dec1, with expand_c96)
and is not ported here.

Targets main. CI needs no GPU: nothing here runs without one.

  • clean/dx12/kernels/swin_c64ex.hlsl (new): the kernel's @wg-kernel line and #include "swin_block.hlsl".
    It instantiates the template unchanged: C = 64, 2 heads, MLP 256 (its C = 64 path, as swin_block_c64_nc), with
    the block input x + xadd (SW_ADD) and the fused expand from the 96-channel low-resolution map (SW_ECL 96). That
    is the same combination swin_block_c96_add_ex_nc uses at C = 96. 256 lanes, one window per wave, the 9 arguments
    of HIP's fused kernels (aux unused).
    • No Model M source changes: swin_block.hlsl and fused_swin.hlsl are untouched.
  • clean/dx12/vgpr_limits.json: its bound, 128. It uses 120 VGPRs, which keeps 3 workgroups per CU.
  • clean/l/runner/l_d3d12_ops_check.py: its cases.
    • dec1 maps 16 x 24, 36 x 68, 8 x 8, 68 x 100, 4 x 6, 12 x 20 and 48 x 64. They are even, because the expand
      writes 2 x 2 pixels per low-resolution token. 4 x 6 and 12 x 20 have fewer windows than a workgroup.
    • Each map runs with dec1's two window offsets, (0, 0) and (2, 0).
    • Inputs: the 96-channel half-size map x and the 64-channel skip map, both FP8. Blob: dec1's whole stage blob, the
      block then the expand section (packing.pack_stage). Only _nc blobs, since the D3D12 port has only the _nc
      form.

Refs #89

Tested

Local, Windows, Radeon RX 9000 series card, against main's swin.co:

  • GPU (one GPU slot), l_d3d12_ops_check.py --run --seeds 6 --kernels swin_block_c64_add_ex_nc:
    • swin_block_c64_add_ex_nc: 84 of 84 cases identical (6 seeds x 7 maps x 2 offsets; 10,008,576 output bytes);
    • the Model M control swin_block_c96_nc: 36 of 36 identical (3,167,424 bytes);
    • 0 differing bytes in every case. The negative control (half grid) was caught: 10,752 bytes differed;
    • compared as raw downloaded bytes. Each output was first filled with its back end's own non-zero sentinel
      (HIP 0xA5, D3D12 0x5A).
  • build_dx12.py --isa (RGA): 120 VGPRs (bound 128). The D3D12 and HIP compilers roll and unroll the block's loops
    differently, so their instruction counts differ; the outputs above are identical.
  • Model M unchanged: against main, this PR changes no file Model M's kernels compile from (a new file, the VGPR
    list and the check script). After merging main (Model L: D3D12 ports of the encoder and decoder blocks, byte for byte against their HIP kernels #132's template switches), swin_block_c64_add_ex_nc rebuilds to
    the byte-identical DXIL the GPU run above tested (SHA-256).
  • python tools/ci/check_line_endings.py: 0 problems. Public gates (secrets, personal data, licence, chunks) pass.

Not tested

  • In a whole Model L frame on D3D12 (waits for param's D3D12 frame).
  • The unfused route (swin_block_c64_add_nc after expand_c96): not ported.
  • The clamped (non-_nc) form: only the _nc forms are ported, as for Model M.

…_c64_add_ex_nc), byte for byte against its HIP kernel

Model M's D3D12 route always runs dec1 fused with the pack12 decoder; Model L's frame launches
this kernel for dec1, which had no port. swin_c64ex.hlsl instantiates swin_block.hlsl
unchanged (C = 64, ADD, fused expand from 96 channels).

Refs #89

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>

# Conflicts:
#	clean/l/runner/l_d3d12_ops_check.py
@phantoslayer21
phantoslayer21 marked this pull request as ready for review November 14, 2026 03:32
…_post_recon cases)

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
@phantoslayer21
phantoslayer21 merged commit 5712bfd into main Nov 14, 2026
9 checks passed
@phantoslayer21
phantoslayer21 deleted the model-l/c64-add-ex-d3d12-pr branch November 14, 2026 03:50
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