Skip to content

Model L's own reconstruction on the D3D12 frame (runtime option l_post=own) - #162

Merged
phantoslayer21 merged 7 commits into
mainfrom
model-l/d3d12-own-post
Nov 14, 2026
Merged

phantoslayer21 merged 7 commits into
mainfrom
model-l/d3d12-own-post

Conversation

@phantoslayer21

@phantoslayer21 phantoslayer21 commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Refs #89

Runs Model L's own reconstruction in the native D3D12 Model L frame, behind the runtime option l_post=own. The pipeline is l_post_recon_p12 (#141), then the analytic filter w64/post_filter_c1_s4 (#147), in place of Model M's fused pack12 post. The default doesn't change: Model M's fused post (l_post=m) runs until the release lead's game screenshot comparison is done.

What

  • clean/runtime/runtime.cpp
    • Option l_post=m|own. own is a Model L option. On HIP it changes nothing, because Model L always runs its own post there.
    • On native D3D12 (l_own_post_setup), the route becomes the unbanded pack12 route:
    • What own refuses:
      • LDR colour, because l_post_recon is HDR.
      • Any change to the default post or filter.
      • A build whose manifest lacks one of the route's ports. The missing ports are named, and there is no fallback.
    • The kernels line now names the route: l_post=l_post_recon, or l_post=m_pack12 for the default D3D12 route.
    • manifest_missing() is built on Model L on D3D12: the decoder block with l_coef_pack12 as its epilogue #159's manifest_kernels().
  • The game's direct route. On this route the game's textures are bound directly, and l_post_recon_p12 reads colour from a buffer. Two D3D12-only kernels are added in clean/dx12/kernels/l_post_direct.hlsl (co=-, rs=direct):
    • l_direct_color stages the colour texture into color_net (16 bytes a pixel) using native_direct_normalized_color. These are the staged route's bytes: the Converter's dense RGBA with alpha +0, divided by pi as color_divide does when pi != 1.
    • l_direct_store writes the filter's FP32 output into the game's output texture:
      • pi applied as scale_rgb (native_direct_scale) when pi != 1;
      • with output_rne16 (the RGBA16F output-copy rows), framebuffer_half's bytes (±65504 clamp, round to nearest even), as post.hlsl's direct forms store them;
      • alpha 1.
    • On this route the runtime also allocates color_net and the FP32 output buffer, and validate_native_direct_config / validate_native_direct_frame accept the route.
  • clean/l/runner/l_d3d12_own_post_check.py (new): the GPU check below, on l_frame_check.py's frames, models and build. l_frame_check.py itself is unchanged.
  • clean/l/runtime/tests/test_l_runtime_frame.py (CPU recorder):
    • D3D12.test_own_post covers sizes that change, a reset, and a frame of render size D (the non-pack12 fallback). It checks:
      • every launch argument's buffer or blob;
      • l_post_recon_p12 after the fold;
      • the filter's grid and arguments (display image → output);
      • no fused post.
    • D3D12.test_own_post_refusals covers the refusals above, each missing port by name, the default still m_pack12, and HIP unchanged.
    • clean/tests/runtime_frame_trace.cpp decodes l_post_recon_p12 and post_filter_c1_s4.

GPU record (merged tree 7e8778b, one GPU slot per run)

Frames: l_frame_check's sequence.

  • Sizes: render 96x64, 80x48 and 77x45; output 120x72; D 180x108.
  • 11 frames, with game resets, a size change and both parities.
  • pre-exposure 1.25, auto exposure, HDR, synthetic Model L.
check result
D3D12 l_post=own against the HIP Model L frame (l_post_recon + the same filter), every output both write, byte for byte 11 / 11 frames identical, 0 differing. Covers post history, reduced history, display image, output and state. The pack12 images unpacked equal HIP's A, B, C.
↳ not written on D3D12 (fusions) enc1.merged
negative control: one output bit flipped in a copy of D3D12 frame 1 caught (1 differing value)
D3D12 l_post=own, fusions off, per stage against the CPU reference on its own inputs 11 / 11 frames pass
↳ post against clean/l/reference/recon.py, Model L's post acceptance 11 / 11 frames
↳ post over the whole run (history, display) 24 of 641,520 values more than 1 ulp off (each); pass
↳ filter against recon.output_filter 11 / 11, 0 of 285,120 outside
↳ b5 b5 as one unit (b0 … b5 chained in the reference from enc2.merged) is off on frame 1. Per stage it passes there. See the note below the table.
D3D12 default kernels against the fusions-off run 11 / 11 identical
direct route against the staged route (native_direct_test, Model L, l_post=own, pi 1 / 1.375, exposure modes 0 / 1 / 2, resets) check mode: 16 / 16 frames byte-identical. All 24 colour / depth / motion / output format combinations: 96 / 96. 0 debug-layer errors. Mutation caught.

b5 on frame 1. The chained reference (b0 … b5 as one unit, started from enc2.merged) parts from the runtime on frame 1. The two runs below show the runtime's b5 is right per stage:

  • D3D12's b5 bytes equal those of HIP's six-launch run;
  • in that run b5 passes against the reference on its own b4.

The script checks this explicitly and records the frame.

The launch trace of the direct-route format run shows the route:

  • l_post_recon_p12 and w64/post_filter_c1_s4 192 times each (96 direct + 96 staged frames);
  • the decoder fold 192 times;
  • l_direct_color and l_direct_store 96 times each;
  • color_divide and scale_rgb 48 times each, on the staged frames with pi != 1;
  • no fused post.

Controls (same build):

  • l_frame_check --compare-d3d12, the default route:
    • Model M D3D12 against HIP: 11 / 11 identical.
    • Model L per stage: 11 / 11.
    • Model L defaults against stages: 11 / 11.
    • Model L post against Model M's post reference: 11 / 11.
  • native_direct_test without the option: 16 / 16, running post_tf4_dl_* as before.
  • HIP l_frame_check --compare: L and M pass, 11 / 11.

Tested

  • The GPU record above.
  • CPU tests:
    • clean/l/runtime/tests (33);
    • clean.tests.test_runtime_frame_trace (7);
    • line endings.
  • Public gates (LOOK lines at the baseline, none in these files) and the leak scan (0 hits).

Not tested

  • The fallback route for frames the pack12 kernels don't take (l_coef + l_post_recon) on the GPU in the frame. The recorder test covers its launches, and both ports are byte-exact on their own (Model L: D3D12 port of the reconstruction kernel l_post_recon, byte for byte against its HIP kernel #136 and the l_coef port). The check's frame sequence has no such size.
  • output_rne16 = 1 (the RGBA16F output-copy rows, the game executor's default route) on the GPU. native_direct_test binds output_rne16 = 0. The store uses framebuffer_half's clamp and wg_f2h, as post.hlsl's direct forms and the direct output table do.
  • A game. The release lead runs the screenshot comparison of l_post=own against the current post.

Review fixes (REVIEW-162), merged tree f425e99 (main 9a42f4b)

Offline GPU comparisons against HIP, one GPU slot each.

  • Engine: l_d3d12_ops_check.py's raw-byte engine.
  • Every output buffer is filled first with its back end's sentinel (HIP 0xA5 / D3D12 0x5A), followed by 64 slack bytes that neither back end may write.
  • Each run has a half-grid negative control.

1. Fallback route (recon2_supported false). clean/l/runner/l_d3d12_fallback_check.py --seeds 2. The chain is run as the frame runs it:

  • unpacked l_coef;
  • then l_post_recon on HIP's A, B, C;
  • then w64/post_filter_c1_s4 on HIP's display image.

The 5 frames, D = (3 O + 1) / 2:

R O D notes
150x90 121x73 182x110
100x60 77x45 116x68 specials, exposure pair
96x60 64x40 96x60 (= R) reset
130x70 99x57 149x86 jitter 0.1, exposure pair
11x8 7x5 11x8 specials

Every launch has edge tiles: D columns are not a multiple of 32, D row pairs not of 8, O columns not of 40, O row pairs not of 8, and R is not a multiple of 32.

step cases identical bytes compared (with slack) differing
l_coef 10 10 1,380,480 0
l_post_recon 10 10 1,494,328 0
w64/post_filter_c1_s4 10 10 493,504 0
Model M control swin_block_c96_nc 12 12 1,055,808 0

Negative control (l_post_recon with half its workgroups): caught, 146,011 differing bytes.

2. The output_rne16 = 1 RGBA16F copy store. clean/dx12/tests/post_tf_d3d12_check.py --store --seeds 2.

  • HIP side: the output-copy rows, from post_filter_c1_s4_o16 (pi 1) or post_filter_h (pi 1.25, 1.375, 30000; pitch 8 O).
  • D3D12 side: w64/post_filter_c1_s4, then l_direct_store into an RGBA16F texture filled with 0x5A beforehand, with color_pi and output_rne16 = 1. kernel_replay's direct_params now takes both.
  • Result: 22 / 22 cases identical, both the RGBA16F rows (6,664,864 bytes) and the FP32 filter output (9,997,296 bytes). HIP's slack is untouched.
  • Negative control (the store with half its workgroups): caught, 20,914 differing bytes.
  • How the special values arise: dec_scale is chosen as 2^-22, 2^-8, 2^-12, ±infinity, a NaN with a payload, or an exposure pair with a NaN e; one case uses pi 30000.
  • Stored values (FP32 filter output times pi), 2,499,324 in total:
class count
NaN 34,068
past ±65504 57,618 (7,680 of them infinite)
FP16 subnormal range 90,861
exact FP16 rounding ties 305
  • Model M control on the same harness (--direct): orig_w64/post_tf_f32_p12_diet_vsit_direct 8 / 8 identical. The analytic direct forms: 10 / 10 and 10 / 10. Negative control caught.

3. kernel_sets.json (#154), regenerated: l_direct_color and l_direct_store are now in Model L's set. Model M: 46 kernels; Model L: 18.

Re-runs on the merged tree:

  • l_d3d12_own_post_check.py: against HIP 11 / 11 identical, negative control caught, per stage 11 / 11, defaults against stages 11 / 11.
  • native_direct_test with l_post=own, matrix: 96 / 96 frames, 24 formats, 0 debug-layer errors.
  • native_direct_test, default route: 16 / 16.
  • CPU: clean/l/runtime/tests (33), test_kernel_sets (3).

Finding 1 (the frame check's byte-identity gaps) is fixed by param's #165. After #165 lands, l_d3d12_own_post_check.py moves to its raw API (fill_sentinels / raw_outputs / raw_compare / negative_controls). Param has already run l_post=own with the fixed checker: 11 / 11 raw-byte identical, all negative controls caught.

Frame check on l_frame_check's raw-byte API (#165), head 0b89598 (main dc80ba5)

l_d3d12_own_post_check.py now uses fill_sentinels, raw_outputs, raw_compare and negative_controls.

  • Sentinels: before every frame each run fills its outputs with its own sentinel (HIP default 0xA5, d3d12_own 0x5A, d3d12_own_stages 0x3C).
  • Raw bytes: every output's raw defined bytes are compared. A missing output, an output of another size, or any differing byte fails the frame.
  • Not written by design: b0 … b4 on both runs (the bottleneck megakernel), enc1's merged map with the D3D12 default kernels (fusion pm), and the previous frame's state on the first frame. Each byte there must still hold its run's sentinel.
comparison (raw bytes) result
D3D12 l_post=own against the HIP Model L frame (28 outputs: post history, reduced history, display image, output, state, every stage) 11 / 11 identical; differing: none
↳ negative controls (a dropped history write, a dropped reduced write, a whole reduced write, a missing output) 4 / 4 caught
D3D12 default kernels against the fusions-off run 11 / 11 identical; negative controls 4 / 4 caught
fusions-off run, per stage against the reference (Model L's post acceptance; b5 of frame 1 per stage on HIP's six-launch run with the same bytes) 11 / 11; post over the run: history and display pass

The REVIEW-162 offline comparisons above still stand:

  • fallback route: 10 / 10 per step, with edge tiles;
  • output_rne16 = 1 RGBA16F copy store: 22 / 22.

…t=own)

Native D3D12, Model L: l_post=own runs l_post_recon_p12 (l_coef_pack12's images; l_coef + l_post_recon
where the pack12 kernels do not fit), then the unbanded analytic filter w64/post_filter_c1_s4, in place of
Model M's fused pack12 post. The default stays Model M's fused post (l_post=m); the kernels line names
the route (l_post=l_post_recon / m_pack12).

Direct-resource route (games): two D3D12-only kernels (dx12/kernels/l_post_direct.hlsl) stage the game's
colour into color_net with the staged route's values (native_direct_normalized_color) and store the
filter's FP32 output into the game's texture (native_direct_scale for pi, framebuffer_half bytes with
output_rne16, alpha 1). The direct route then gives the staged route's bytes.

Checks: CPU recorder (test_l_runtime_frame D3D12.test_own_post / test_own_post_refusals), and the GPU
check clean/l/runner/l_d3d12_own_post_check.py against the HIP frame and the reference.

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>

# Conflicts:
#	clean/l/runtime/tests/test_l_runtime_frame.py
#	clean/runtime/runtime.cpp
@phantoslayer21
phantoslayer21 marked this pull request as ready for review November 14, 2026 10:40
phantoslayer21 added a commit that referenced this pull request Nov 14, 2026
… trace per choice

- run.py: runtime_options_extra in the config and --extra on prepare / use-m /
  use-l (e.g. l_post=own, then --extra '' for the default post in the same
  session); set_options replaces the items it added before (timing, launch
  trace, the previous extra) instead of appending them again.
- run.py: each model choice writes its own launch-trace-<time>.txt; collect
  summarises every trace on its own.
- offline_create.py: --extra adds runtime options to Model L's runs.

Used for the Model L own-reconstruction game run (#162).

Refs #89

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…copy store; kernel sets

- clean/l/runner/l_d3d12_fallback_check.py: the fallback route (recon2_supported false: l_coef,
  l_post_recon, w64/post_filter_c1_s4), chained as the frame runs it, against HIP byte for byte, with edge
  tiles at sizes that are not tile multiples; sentinels, slack, negative control, Model M control.
- clean/dx12/tests/post_tf_d3d12_check.py --store: HIP's output-copy rows (post_filter_c1_s4_o16 /
  post_filter_h) against w64/post_filter_c1_s4 then l_direct_store with output_rne16 = 1 into an RGBA16F
  texture, with FP16 subnormals, values past 65504, infinities, NaN and rounding ties.
- kernel_replay: direct_params takes color_pi and output_rne16.
- kernel_sets.json regenerated: l_direct_color and l_direct_store in Model L's set (Model M: 46).

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…nels, raw defined bytes, negative controls

Each run fills its outputs with its own sentinel before every frame and records every output's raw defined bytes; both raw comparisons (against HIP, defaults against stages) fail on a missing output, another size or any differing byte, and carry l_frame_check's record-level negative controls.

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
@phantoslayer21
phantoslayer21 merged commit 93461bb into main Nov 14, 2026
9 checks passed
@phantoslayer21
phantoslayer21 deleted the model-l/d3d12-own-post branch November 14, 2026 13:28
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