Repository navigation
Model K on D3D12: the narrow network stages, byte-identical to HIP - #204
Merged
Merged
Conversation
…cal to HIP Refs #15. Ports of k_stage_e2, k_stage_e0, k_stage_e1, k_stage_d2, k_stage_d1 and the two-window forms k_stage2_e0, k_stage2_e1, k_stage2_d1, plus the network's d0 forms k_stage2_d0_hp and k_stage2_d0_hidden (hidden history and compact pixel head): the exact FP32 path only; the FP16-accumulating and FP8 forms are not ported. The port check runs the stage runner's launch plans on HIP and replays them on D3D12 (k_plan_bridge.py); kernel_replay chains take offset pointers and null arguments. Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
A replay output of an earlier run could stand in for one that a failed replay did not write; each run now has its own folder, and a failing replay fails the run. 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.
Refs #15. Stacked on #201 (and through it #198, #194): the diff is against that branch.
Preset K's narrow network stages on D3D12, byte-identical to their HIP kernels on the exact FP32 path. Not ported, on purpose: the FP16-accumulating and FP8 forms of the stage kernels (the approximation modes); they stay HIP-only and opt-in.
What changes
clean/k/dx12/kernels/k_block.hlsland headershlsl/k_block.hlsli,k_common.hlsli,k_blkparams.hlsli,k_norm.hlsli: thek_blocktemplate with the instantiations ofk_block.hip:k_stage_e2,k_stage_e0,k_stage_e1,k_stage_d2,k_stage_d1;k_stage2_e0,k_stage2_e1,k_stage2_d1;_hp, the compact pixel head:k_stage2_d0_hp,k_stage2_d0_hidden.Argument
KBlkParamsby value ass184:p19.b32(the struct argument of Model K on D3D12: --model-k, struct arguments, the port check, k_expo_scalars and k_warm #201); the d0 kernels take the hidden pointer too.kernel_sets.json: ten kernels inmodel_k.k_port_check.pyfamilynarrow,k_plan_bridge.py(new): the stage runner's launch plans (k_stages.prepare, the same plans the HIP tests use) are run on HIP and replayed on D3D12 on the same input bytes.kernel_replaychains take pointers into a buffer (@id+bytes) and null arguments.clean/k/tests/test_k_plan_bridge.py: CPU test of the bridge (pointer fields, buffer and offset, chain steps).Tested
k_port_check.py --run --family narrow --seeds 2, one GPU slot, random stage weights (random_stage_params) and inputs, six block-level grids per kernel (8 x 8 to 40 x 24, odd sizes, fewer windows than a workgroup's among them) with window offsets from {0, 2, 4, 6}:0xA5, D3D120x5A); the part of a buffer beyond what the kernel defines (the head buffer of_hp) kept it too.scale_rgbthrough the same replay: identical.pr6-narrow.json(counts and verdicts only).test_k_plan_bridge(4),test_kernel_sets,test_struct_argspass; line endings clean.public_gates.py: must-pass gates pass; the LOOK counts equal main's.Not tested
Accepted exceptions (review decision, 2026-11-14)