Skip to content

Model L frame on native D3D12: Model M's native frame with Model L's encoder and decoder - #140

Merged
phantoslayer21 merged 5 commits into
mainfrom
model-l/frame-d3d12
Nov 14, 2026
Merged

phantoslayer21 merged 5 commits into
mainfrom
model-l/frame-d3d12

Conversation

@phantoslayer21

@phantoslayer21 phantoslayer21 commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Model L on native D3D12 (backend 3): Model M's native frame with Model L's encoder (step 2) and decoder (step 4).
The coefficients go through the pack12 store l_coef_pack12 (#131, #134) into Model M's fused pack12 post, which uses
the analytic-filter ports (#143, #145, #146). This is the reconstruction for the first game run; switching to Model
L's own l_post_recon_p12 (#141) and the analytic filter (#147) follows.

What changes

  • clean/runtime/runtime.cpp:
    • Model L is accepted on backend 3, in builds with WG_MODEL_L. On HIP (backend 0), Model L frame on HIP: its own reconstruction l_post_recon in place of Model M's post #135's route is unchanged;
      backends 1 and 2 still refuse Model L.

    • At create, every D3D12 port Model L needs that <build>/dx12/manifest.json lacks is refused by name ("not yet
      ported to D3D12: ..."); nothing stands in for a missing port. The list:

      • lev/input_encoder, or lev/input_encoder_direct on the game's direct-resource route;
      • the linears, l_swin_block_c32_enc_nc / _dec_nc, the two projections, l_coef_pack12;
      • dec1's own block swin_block_c64_add_ex_nc.

      Weights that need the clamped blocks are refused (only the _nc forms are ported).

    • Off HIP, Model L does not take Model L frame on HIP: its own reconstruction l_post_recon in place of Model M's post #135's post-route override: pack12 is its default and required on backend 3, and
      LDR is not refused there, since Model M's post takes both. Frames the pack12 post does not take (render size too
      close to D) run l_post_recon and the analytic filter, both ported.

    • The fusions pm, mb and rv apply as for Model M. xe, xo and xd need Model M's fused pack12 decoder, so they are
      off; dec1 runs its own block.

    • Direct-resource route:

      • the analytic fused post (post_w64.co, a model file without output-filter weights, as Model L's) is accepted
        next to the original filter build;
      • Model L is accepted without the fused pack12 decoder.
  • clean/tests/runtime_frame_trace.cpp: --backend=<n>; l_coef_pack12's arguments are decoded.
  • clean/l/runtime/tests/test_l_runtime_frame.py: class D3D12, Ports; check_frame / check_roles take
    l_post.
  • clean/l/runner/l_frame_check.py: --run --backend d3d12 | d3d12-stages and --compare-d3d12 (see "GPU
    record").

Refs #89

GPU record (native D3D12, clean/l/runner/l_frame_check.py, on 4ec8fab)

Build:

  • the D3D12 kernels from clean/dx12/build_dx12.py on this branch: 60 in the manifest, with the analytic
    w64/post_tf_f32_p12_diet_vsit / post_tf4_dl_f32_p12_diet_vsit and w64/post_filter_c1_s4 (post_w64.co);
  • the HIP code objects and runtime from build.py and --prepare.

Frames: #111's 11 per model (96 x 64, 80 x 48, 77 x 45; resets on frames 0, 2, 5, 8, 9; both parities), synthetic
models. Each run was its own locked GPU slot (gpu_slot.py --cap-s 170): HIP 2.0 s, D3D12 default 2.0 s, D3D12 with
the fusions off 3.0 s.

On D3D12, Model L ran lev/input_encoder, the linears, l_swin_block_c32_enc_nc, l_project_gather, Model M's
native stages, dec1's swin_block_c64_add_ex_nc, l_dec_project, l_swin_block_c32_dec_nc, l_coef_pack12 and
w64/post_tf_f32_p12_diet_vsit (post_pack p12, bottleneck bmegahg, d1d0_p12 0).

  • Model M (control), D3D12 against HIP: byte-identical on all 11 frames, across 20 stage outputs: encoder,
    every Swin stage written, dec0's coefficients, latent, history, reduced history, final output.
  • Model L: HIP reconstructs with l_post_recon (Model L frame on HIP: its own reconstruction l_post_recon in place of Model M's post #135) and D3D12 with Model M's fused pack12 post. Each frame's
    encoder reads the previous frame's reconstruction, so the two runs part after the first frame. Where their inputs
    agree (frames 0 and 9), the D3D12 frame is byte-identical to the HIP frame. The D3D12 frame is checked on its own:
    • Per stage against the CPU reference, on the run with the fusions off (--backend d3d12-stages): every stage
      passes on all 11 frames, under the same rules as Model L runtime frame on the HIP backend (confirmed FORMATS.md interface) #111's HIP check.

      stage values differing from the reference largest difference
      enc0 2126 / 1397154 18 FP8 steps
      enc1 73 / 1486848 24
      enc2 57 / 540672 13
      b0 ... b5 (one unit; the megakernel writes only b5) 299 / 135168 23
      dec2 71 / 405504 11
      dec1 16 / 1081344 3
      dec0 (A, B, latent codes, C) 13 / 684255 10 FP16 ulps
      post (history, reduced; Model M's post reference) 395 / 801900 13 FP16 ulps

      State (counter, parity, reset, offsets, latent / motion history / history hand-over) and exposure: 11 of 11.

    • Default kernels (the game's route) against that run: byte-identical on all 11 frames, across 22 outputs.
      enc1.merged is not written by the default kernels: the pm fusion keeps it on chip.

    • The default run's post against Model M's post reference: 11 of 11 frames pass; history 387 / 641520 differ,
      at most 13 FP16 ulps; reduced 8 / 160380.

  • The HIP frames pass the CPU reference for both models.
  • Not compared: b0 ... b4 (the bottleneck megakernels write only b5); the display image (the fused post writes none).
    The D3D12 fusions leave enc1's merged map and Model M's dec2 / dec1 outputs unwritten; these are reported apart, as
    all zero on D3D12.

Tested (CPU, the recording device)

  • clean/l/runtime/tests: 31 tests OK.
    • The D3D12 class's manifest is built from the repository's own @wg-kernel declarations.
    • With today's declarations every port Model L needs is present; each one left out alone is named alone.
    • Four to six frames on backend 3 pass Model L runtime frame on the HIP backend (confirmed FORMATS.md interface) #111's checks:
      • map chain, extents, window offsets, parameters;
      • every Model L argument against named buffers and blobs;
      • history; sizes 96 x 64, 80 x 48, 77 x 45; game reset and size changes; an injected l_coef_pack12 failure.
    • pack12 image extents; dec1 as its own block; Model M's pack12 post right after the store.
    • Model M on backend 3 traces the same with and without Model L in the build.
  • clean.tests.test_runtime_frame_trace, test_model_select, test_model_filter, test_model_pack_cpp: 31 OK
    (on 4ec8fab).
  • Model M unchanged on HIP: the 14-case frame trace set is identical to main's, in builds with and without
    WG_MODEL_L (before the rebase onto Model L frame on HIP: its own reconstruction l_post_recon in place of Model M's post #135; the runtime's HIP paths for Model M are untouched since).

Not tested

@phantoslayer21
phantoslayer21 force-pushed the model-l/frame-d3d12 branch 2 times, most recently from 6e55c45 to 4ec8fab Compare November 14, 2026 05:37
…encoder and decoder

Model L on backend 3 (native D3D12) runs Model M's native frame with Model L's
encoder (step 2) and decoder (step 4). Its coefficients go through the pack12 store
l_coef_pack12 (lossless, #131 / #134) into Model M's pack12 post path, the only post
path ported to D3D12. dec1 runs its own block (Model M fuses it into its pack12
decoder there; Model L's decoder reads dec1's map), so the xe / xo / xd fusions,
which need that fused decoder, are off for Model L; pm, mb and rv apply as for
Model M.

- clean/runtime/runtime.cpp:
  - Model L is accepted on backend 3 (builds with WG_MODEL_L);
  - at create, every D3D12 port Model L needs that <build>/dx12/manifest.json
    lacks is refused by name, "not yet ported to D3D12": its encoder (the _direct
    form on the direct-resource route), linears, clamp-free blocks, projections,
    l_coef_pack12, and dec1's own block swin_block_c64_add_ex_nc. Weights that need
    a clamped block are refused too (only the _nc forms are ported);
  - pack12 is Model L's default on backend 3 and required there; on HIP it stays
    refused (l_coef, base format);
  - the encoder launches lev/input_encoder_direct on the direct-resource route;
    the decoder launches l_coef_pack12 on pack12 frames;
  - the direct-resource checks accept Model L without the fused pack12 decoder.
- clean/tests/runtime_frame_trace.cpp: --backend=<n>; l_coef_pack12's arguments
  decoded.
- test_l_runtime_frame.py, class D3D12: the manifest is built from the
  repository's own @wg-kernel declarations. The missing ports are named, and each
  one alone is named; with every port present, the frame passes #111's checks on
  backend 3 (map chain, extents, offsets, parameters, every argument against
  named buffers and blobs, history, sizes, resets, a failed launch), with the
  pack12 images' extents, dec1's own block and Model M's pack12 post after the
  store. Model M on backend 3 traces the same with and without Model L in the
  build.

Refs #89

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
--run --backend d3d12 runs the frame sequence on native D3D12 (runtime backend 3,
default kernels: Model L's ports, the pack12 store l_coef_pack12, Model M's pack12
post path; Model M's native frame as the control) and keeps the raw pack12 images.
--compare-d3d12 compares every stage output both backends write with the HIP run's,
byte for byte, the pack12 images unpacked against the HIP run's A, B and C (the
layout of clean/FORMATS.md, dec0 "pack12"). Not compared: b0 ... b4 (the bottleneck
megakernels write only b5), the display image (the fused pack12 post writes none),
and on the first frame the previous frame's state.

Refs #89

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

The direct-resource route required the "original" output-filter build of the
wave64 fused post (post_w64__orig.co) with the model file's filter weights. With
the analytic-filter ports on main (#145, #146; keyed by name and code object, #143)
it also takes post_w64.co, the build a model file without those weights uses, as
Model L's: the check now refuses only quality5 / quality9, a post outside wave64,
or the original filter without weights.

test_l_runtime_frame.py: the D3D12 tests use the declared ports as they are (both
filter builds of Model M's fused post are declared now); a test that the analytic
build of the fused pack12 post is among them.

Refs #89

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

An output that is all zero on D3D12 and not on HIP is reported as not written
there, not as differing: the D3D12 fusions keep enc1's merged map (pm) and, for
Model M, dec2's and dec1's outputs (xe, the fused pack12 decoder) on chip, so those
debug buffers stay as allocated. The outputs compared are listed in the result.

Refs #89

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Since #135, the HIP Model L frame reconstructs with l_post_recon while the native
D3D12 frame runs Model M's fused pack12 post. Each frame's encoder reads the
previous frame's reconstruction, so the two runs part after the first frame, and a
byte comparison with HIP holds only where their inputs agree. For Model L,
--compare-d3d12 therefore checks the D3D12 frame on its own:
- --run --backend d3d12-stages: the frames with the D3D12 fusions off
  (WG_D3D12_FUSION=none, set before the runtime library loads: one configuration
  per process), so every stage output is written except b0 ... b4 (the bottleneck
  megakernel; the plain C = 128 block has no D3D12 port);
- every stage of that run against the reference on the run's own inputs, as
  --compare (compare_model: post_ref "M", the bottleneck as one unit chained from
  enc2.merged, A / B / C from the unpacked pack12 images, no display for the fused
  post);
- the default kernels (--backend d3d12) against that run, byte for byte;
- the default run's post against Model M's post reference.
Model M's D3D12 frame stays compared with its HIP frame, byte for byte.

test_l_runtime_frame.py: check_frame / check_roles take l_post (False for the
native D3D12 frame, which launches Model M's post, not l_post_recon).

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 05:48
@phantoslayer21
phantoslayer21 merged commit 9b339b9 into main Nov 14, 2026
9 checks passed
@phantoslayer21
phantoslayer21 deleted the model-l/frame-d3d12 branch November 14, 2026 05:49
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