Skip to content

Model L: D3D12 ports of the encoder and decoder blocks, byte for byte against their HIP kernels - #132

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

phantoslayer21 merged 3 commits into
mainfrom
model-l/l-blocks-d3d12-pr

Conversation

@phantoslayer21

Copy link
Copy Markdown
Owner

Model L (#89): the D3D12 ports of Model L's encoder and decoder blocks, l_swin_block_c32_enc_nc and
l_swin_block_c32_dec_nc of l_swin.co (clean/l/kernels/l_swin.hip, merged in #115), byte for byte against their HIP
kernels.

Targets main (it extends #117's harness). CI needs no GPU: nothing here runs without one.

  • clean/dx12/kernels/swin_block.hlsl: the HLSL side of Model L kernels: encoder and decoder blocks, input linears, projections, coefficient step (HIP) #115's gather-source hook and FP16 epilogue, as two
    defines. Both default to Model M's code.
    • SW_SRC 1 (LHaloF16Src): the block input is the FP16 halo map [H + 4][W + 4][32]. A window member reads its
      own pixel (pr + 2, pc + 2), inside the grid or in the halo, with no mirror.
    • SW_SRC 2 (LCoarseFp8Src): the FP8 map. A member outside the grid takes the mirrored 2 x 2 group (mirror of the
      group index) and keeps its sub-pixel.
    • SW_OUT_F16 (LStoreF16Epi): the output is RN16(x2) as an FP16 map, real members only.
    • Plain blocks only (an #error otherwise), as HIP's static_assert. The RMS norm needs no change: the HLSL
      template already sums the squares from the FP32 values, which is what Model L kernels: encoder and decoder blocks, input linears, projections, coefficient step (HIP) #115's custom sources do.
    • The FP16 output returns before the q8 output. That keeps the q8 store the file's last block, the anchor
      fused_swin_gen.py needs.
  • clean/dx12/kernels/fused_swin.hlsl: regenerated (fused_swin_gen.py, LF). It only gains the same text.
  • clean/dx12/kernels/l_swin.hlsl: the two kernels' @wg-kernel lines.
  • clean/dx12/vgpr_limits.json: their entries, 96 like l_swin_block_c32_nc. They use 95 (enc) and 93 (dec).
  • clean/l/runner/l_d3d12_check.py: the two kernels' cases, from one case generator per kernel. --kernels
    picks the kernels. The existing kernels draw their random inputs in the same order as before.

Refs #89

Tested

Local, Windows, Radeon RX 9000 series card, against main's l_swin.co (#115 merged):

  • GPU (one GPU slot), l_d3d12_check.py --run --seeds 6 (all Model L kernels of the harness + the control):
    • l_swin_block_c32_enc_nc: 84 of 84 cases identical (6 seeds x 7 grids x 2 offsets; 7,391,232 output bytes);
    • l_swin_block_c32_dec_nc: 84 of 84 identical (14,782,464 bytes);
    • l_swin_block_c32_nc (Model L: D3D12 port of the C = 32 Swin block, byte for byte against its HIP kernel #117): still 48 of 48 identical (23,911,488 bytes);
    • the Model M control swin_block_c96_nc: 48 of 48 identical (71,734,464 bytes);
    • 0 differing bytes in every case. The negative control (half grid) was caught: 1,248 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): the same 46 FP8 and 2 FP16 v_wmma as l_swin_block_c32_nc. The encoder has one more
    128-bit load per lane (the FP16 input row is 32 bytes) and the decoder two 128-bit stores (FP16 out). VGPRs 95 / 93
    of 96.
  • Model M's 9 Swin block DXILs (swin_block.hlsl, swin_c64w2.hlsl, fused_swin.hlsl): 9 of 9 byte-identical, main against this
    branch (DXIL SHA-256; fused_swin.hlsl regenerated from the changed template).
  • fused_swin_gen.py --check: up to date. python tools/ci/check_line_endings.py: 0 problems. Public gates (secrets,
    personal data, licence, chunks) pass.

Not tested

… against their HIP kernels

swin_block.hlsl gets the HLSL side of the gather-source hook (SW_SRC: FP16 halo map,
token-grid mirror) and the FP16 output (SW_OUT_F16); both default to Model M's code.

Refs #89

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
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