Repository navigation
Model L: reverse workgroup order on five hybrid Swin kernels - #269
Merged
Merged
Conversation
…me bytes) Model L's hybrid route ran every Swin-chain kernel with its workgroups in forward order. Five of them now run in reverse order (WG_REV_ORDER=1, the same mechanism the c32 encoder kernels already use), so that along the chain each consumer starts on the rows its producer wrote last: l_project_gather F -> swin_block_c64_hyb R -> patch_merge_c64_hyb F -> swin_block_c96_hyb R -> patch_merge_c96_hyb F -> bottleneck (unchanged) -> expand_c128_hyb R -> swin_block_c96_add_hyb F -> expand_c96_hyb R -> swin_block_c64_add_hyb F -> l_dec_project F -> l_swin_block_c32_dec_coef12_hyb R. Each workgroup does the same work on the same data: no in-place buffers, no atomics, the group index only through WG_SETUP. Declarations only; the other kernels' DXILs are unchanged. Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Beside the hybrid L kernels that use it (l_swin.hlsl, hyb_gemm.hlsl): a multi-dimensional launch must flatten its group index before the reversal. Comments only; the kernels compile to the same DXIL. wg_platform.hlsli itself stays unchanged, since its text is part of Model K's softmax self-check digest. Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
phantoslayer21
force-pushed
the
model-l/rv-hybrid-order
branch
from
November 17, 2026 04:51
3ae016b to
54c2951
Compare
phantoslayer21
marked this pull request as ready for review
November 17, 2026 04:59
phantoslayer21
added a commit
that referenced
this pull request
Nov 17, 2026
…s) into release-0.6.1 Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
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.
Model L's hybrid route ran every kernel of its Swin chain with the workgroups in forward order. This change runs five of them in reverse order (
WG_REV_ORDER=1, the mechanism the c32 encoder kernels already use), so that each consumer starts on the rows its producer wrote last, which are the likeliest to still be in the caches:l_project_gatherF →swin_block_c64_hybR →patch_merge_c64_hybF →swin_block_c96_hybR →patch_merge_c96_hybF → bottleneck (unchanged) →expand_c128_hybR →swin_block_c96_add_hybF →expand_c96_hybR →swin_block_c64_add_hybF →l_dec_projectF →l_swin_block_c32_dec_coef12_hybREach workgroup does the same work on the same data, so the output is the same bytes. The change touches only kernel declaration lines and comments:
clean/dx12/kernels/hyb_swin.hlsl(2 declarations)clean/dx12/kernels/hyb_gemm.hlsl(2 declarations, plus a comment)clean/dx12/kernels/l_swin.hlsl(1 declaration, plus a comment)The comments note that
WG_REV_ORDERreverses the group index of a 1-D dispatch only (a multi-dimensional launch must flatten it first), and that every kernel using it here is 1-D.wg_platform.hlsliitself is unchanged, because its text is part of Model K's softmax self-check digest. There is no runtime change, and the kernel names stay the same.Why it is exact: for each of the five kernels, the input and output buffers are distinct (no in-place writes another workgroup could read), there are no atomics or cross-workgroup sums (the coherent cross-workgroup loads in
swin_block.hlslare compiled only into the bottleneck's persistent form), and the group index is read only throughWG_SETUP. Every shipped shape stays far below 65,535 workgroups in one launch for these kernels: the largest grid is a block kernel at 4K Performance, at about 4,100 groups.Measured with the direct-route benchmark (D3D12 timestamps, synthetic model and inputs, 1500 frames per run, 5 interleaved rounds, the same build with and without the change):
The stage split puts the gain in the Swin and decoder-block stages, the hand-offs that were reversed. Record: RV-HYB-RESULT.md.
Tested
Not tested