Skip to content

Model L D3D12: scheduling knobs on the two C32 frame blocks (byte-identical, -9/-12/-10 us) - #192

Merged
phantoslayer21 merged 1 commit into
mainfrom
model-l/c32-isa
Nov 14, 2026
Merged

phantoslayer21 merged 1 commit into
mainfrom
model-l/c32-isa

Conversation

@phantoslayer21

Copy link
Copy Markdown
Owner

Refs #89

This sets swin_block.hlsl's same-value scheduling knobs on Model L's two full-resolution C32 blocks. These knobs reorder and stage the work without changing any value. Both kernels stay within their 96-VGPR bound (4 workgroups per CU), and only their two declaration lines in l_swin.hlsl change.

  • l_swin_block_c32_enc_lin_nc: SW_HEAD_PAIRS=1 (the head loop in pairs), SW_SMAX_STAGED=1 (the softmax's staged form), SW_NORM1_EARLY=1 (norm1's gamma/beta loads before the first barrier). 95 VGPRs.
  • l_swin_block_c32_dec_coef12_nc: SW_SMAX_ADDST=1, SW_SMAX_STAGED=1. 96 VGPRs.

Found by an ISA audit and a timed sweep of the template's knobs.

  • Per-window work: about 1760 instructions per window (head loop counted twice), at roughly one instruction per cycle per SIMD. So the blocks are issue-bound.
  • Sweep result: 18 knobs on both blocks. The ones that raised VGPRs over 96 or were slower were dropped; the combination above is the best that fits.

Timing

Synthetic models. Main against main with this branch's two DXILs, interleaved, 3 rounds, each run in its own GPU slot. Values are medians in ms. Records: c32knobs-timing.json and its per-run records c32knobs-{elrt,skrt}-<shape>-r1..3.json.

shape encoder block decoder block both
1080p Quality 0.2963 → 0.2911 0.3017 → 0.2983 −8.7 µs
1440p Quality 0.5311 → 0.5214 0.5452 → 0.5429 −12.0 µs
1440p Performance 0.2993 → 0.2907 0.3004 → 0.2986 −10.4 µs

Every PR run of the encoder block beat every main run, at all three shapes.

Tested

  • Encoder block: l_enclin_check.py --seeds 2. Record c32knobs-enc-identity.json.
    • 28/28 cases byte-identical across the kernel, the D3D12 sequence (l_linear_32_32_fused → l_swin_block_c32_enc_nc) and the HIP sequence (relu → f16 → block), with special FP8 codes in q.
    • Negative control: caught. Model M control: 8/8.
  • Decoder block: l_fold_check.py --seeds 2. Record c32knobs-dec-identity.json.
    • 84/84 cases byte-identical against the D3D12 pair and the HIP pair (l_swin_block_c32_dec_nc → l_coef_pack12).
    • Negative control: caught. Model M control: 8/8.
  • Frame check: main's raw frame check (l_frame_check.py --run --backend d3d12 / d3d12-stages, then --compare-d3d12), both models, pass, with all negative controls caught. Record c32knobs-framecheck-raw-d3d12.json.
  • Frames against main: every recorded D3D12 array, both models, both configurations, 11 frames, compared byte for byte: 0 differing. Record c32knobs-frames-vs-main.json.
  • DXILs: all kernels of l_swin.hlsl rebuilt and compared with main's: only the two edited kernels differ. No other source file changes, so every other DXIL, Model M's included, is built from unchanged source.
  • Gates: public_gates.py passes. The LOOK lines carry no hit in this branch's file.

Not tested

  • HIP: unchanged; these are D3D12 declarations only.
  • Real models and real game frames.

… bytes)

l_swin_block_c32_enc_lin_nc: SW_HEAD_PAIRS, SW_SMAX_STAGED, SW_NORM1_EARLY; l_swin_block_c32_dec_coef12_nc:
SW_SMAX_ADDST, SW_SMAX_STAGED (swin_block.hlsl's same-value knobs). 95 / 96 VGPRs: 4 workgroups per CU kept. Only
these two DXILs change.

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
@phantoslayer21
phantoslayer21 marked this pull request as ready for review November 14, 2026 20:11
@phantoslayer21
phantoslayer21 merged commit ae3cf4e into main Nov 14, 2026
9 checks passed
@phantoslayer21
phantoslayer21 deleted the model-l/c32-isa branch November 14, 2026 20:12
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