Repository navigation
Model K on D3D12: --model-k, struct arguments, the port check, k_expo_scalars and k_warm - #201
Merged
Merged
Conversation
… the first ports (k_expo_scalars, k_warm) Refs #15. build_dx12.py builds clean/k/dx12/kernels only with --model-k (or --only), so Model M's and Model L's kernel sets and DXILs stay as they are; kernel_sets.json has a model_k list. A kernel that takes a struct with pointers by value declares it as s<N>:<fields> (clean/runtime/struct_args.h), supported by the hybrid and the native device; a port that uses binary64 fma or division is marked fp64=ext and dropped on an adapter without them. kernel_replay chains take struct arguments. clean/k/dx12/k_port_check.py compares a family of ports with its HIP kernels byte for byte. k_expo_scalars is ported and checked; k_warm (no HIP kernel) is checked against its definition. Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
phantoslayer21
marked this pull request as ready for review
November 14, 2026 21:08
This was referenced Nov 14, 2026
This was referenced Nov 14, 2026
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 #198 (and through it #194): the diff is against that branch.
First D3D12 piece of Preset K: the build option, struct arguments, the byte-for-byte check, and the first two ports.
k_expo_scalarsis byte-identical to its HIP kernel (the pilot of the family check);k_warmis a D3D12-only cache warm-up with no HIP kernel.What changes
build_dx12.py: Model K's kernels (clean/k/dx12/kernels,co=k_*.co) are built only with--model-k, or when--onlynames them. Without the option the kernel set is Model M's, and with--model-lModel L's, as before.kernel_sets.jsonhas amodel_klist;test_kernel_sets.pychecks that no K kernel is in the other sets and that--model-kadds only K kernels.clean/runtime/struct_args.h, new): a HIP kernel that takes a struct with 64-bit pointers by value declares it ass<N>:<fields>(p<n>pointers,b<n>copied bytes,x<n>skipped bytes). The hybrid device (device_dx12.cpp) and the native device (device_d3d12.cpp) turn each pointer into an arena offset. CPU test:clean/tests/test_struct_args.{cpp,py}.fp64=ext: a port that uses binary64 fma or division (the exact input stage will) is marked in the manifest, and both devices drop it when the adapter lacksDoublePrecisionFloatShaderOps.kernel_replay: chain steps takeB:<file>(struct by value) andS:<file>:<offset>=@<id>,...(struct with pointers).clean/k/dx12/k_port_check.py(new): the byte-for-byte check, one family at a time (--prepareon the CPU,--runin a GPU slot). Raw bytes; 64 bytes of slack per output with HIP0xA5/ D3D120x5Asentinels; special values among the inputs; a negative control; Model M'sscale_rgbas the harness control. README inclean/k/dx12/.k_expo_scalars(+_direct, the native executor's texture form) andk_warm.Tested
test_kernel_sets(7),test_struct_args(1) pass; line endings clean; the runtime library (hybrid and native devices) compiles.k_port_check.py --run --family expo,warm --seeds 2:expo: 72 of 72 cases byte-identical to HIP (hdr/LDR, value/texel/none, auto-exposure, first/reset, e1/e2 not 1, a pre-exposure reciprocal of 0, infinity, NaN, FP16 specials: zero, -0, subnormals, 65504, 65520, 1e6, infinity, NaN), every slack byte its own sentinel. Negative control (the port given another exposure than HIP) caught, 8 bytes differ. This kernel has one workgroup, so there is no half-grid control; the different-input control takes its place.warm: 12 of 12 cases as defined (13 pointers and the other bytes through the struct argument; the dummy is written exactly when the key equals a lane's loaded value).scale_rgb: identical.pr4-expo-warm.jsonof the run (counts and verdicts only).exposure_pair_diet,scale_rgb,color_divide,input_encoder,expand_c96,patch_merge_c64,l_coef,l_post_recon,l_linear_32_32_fused,l_direct_color,l_project_gather,lev/input_encoder) built from main (f4816cf) and from this branch: all 12 digests identical. No.hlslor.hlsliof Model M or Model L changed; their compile command is unchanged. Not the full 68-kernel build.public_gates.py: must-pass gates pass; the LOOK counts equal main's except 3 review lines for the HIP SDK path in the new usage text.Not tested
sargument and thefp64flag).k_expo_scalarsmeets one only with a pre-exposure above about 8.5e37; the check's inputs stay clear of them (README).