Skip to content

Model L's C = 32 blocks on D3D12: q8(GELU) from the arena table (-31 / -33 us); per-kernel profile - #157

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

phantoslayer21 merged 1 commit into
mainfrom
model-l/c32-gelu-table

Conversation

@phantoslayer21

Copy link
Copy Markdown
Owner

Model L speed on D3D12, first change: the frame's two C = 32 blocks (l_swin_block_c32_enc_nc, _dec_nc) take
q8(GELU) from the 16 KB arena table (SW_GELU 1) instead of HIP's transcendental chain (SW_GELU 0). Model M's
blocks use the same tables, which swin_block.hlsl keeps bit-identical to HIP's chain plus its FP8 pack. The ports
stay byte for byte against their HIP kernels; nothing is approximated. This PR also adds the per-kernel profiler.

What changes

  • clean/dx12/kernels/l_swin.hlsl: SW_GELU=1 on _enc_nc / _dec_nc. The groupshared table (SW_GELU 2) takes
    both to 112 VGPRs, over their bound of 96 (vgpr_limits.json; the build refuses it), so it is not used.
    l_swin_block_c32_nc (not in the frame) keeps the chain.
  • clean/l/runner/l_d3d12_profile.py (new): per-kernel GPU time of the native D3D12 frame from the runtime's
    operation profile (WG_D3D12_PROFILE, as clean/dx12/profile_frames.py).
    • Model L, or Model M as the control, at 1080p Quality (1280 x 720 -> 1920 x 1080) or 1440p Quality.
    • Kernels grouped by frame step; the record as JSON.

Refs #89

Where Model L's time goes (main, 1080p Quality, synthetic models, instrumented D3D12 timestamps, ms per frame;
records records/l-d3d12-kernels-1080pq-L.json and -M.json in the rr-plugin build folder)

step Model L Model M
encoder 0.785 0.124
Swin (with Model L's own dec1 block) 0.768 0.589
decoder 0.694 0.169 (also holds M's fused dec1)
post 0.378 0.378

These match the game's timing (encoder 0.761 vs 0.110, decoder 0.685 vs 0.189). Model L's encoder and decoder by
kernel:

kernel ms
l_swin_block_c32_dec_nc 0.340
l_swin_block_c32_enc_nc 0.296
l_dec_project 0.187
l_coef_pack12 0.167
l_project_gather 0.164
lev/input_encoder 0.114
l_linear_32_32_relu 0.113
l_linear_32_32_f16 0.099

Byte identity (clean/l/runner/l_d3d12_check.py --kernels l_swin_block_c32_enc_nc,l_swin_block_c32_dec_nc, one
GPU slot; record records/c32-gelu1-identity.json)

  • D3D12 against HIP, raw bytes, sentinel-filled outputs: _enc_nc 28 of 28 cases identical, _dec_nc 28 of 28.
  • Model M's swin_block_c96_nc control: 16 of 16.
  • Negative control (half grid): caught, 768 bytes differ.
  • The DXILs of this commit were rebuilt from its source and are identical to the checked ones.

Timing (l_d3d12_profile.py, main's build A against this change's build B, which differ only in these two
DXILs; interleaved, 3 rounds each, every run its own GPU slot; record records/c32-gelu1-ab.json; medians)

  • l_swin_block_c32_enc_nc: 0.299 -> 0.268 ms (-31 us).
  • l_swin_block_c32_dec_nc: 0.341 -> 0.308 ms (-33 us).
  • The other kernels are within +-0.004 ms.
  • Whole-frame span (wg_rt_frame_timed, after the profiled phase): A 2.664 / 2.675 / 2.657 ms, B 2.605 / 2.599 /
    2.608 ms.

Tested

  • The byte-identity check and timing above; public gates.

Not tested

  • In a game (the next game timing run).
  • Real model weights: the arithmetic is the same, and the tables are exact for every input.

…kernel profile

- clean/dx12/kernels/l_swin.hlsl: l_swin_block_c32_enc_nc and _dec_nc (the frame's
  blocks) take q8(GELU) from the 16 KB arena table (SW_GELU 1) instead of HIP's
  transcendental chain (SW_GELU 0). swin_block.hlsl's tables are bit-identical to
  that chain plus its FP8 pack, as Model M's blocks use them; the ports stay byte
  for byte against their HIP kernels. The groupshared table (SW_GELU 2) takes both
  to 112 VGPRs, over their bound of 96, and is not used. l_swin_block_c32_nc keeps
  the chain.
- clean/l/runner/l_d3d12_profile.py (new): per-kernel GPU time of the native D3D12
  frame by the runtime's operation profile (WG_D3D12_PROFILE), Model L or Model M,
  grouped by frame step, at 1080p Quality (1280 x 720 -> 1920 x 1080) or 1440p
  Quality; the record as JSON.

Refs #89

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