Skip to content

Model L: D3D12 port of the halo input encoder (lev/input_encoder), byte for byte against its HIP kernel - #127

Merged
phantoslayer21 merged 2 commits into
mainfrom
model-l/l-halo-enc-d3d12-pr
Nov 14, 2026
Merged

phantoslayer21 merged 2 commits into
mainfrom
model-l/l-halo-enc-d3d12-pr

Conversation

@phantoslayer21

Copy link
Copy Markdown
Owner

Model L (#89): the D3D12 port of Model L's halo input encoder, lev/input_encoder, byte for byte against its HIP
kernel: clean/kernels/encoder.hip built with WG_ENC_VALUES_OUT=1 as l_enc_values.co. The HIP kernel is merged in
#115 and includes the width-17 fix.

Targets main (it extends the ops harness of #122 / #123). CI needs no GPU: nothing here runs without one.

  • clean/dx12/kernels/encoder.hlsl: HIP's WG_ENC_VALUES_OUT switch, off by default, plus the kernel's
    @wg-kernel line (co=l_enc_values.co, tag lev). With the switch, as HIP:

    • the grid is the padded grid plus a 2-pixel halo per side, with X0 = 2 c - 2 and Y = 2 r + h - 2;
    • the dither is two byte loads at the unmirrored position (|Y| mod 16, |x| mod 16);
    • when both halo columns of a lane mirror onto one render column (x0 == x1, render width 17 padded to 32), slot 1
      takes slot 0's depth neighbourhood and centre motion and keeps its own dither;
    • motion surfaces are stored only for pixels inside R (0 <= Y < rh, X0 >= 0);
    • there is no projection: each pixel's 20 FP8 values and 12 zero bytes go to the halo map [fh + 4][fw + 4][32].

    Buffer form only: an #error stops a build with direct textures or output-resolution motion. Model M's encoder
    text is unchanged outside the switch.

  • clean/l/runner/l_d3d12_ops_check.py: the encoder's cases, built from Model L kernels: encoder and decoder blocks, input linears, projections, coefficient step (HIP) #115's l_enc_check.py frames:
    40 x 24, 37 x 19, 64 x 32 (reset), 90 x 50, 17 x 17 and 17 x 24 (reset).

    • Inputs from clean/reference/encoder.py random_inputs, the blob enc0.values, and WgEncParams by value.
    • All four outputs compared: the halo map and the three motion surfaces.
    • The engine gains two optional case keys: a module tag (module l_enc_values.co lev) and the HIP kernel name
      (input_encoder). The / of the launch name stays out of the case file names.

Refs #89

Tested

Local, Windows, Radeon RX 9000 series card, against main's l_enc_values.co:

  • GPU (one GPU slot), l_d3d12_ops_check.py --run --seeds 6 --kernels lev/input_encoder:
    • lev/input_encoder: 36 of 36 cases identical (6 seeds x 6 frames; 4 outputs per case, 3,854,688 output bytes),
      including the width-17 frames;
    • the Model M control swin_block_c96_nc: 36 of 36 identical (3,167,424 bytes);
    • 0 differing bytes in every output. The negative control (half grid) was caught: 50,495 bytes differed;
    • compared as raw downloaded bytes. Each output was first filled with its back end's own non-zero sentinel
      (HIP 0xA5, D3D12 0x5A).
  • build_dx12.py --isa (RGA): 4 buffer_store_b128 (the halo map, 2 per pixel) and the motion surfaces' 3
    buffer_store_b64 + 3 buffer_store_b32, as HIP's; no matrix instructions.
  • Model M's 4 encoder DXILs (input_encoder, input_encoder_direct, emo/input_encoder_mo,
    emo/input_encoder_mo_direct): 4 of 4 byte-identical, main against this
    branch (DXIL SHA-256).
  • python tools/ci/check_line_endings.py: 0 problems. Public gates (secrets, personal data, licence, chunks) pass.

Not tested

  • In a whole Model L frame (waits for the L runtime frame).
  • NaN or infinite inputs (none in the synthetic frames).

…te for byte against its HIP kernel

encoder.hlsl gets HIP's WG_ENC_VALUES_OUT switch (halo grid, unmirrored dither, x0 == x1 slot rule,
halo map store, no projection); off by default.

Refs #89

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

# Conflicts:
#	clean/l/runner/l_d3d12_ops_check.py
@phantoslayer21
phantoslayer21 marked this pull request as ready for review November 14, 2026 02:37
@phantoslayer21
phantoslayer21 merged commit 3fe45c1 into main Nov 14, 2026
9 checks passed
@phantoslayer21
phantoslayer21 deleted the model-l/l-halo-enc-d3d12-pr branch November 14, 2026 02:43
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