Skip to content

Model L: D3D12 port of the pack12 coefficient store (l_coef_pack12), byte for byte against its HIP kernel - #134

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

phantoslayer21 merged 2 commits into
mainfrom
model-l/l-coef-pack12-d3d12-pr

Conversation

@phantoslayer21

Copy link
Copy Markdown
Owner

Model L (#89): the D3D12 port of the pack12 coefficient store, l_coef_pack12 of l_ops.co
(clean/l/kernels/l_ops.hip, merged in #131), byte for byte against its HIP kernel. With it, the native D3D12 frame
can read Model L's coefficients through the existing pack12 read side (the _p12 post kernels).

Targets main. CI needs no GPU: nothing here runs without one.

  • clean/dx12/kernels/l_ops_coef.hlsl: the second kernel from the same source (COEF_PACK12, as HIP's
    l_coef_body<PACK12>). Every value is l_coef's; only the stores differ:
    • image A, 8 bytes per pixel: A | B << 24, then B >> 8 | C2 << 16;
    • image C, 4 bytes per pixel: C0 | C1 << 16;
    • the latent as l_coef; B is unused (null in the cases).
      The l_coef kernel keeps its exact text: its DXIL is identical to main's.
  • clean/l/runner/l_d3d12_ops_check.py: l_coef_pack12 cases. They are l_coef's six frames with the same
    random inputs (the same draws); only the output buffers follow the pack12 layout.

Refs #89

Tested

Local, Windows, Radeon RX 9000 series card, against l_ops.co built from #131 (main's l_ops.hip is #131's):

  • GPU (one GPU slot), l_d3d12_ops_check.py --run --seeds 6 --kernels l_coef_pack12,l_coef:
    • l_coef_pack12: 36 of 36 cases identical (6 seeds x 6 frames; 3 outputs per case, 928,320 output bytes);
    • l_coef (Model L: D3D12 port of the coefficient step (l_coef), byte for byte against its HIP kernel #126): still 36 of 36 identical (1,160,400 bytes);
    • 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: 21,299 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).
  • Cross-check on the same D3D12 run: in all 36 cases, the pack12 outputs are exactly l_coef's outputs repacked
    (A | B << 24, B >> 8 | C2 << 16, C0 | C1 << 16, latent equal). So the pack12 form loses nothing.
  • build_dx12.py --isa (RGA): l_coef_pack12 has 2 buffer_store_b64 + 4 buffer_store_b32 (A8, then C4 and the
    latent, per pixel x 2), as HIP's 2 global_store_b64 + 4 global_store_b32. l_coef's DXIL is byte-identical to
    main's (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 on D3D12 (waits for param's D3D12 frame).
  • NaN or infinite inputs (none in the synthetic data).

…byte for byte against its HIP kernel

Refs #89

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
@phantoslayer21
phantoslayer21 marked this pull request as ready for review November 14, 2026 03:13
@phantoslayer21
phantoslayer21 merged commit 26eb21e into main Nov 14, 2026
9 checks passed
@phantoslayer21
phantoslayer21 deleted the model-l/l-coef-pack12-d3d12-pr branch November 14, 2026 03:15
phantoslayer21 added a commit that referenced this pull request Nov 14, 2026
…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>
phantoslayer21 added a commit that referenced this pull request Nov 14, 2026
…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>
phantoslayer21 added a commit that referenced this pull request Nov 14, 2026
…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>
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