Skip to content

Model L reconstruction kernel l_post_recon (HIP, HDR) and its GPU check - #128

Merged
phantoslayer21 merged 3 commits into
mainfrom
model-l/p12-hip
Nov 14, 2026
Merged

phantoslayer21 merged 3 commits into
mainfrom
model-l/p12-hip

Conversation

@phantoslayer21

@phantoslayer21 phantoslayer21 commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Refs #89

l_post_recon (clean/l/kernels/l_post.hip, code object l_post.co) is Model L's reconstruction kernel, HDR. It
has Model M's post_recon arguments, buffers, layouts and grid, with Model L's arithmetic.

Colour gather in the model's precision (as the spec side confirmed it, for Model L and Model M):

  • fused target positions;
  • FP16 tap offsets and an FP16 exponent with the fused cross term (C1);
  • float32 weights flushed to +0 below 2^-126;
  • FP16 weights into half accumulators;
  • a float32 sum of the unrounded weights;
  • a 4 x 4 window, taps i outer, j inner.

The oracle (clean/l/reference/recon.py, gather_half, table entry "gather": "half") computes the gather the
same way, so the kernel and the oracle agree on which weights underflow. No pixel is excluded any more. This settles
the two gather regimes:

  • total weight 0: the zero-weight values (history -1.4404296875, display 0, reduced 0);
  • total weight > 0 with every FP16 weight 0 (e.g. extreme coefficients at 0.023 to 0.0516 from a texel centre):
    all features 0, so the output is the candidate history.

After the gather:

  • history candidates are decoded and divided by the previous exposure, combined with one fused multiply-add
    w1 L1 + (w2 L2), times the current exposure;
  • an invalid or reset sample falls back to the plain linear colour;
  • the blend is the fused form beta' = fused(alpha (1 - beta-bar) + beta-bar), H^ = fused((C - Hl) beta' + Hl);
  • the decode passes a NaN through.

The file includes Model M's clean/kernels/post.hip for its other functions and does not change it. Model M's
reference (clean/reference/post.py) also keeps its float64 gather: the table's Model M entry keeps
"gather": "float64", and the byte-exact reduction test to Model M's oracle still holds.

Tested

GPU record: RX 9070 XT, locked GPU slot model-l-post-3, run on head b055edb, 2 seeds, synthetic data.
clean/l/runner/l_post_check.py. This replaces the earlier record of 2a37dbd.

Harness:

  • every output buffer starts filled with a non-zero sentinel (0xA5) and has 64 bytes of sentinel slack;
  • every defined byte is compared: full-history RGB and alpha (0), display pixels, reduced codes' three 10-bit fields
    and top 2 bits (0);
  • no slack byte may change;
  • a negative control (the first case with the jitter moved half a render pixel) must fail the criteria. Result: it
    fails, as required.

14 cases, all pass:

  • 8 random cases (D / render about 2.25 and exactly 3, odd sizes, jitter, random exposures, reset):
    • history: 7 of 82,446 FP16 values differ, each by 1 ulp;
    • display: 9 of 82,446 differ, each by 1 ulp;
    • reduced codes: 0 of 20,322 differ;
    • alpha 0, top bits 0, slack untouched everywhere;
    • largest mean error / RMS: 2.8e-7.
  • Extreme coefficients C = (65504, 65504, 0) at Quality ratio, previously excluded pixels now compared: the
    earlier record (2a37dbd) compared only the 883 of 950 pixels per seed where the float64 oracle's total weight was
    0, and excluded the other 67 per seed (134 in all). Now every pixel is compared: 950 per seed. Result: 0 of 2,850
    history values and 0 of 2,850 display values differ per seed, and 0 reduced codes. With the gather in the model's
    precision, 943 and 941 pixels have total weight 0 (883 under the old float64 gather). The other pixels are compared
    like any other.
  • Known answers (D = R, every target offset from a texel centre by the jitter):
    • offset 0.1: total weight 0 on all 192 pixels; history -1.4404296875, display 0, reduced 0;
    • offset 0.05: weight > 0 but every FP16 weight 0; the history is exactly h(E(linear colour x e)), the reset
      fallback.

Criteria: Model M's acceptance for its own reconstruction kernel (clean/tests/test_post_emu.py): no non-finite
value, at most 0.01 % of FP16 values more than 1 ulp off, at most 1 % differ, mean error at most 0.1 % of the RMS;
reduced codes within 1, at most 1 % differ. These thresholds are Model M's: a float32 kernel against a float64
oracle. They are to be tightened once a kernel-order model of the reconstruction exists.

CPU: python -m unittest discover -s clean/l/tests -t . passes. New: the Q3 constants (A = -47264, eps = -472.5
at offset 0.1) and the offset-0.05 / 0.1 known answers in the oracle.

Model M code objects: clean/runner/m_codeobjects_compare.py --base origin/main (base vs this head, every
Model M code object of build.py --no-runtime --variants, head b055edb): 84 base / 84 head, all identical.

Not tested

  • The LDR kernel (planned; the oracle has the confirmed LDR path).

  • Motion at output resolution.

  • Byte-exactness against a kernel-order model. Through post.hip's helpers, the kernel keeps Model M's forms for:

    • the Catmull-Rom weights (cr_weights, float32 Horner, not C2's fused w0 and w1);
    • the hardware exp2, reciprocal and divisions.

    This belongs to the Model M fidelity decision.

  • Tiny exposures (spec question Q4, pending).

  • The D3D12 port: kern2.

…r-colour history and fallback, NaN-passing decode; GPU check against the oracle

Refs #89

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
@phantoslayer21
phantoslayer21 marked this pull request as ready for review November 14, 2026 02:23
…e and kernel), fused blend; GPU check with sentinels, every output byte, extreme-coefficient known answers and a negative control

Refs #89

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
@phantoslayer21
phantoslayer21 merged commit dbdfaff into main Nov 14, 2026
9 checks passed
@phantoslayer21
phantoslayer21 deleted the model-l/p12-hip branch November 14, 2026 02:48
j0nsh1n pushed a commit to j0nsh1n/wronggpu that referenced this pull request Nov 14, 2026
… Model M's post

Step 5 of Model L's frame runs l_post_recon (l_post.co, phantoslayer21#128; clean/l/FORMATS.md
step 5) on Model M's unbanded post_recon route: post_recon's arguments and
buffers, 8-byte history, the base coefficient format, then Model M's unbanded
output filter.

- clean/runtime/runtime.cpp: for model=L, l_post.co is loaded and the post kernel
  is l_post_recon. Model M's post kernels (post_kernel / WG_POST_KERNEL) and
  post_pack=p12 are refused for Model L. LDR colour (WgRtConfig.hdr = 0) is
  refused: l_post_recon is HDR and Model L's LDR kernel is not written yet.
- clean/tests/runtime_frame_trace.cpp: --hdr=<0|1>; l_post_recon's arguments
  decoded (P{rw,rh,dw,dh,reset} for WgPostParams).
- test_l_runtime_frame.py: Model L's frame equals Model M's on the post_recon
  route with steps 2, 4 and 5 replaced; l_post_recon's arguments against the
  named buffers and the post blob; its parameters and grid; Model M's filter
  follows; three more mix-ups fail; the LDR and post-kernel refusals.
- test_l_runtime_abi.py: l_post.co's l_post_recon against the recorder's kinds
  (WgPostParams 64 bytes).
- clean/l/runner/l_frame_check.py: Model L runs with HDR colour; its post and
  filter against clean/l/reference/recon.py; --plain runs frames without
  random_inputs' special values.

Refs phantoslayer21#89

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant