Repository navigation
Model K: streamline narrow stages and compact head - #288
Merged
Merged
Conversation
Use prewidened FP32 bias planes and folded weight offsets in the two-window narrow kernels. Pack the 32 live compact-head rows into two WMMA tiles. Rebind the K softmax source digest after native D3D12 backend 3 k_smx_test=report reproduced all 133 stored hashes in each of the mix and round-to-odd forms with zero mismatches. Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Keep the original 48-row head in KBlkParams and pass the compact head and bias plane as separate D3D12 arguments. Require the narrow ports and their argument signatures for hybrid and native contexts. Refuse missing argument values before hybrid argument packing. Replay both d1 forms and the compact head against the original HIP arguments. Check the packed row permutation on the host and reject a compact-bias full-head shader at compile time. Rebind the softmax source digest to a47546460b78b46b3ae0775661c6c4160ad20af09b6106c16322f8d164136264. The native backend-3 k_smx_test=report reproduced 133/133 stored HIP hashes for each of mix and round-to-odd, with zero hash or probe mismatches. Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
phantoslayer21
marked this pull request as ready for review
November 19, 2026 01:20
j0nsh1n
added a commit
to j0nsh1n/wronggpu
that referenced
this pull request
Nov 23, 2026
…operands (FP32 bias plane, compact d0 head) Main's phantoslayer21#288 gave the two-window narrow ports (k_stage2_e0, e1, d1, d1__rodd) a prewidened FP32 bias plane as one more pointer argument, and d0_hp a compact head (32 live rows in two tiles) plus the plane (three pointers in all), and the runtime now requires those argument lists for the native context too. The native __g11 forms kept the old lists, so a native Model K run would have refused to start (require_d3d12_port compares the signature of the __g11 form). k_block_g11.hlsli's k_block_n11 takes (hidden, blk, bias32, compact_head) under KB_BIAS32 and reads every accumulator start (embed / expand bias, bo, b2, b1, the merge or head bias, the softmax bias table) from the plane through kn_bias32 (k_block.hlsli's kb_bias32 through kn_ld128, so KN_A16 still decides the alignment hint); the FP16 -> FP32 widening happened on the host, so every start value is the one wgk_widen8 of the FP16 bias gave. The d0 head reads two packed tiles from the compact blob and the pixel head and the hidden history take their channels from kb_head_row, as k_block.hlsli does. Tiles, their order and the roundings are unchanged. KB_BASE_FORM (folded weight offsets) is an addressing change of the ports and is not taken: the native kernels keep their own loads. The declarations get the ports' argument lists and defines (KB_BIAS32=1, KB_COMPACT_HEAD_ARG=1). Verified: build_dx12.py --gfx 11 --model-k builds 18 kernels, exit 0; only k_stage2_e0, e1, d1, d1__rodd and d0_hp changed (13 of 18 DXIL byte-identical to before). The emulation comparison against the ports follows in the harness commit. Signed-off-by: Jonathan Shin <85975340+j0nsh1n@users.noreply.github.com>
j0nsh1n
added a commit
to j0nsh1n/wronggpu
that referenced
this pull request
Nov 23, 2026
… find_port user Main's phantoslayer21#288 added Device::require_d3d12_port, which resolves its kernel through find_port, so in a native run the signature it compares is the __g11 form's (that is the point of the check, and why the native declarations must carry the ports' argument lists). The source pin test_the_device_has_one_lookup_point_and_filters_the_manifest counted three users (definition, prepare, launch); it counts four now. Verified: clean.tests.test_dev_gfx11_native_k, 12 tests OK (with the declarations of the previous commit: the interface pin test_every_native_declaration_has_the_launch_interface_of_its_port passes again). Signed-off-by: Jonathan Shin <85975340+j0nsh1n@users.noreply.github.com>
j0nsh1n
added a commit
to j0nsh1n/wronggpu
that referenced
this pull request
Nov 23, 2026
…ports and gives them their operands Main's narrow ports now differ in their defines (KB_BIAS32, KB_BASE_FORM, KB_COMPACT_HEAD_ARG), so the harness's fixed groups of "one library per set of defines" no longer hold: k_native_check.groups_by_defines splits the port names by the declarations' own defines. The launches of the kernels that take phantoslayer21#288's operands (k_native_check.NARROW_BIAS32) get the FP32 bias plane and d0's compact head appended, built by k_plan_bridge.narrow_d3d12_args from the same weight blob (k_port_check does the same); the stage check's case files (prepare) carry them as buffers and the manifest tokens (s184:p19.b32,p and ,p,p,p). The emulator stages the head row table (.inc) next to the headers and turns a const int table into a constexpr one for its C++ class body. Verified (CPU, clang++): test_k_native_g11_emu 6 tests, test_k_native_check 1 test and test_dev_gfx11_native_k OK: every narrow stage, both window counts, three size sets and offsets, both round-to-odd forms and d0's head and hidden history give the port's bytes (and NumPy within spec 49's limits), the wrong-row-table negative control is caught, and the stage check's own negative control. Broken on purpose, each caught and restored: the plane's b2 offset moved by 16 (test_native_against_reference_and_port red), d0's head read from the full blob instead of the compact one and a wrong head row index (test_d0_heads_and_hidden red). Whole 18-module native / gfx11 set: 162 ran, 25 skipped, 0 failures. Signed-off-by: Jonathan Shin <85975340+j0nsh1n@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.
What changed
Prewiden the FP16 bias planes and fold weight offsets for Model K's narrow e0, e1, d1, and compact d0 stages. Pack the 32 live d0 head rows into two WMMA tiles and preserve the logical row mapping for the compact and hidden epilogues. Rebind the softmax source digest after the native report gate passed.
Initial timing against eff8ed7
Four alternating ABBA/BAAB blocks per shape, 1,500 frames per leg. A and B used the same runtime build flags and loaded DXIL from disk. A's reviewed phi-fast shaders were verified against the
eff8ed7source tree.1b975fbba17891e35fb3d1ab49ad8f90Gates
eff8ed7and REFS. Forced round-to-odd also matched all 600 odd frames and six saved frames. The odd raw state and output comparison matched 516,093,680 bytes, including compact and full head and recurrent state.k_smx_test=reportreproduced 133 of 133 stored HIP hashes in each of mix and round-to-odd, with zero hash or probe mismatches.Review fixes
Head 731ba36 passes the compact d0 head and FP32 bias plane as separate D3D12 arguments and preserves the original 48-row head in the shared stage parameters. The hybrid runtime refuses missing or incompatible narrow ports and rejects null argument storage before packing.
The replay passes the original arguments to HIP and supplies the packed weights and bias planes to D3D12. The head row test covers every pixel and hidden channel, and DXC rejects a full-head shader built with the compact bias plane.
Four alternating ABBA/BAAB blocks per shape used 1,500 frames per leg against eff8ed7. The noise floor is max(5 us, twice max A/A).
1b975fbba17891e35fb3d1ab49ad8f90