Repository navigation
[0.6.6] L post recon (D3D12): history encode through the driver's conversion fold, with a start-up guard - #236
Draft
phantoslayer21 wants to merge 2 commits into
Draft
phantoslayer21 wants to merge 2 commits into
phantoslayer21 wants to merge 2 commits into
Conversation
…fold, guarded by a start-up probe, a differential self-test of the real ports and a per-site sensitivity control - l_post_recon_p12 gets three ports: needs=fold (the encode as mad(log2, kEncK, 0) into the RNE conversion, which the driver folds into v_fma_mixlo/mixhi_f16), needs=nofold (round to odd, exact on any driver) and needs=control (the encode rounded twice, never selected to run) - start-up guard (device_d3d12 fold_probe), all steps must pass, else the no-fold port runs: l_fold_probe against exact expected bytes; the fold and no-fold ports on a crafted frame (fold_selftest.h: per encode site 13 FP32-product ties a second rounding gets wrong, each at predicted-log2 offsets -8..8 ulp) with equal raw bytes; the control port differing from the no-fold port at each of the six sites; bounded queue waits (a timeout fails device creation) - build_dx12: needs=fold|nofold|control, isa= rules with literal-tied site counts (fold: six kEncK sites; control: none) - l_post_edge_check: fold and no-fold legs; test_fold_probe: generated headers, the -8..8 ulp shift test (N = 13 per site), ports and ISA rules Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…single-site mutants (review fixes) - the fold port stores each pixel's three FP32 conversion inputs when the params' pad1 holds a side buffer (0 in every frame; the same compiled shader); RGA: the six v_fma_mixlo/hi_f16 .., 0x3dddf184, 0 sites keep their form, the side store writes exactly the registers they read, no s_round_mode - the start-up guard: fold and no-fold ports equal in raw bytes, and from the fold port's own stored inputs and codes, per site (row of the pair x channel) at least 8 FP32-product ties a second rounding gets wrong and every code the exact one-rounding RN16(xe kEncK) computed on the host; else the no-fold port - the separate control port is removed (needs=control gone from the build, the devices and the tests) - LP_MUTSITE 1..6: one site (3 row + channel) rounded twice, the other five folded (negative controls, never shipped) Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
phantoslayer21
force-pushed
the
kspeed/l-post-fold
branch
from
November 15, 2026 10:11
fbb1355 to
1e03993
Compare
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.
Status: 0.6.6 (not for 0.6.5). Draft, not to be merged in this form. The fold is dropped for 0.6.5: Model L's speed for 0.6.5 is #231 + #240 as merged; this PR's extra -0.035 ms is given up.
Review findings
pad1non-zero (side output on), while real frames run it withpad1= 0. The side stores consume the six conversion inputs, so the shader the driver compiles has two paths, and nothing establishes that the conversions executed withpad1= 0 are the ones the guard tested (a driver may lower the six conversions differently per path). RGA shows the same six fold sites, but that is not the installed driver's lowering. References:clean/dx12/kernels/l_post.hlsl(theP_pad1 != 0side output),clean/runtime/device_d3d12.cpp(the guard),clean/runtime/runtime.cpp(PostParams p = {}in frames).LP_MUTSITE) on the GPU; bounded guard waits (a timeout fails device creation); the edge runner's mutant legs require a successful run with full outputs.For 0.6.6
Either an encode whose correctness does not depend on the driver's fold, or a guard that checks the output of the
pad1= 0 path itself (the exact PSO and path real frames run).Follow-up to #231: Model L's history encode in
l_post_recon_p12(D3D12) through the driver's conversion fold, the part #231 left out. The fast port runs only after a start-up guard on the device has shown that the driver folds the encode in the real post shader. Otherwise the exact port from #231 runs.What changes
Two ports of
l_post_recon_p12(clean/dx12/kernels/l_post.hlsl,hlsl/l_post_encode.hlsli):needs=fold: the history encode asmad(log2(..), kEncK, 0)into the driver's round-to-nearest-even matrix conversion. The driver compiles it tov_fma_mixlo/mixhi_f16 .., kEncK, 0(HIP's own instruction: one rounding).needs=nofold: L post recon (D3D12): fewer VALU in the tap, history and encode paths, byte-identical, with a guarded conversion fold (draft) #231's round-to-odd encode, exact on any driver.The fold port has a self-test side output. When the params'
pad1word is non-zero (it is zero in every frame; the same compiled shader), the port also stores each pixel's three FP32 conversion inputsxeat that address.Build check (
build_dx12.py):isa=rules count only thex * literal + 0sites. The fold port must have exactly sixv_fma_mixlo/mixhi_f16 .., 0x3dddf184, 0(three channels, two rows) and nos_round_mode.Start-up guard (
clean/runtime/device_d3d12.cpp). Every step must pass; otherwise, or on any error, the no-fold port runs:l_fold_probeon adversarial inputs of the shared encode expression, against expected bytes from exact rationals (clean/runtime/fold_probe.h,gen_fold_probe.py);clean/runtime/fold_selftest.h,gen_fold_selftest.py): the fold port, with its side output on, and the no-fold port, each with its outputs pre-filled with its own sentinel. The fold port's raw output bytes (full history, reduced history, display) must equal the no-fold port's. From the fold port's own values in the same PSO, its stored inputsxeand its stored history codes, each of the six encode sites (row of the pair x channel) must pass two checks:xex kEncK), computed exactly on the host (the product is exact in a double; one rounding to FP16).The frame makes each full-history value exactly the render colour (render size = output size, jitter 0, reset, exposure 1, post scale 0, codes and kernel shape 0). Each history code is therefore the encode of a crafted value, with log2 computed by the shader. Per site it holds 13 FP32-product ties that a second rounding gets wrong. Each tie is placed at predicted-log2 offsets -8 to +8 ulp, so a device log2 up to 8 ulp off still lands on them. The frame also holds zero and FP16-subnormal products, the encode floor, and extra ties among negative products. Check (a) counts the ties among the values this device actually fed the conversion, whatever its log2 returned.
Every queue wait of the guard is bounded (10 s). A timeout fails device creation, and its allocations are kept rather than freed under a running queue. The result appears once in the runtime's ready line. The hybrid device never takes the fold port.
Tests:
clean/dx12/tests/test_fold_probe.pypins both headers to their generators and checks the ports and ISA rules. Its shift test moves every predicted log2 by the same e ulp, for each e from -8 to +8, and asserts at least N = 13 detecting ties per site.clean/l/runner/l_post_edge_check.pygains the fold leg (the fold port must be selected) and the no-fold leg (WG_TEST_FOLD_PROBE_FAIL=1).LP_MUTSITE 1..6are single-site negative controls (never shipped): site k-1 = 3 x row + channel is rounded twice, the other five sites keep the fold.Results
RGA (fold port with the side output, against the earlier fold port without it): the same six sites,
v_fma_mixlo_f16 / v_fma_mixhi_f16 v#, v#, 0xf184, 0(literal 0x3dddf184), nos_round_mode. The side output adds twobuffer_store_b96(one per row) and 23 VALU. Each store writes exactly the three registers its row's fold instructions read (row 0: v11-v13, row 1: v15-v17). The no-fold port has no such site. The build's ISA check passes.Guard on the GPU (RX 9070 XT): "conversion-fold probe and self-test passed (detecting ties per site 22/22/19/18/18/20, every code the one-rounding encode): the fold ports run".
Six single-site mutants (
LP_MUTSITE 1..6, each with exactly five fold sites in its ISA): each makes the guard choose the no-fold port on the GPU. The fold port differs from the no-fold port in 22, 22, 20, 18, 18 and 20 bytes. Applied offline to each run's dump, the own-value check finds wrong codes at exactly the mutated site (22, 22, 19, 18, 18, 20 values, its detecting ties) and none at the other five.Frame check (
l_d3d12_own_post_check.py, 13 frames; raw bytes against HIP, sentinels, record-level negative controls):LDR leg: 13/13.
Edge check (14 sizes x 12 motion kinds): fold port 672/672 identical, no-fold port 168/168, 0 differing pixels in each edge band, the counter's expectations met, both hs mutants and the half-grid control caught, HIP vs the reference 336/336.
Timing on the direct route (test_interop_d3d12 hipbench, executor dx12), 1440p Quality, synthetic L model, 5 interleaved rounds. The base is the same runtime library with main's kernels:
Paired rounds: -27.5 to -46 us, median -35 us. Every timed run logged the guard passing.
Tested
test_fold_probe.py,test_post_edge_cases.py,test_kernel_sets.py.Not tested