Repository navigation
Model L D3D12: encoder block with the input linears as its prologue (byte-identical; enc0 -88/-141/-70 us) - #190
Merged
Merged
Conversation
…ologue (fusion le; the same bytes) l_swin_block_c32_enc_lin_nc (swin_block.hlsl SW_SRC 3, declared in l_swin.hlsl): the encoder block reads the FP8 q halo map and runs l_linear_32_32_fused's arithmetic on each member's pixel in registers (hlsl/l_lin_px.hlsli, shared with that kernel), so x2 (64 bytes a halo pixel) is neither stored nor read back and one launch goes. 95 VGPRs (bound 96: 4 workgroups per CU). Runtime fusion le (on by default, over ll); without it, or without the kernel in the build, the linears and the block run. l_enclin_check.py: the kernel against the sequence on D3D12 and on HIP, raw bytes, sentinels, negative control, Model M control. Every existing DXIL unchanged. Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
phantoslayer21
force-pushed
the
model-l/enc-lin
branch
from
November 14, 2026 19:18
0e3de42 to
2a8f3cc
Compare
phantoslayer21
marked this pull request as ready for review
November 14, 2026 19:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #89
Model L's D3D12 encoder block now runs the two input linears as its prologue. The new kernel
l_swin_block_c32_enc_lin_ncreads the FP8 q halo map and computes x2 in registers, so x2 (64 bytes per halo pixel) is never stored or read back and the linears launch goes. Its output is byte-identical to the sequence it replaces,l_linear_32_32_fused→l_swin_block_c32_enc_nc.What changes
swin_block.hlsl: gather modeSW_SRC 3. Each window member is a pixel of the q halo map at the same position mode 1 reads from x2. The member's lane runsl_linear_32_32_fused's arithmetic on it, which is the same lane mapping (token t, channel half h). Every lane runs it, so control flow stays wave-uniform. The block then starts from those FP16 values exactly as mode 1 does. The pointer argumentslinW1andlinW2are added underSW_SRC == 3.hlsl/l_lin_px.hlsli(new): the linears' helperslin_blob,lin_accandlin_pair.l_ops_linear.hlslincludes it in place of its own copies; the fused linears kernel keeps its inline sequence, and its DXIL is unchanged.l_swin.hlsl: declaresl_swin_block_c32_enc_lin_nc, D3D12 only, with the encoder block's defines plusSW_SRC=3andWG_REV_ORDER=1.enc0.Win1andenc0.Win2.le, on by default, afterllin the default list (pm,xe,mb,rv,xo,xd,lc,ll,le;compare.pymirrors it).l_narrow, then the fused block and the gather run.le, or without the kernel in the build, the linears (fused underll) and the plain block run.runtime_frame_trace.cpprecords the new kernel's argument kinds.test_l_runtime_frame.pycovers its arguments, roles and map chain, plus fallback subtests for each fusion setting and each kernel missing from the manifest.kernel_sets.json,vgpr_limits.json, FORMATS.md, and the regeneratedfused_swin.hlsl(its argument anchor too).Timing
Synthetic models; main (6622148) against the same build with this branch's runtime and kernel, interleaved, 5 rounds, each run in its own GPU slot. Values are medians in ms. Records:
enclin-timing.jsonand its per-run recordsenclin-{m6622,elrt}-<shape>-r1..5.json.Per kernel at 1080p Quality: the block goes from 0.260 to 0.296 ms, the linears (0.096 ms) are gone, and
l_project_gathergoes from 0.058 to 0.042 ms (x3 now stays in cache).Tested
l_enclin_check.py --seeds 2(new). Recordenclin-identity.json.swin_block_c96_nc: 8/8.l_frame_check.py --run --backend d3d12 / d3d12-stagesthen--compare-d3d12, pass, with all negative controls caught. Recordenclin-framecheck-raw-d3d12.json.enclin-frames-vs-main.json.build_dx12.py --model-lbuild against main's (6622148). All 68 existing DXILs are unchanged, Model M's included; the only addition is the new kernel, and that DXIL is the one tested and timed.test_l_runtime_frame.py(21 tests),test_kernel_sets.py,fused_swin_gen.py --check.public_gates.pypasses. The LOOK lines carry no hit in this branch's files.Not tested