Skip to content

Post reference: motion candidate positions in float32, as the kernel computes them - #142

Merged
phantoslayer21 merged 1 commit into
mainfrom
model-l/post-ref-f32
Nov 14, 2026
Merged

phantoslayer21 merged 1 commit into
mainfrom
model-l/post-ref-f32

Conversation

@phantoslayer21

Copy link
Copy Markdown
Owner

The post reference (clean/reference/post.py) now computes the motion candidate positions in float32, as the kernel
does: the render position, the point reads' texel, m_center's bilinear read and q = X + m (spec item 3: float32
unless stated; kernel order of post.hip pos_x / pos_y, motion_bilinear, q = X + m). The gather, history
sample and blend stay float64. Motion at output resolution is unchanged.

Why: #133's real-weight run failed post on one frame. The cause: the validity test 0 <= q <= D is a
discontinuity, and the center candidate's position landed exactly on the bottom edge. In float32 (the kernel)
qy = 108 = Dh, so valid, and the history sample was used; in float64 (the reference) qy = 108.0000089, so invalid,
and the fallback was used. That pixel was 79 FP16 ulps and 6 reduced codes apart. With the center candidate taken as
valid, the old reference reproduced the kernel's history exactly (0 ulp in all three channels). The gather was not
involved (W 1.2588 in float64 and 1.2589 at the kernel's half precision).

Each multiply and add is rounded on its own. Fused multiply-adds were tried against the kernel's outputs: fusing the
bilinear kept the edge case apart, and fusing the position matched fewer reduced codes.

Record

Saved HIP outputs of #133's runs (main 26eb21e + #133, l_frame_check.py, GPU slot), re-compared on the CPU with this
reference; no new GPU run.

run post: values differing / compared (old -> new) frames failing (old -> new)
Model L, real weights (converter's model.wgcm, SHA-256 d3c04019...ad806) 1179 -> 1107 / 1443420 frame 6 -> none
Model M control (same run) 1021 -> 910 / 1443420 none -> none

The full --compare now passes for real-weight Model L: every stage on all 11 frames. Largest post difference with
real weights: 79 -> 2 FP16 ulps in the history, 6 -> 1 in the reduced codes.

Against the same saved kernel outputs, the synthetic runs: Model L unchanged (8 reduced codes differ, max 1); Model M
reduced codes differing 13 -> 10.

Model M values that change in the reference itself (old against new reference on post.random_inputs, 720
cases: 6 sizes including odd D, 60 seeds, with and without reset, motion scale 3 to 12): 30 of 17,719,920 history
values and 46 display values (in 57 cases), 0 of 4,420,080 reduced codes. These are FP16 roundings at
float32-level position differences.

Tested

  • test_post_reference (7), test_motion_hi_reference (13), test_model_filter (19), clean/l/tests/test_l_recon
    (14): pass.
  • The CPU re-compare above.

Not tested

  • The *_emu post tests (they need the host emulator library and skip on Windows, as on CI).
  • No new GPU run. The Model L reconstruction reference (clean/l/reference/recon.py) still forms its candidate
    positions in float64 (same pattern); it is not in the frame yet and is not changed here.

Refs #89

…computes them

The validity test 0 <= q <= D is a discontinuity. With real Model L weights a candidate position
landed exactly on the bottom edge: float32 (the kernel) gave qy = 108 = Dh, valid; the reference's
float64 bilinear and sum gave 108.0000089, invalid, so it took the fallback where the kernel took the
history sample (79 FP16 ulps, 6 reduced codes apart on that pixel).

reconstruct now computes the render position, the point reads' texel, m_center's bilinear and
q = X + m in float32 in the kernel's order (post.hip pos_x / pos_y, motion_bilinear), each operation
rounded on its own (fused multiply-adds there were measured to match the kernel less well). The
gather, history sample and blend stay float64; motion at output resolution is unchanged.

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 03:44
@phantoslayer21
phantoslayer21 merged commit 34197ba into main Nov 14, 2026
9 checks passed
@phantoslayer21
phantoslayer21 deleted the model-l/post-ref-f32 branch November 14, 2026 04:22
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