Skip to content

Model L coefficient step: pack12 store form (l_coef_pack12), lossless against l_coef - #131

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

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

Conversation

@phantoslayer21

Copy link
Copy Markdown
Owner

Refs #89

l_coef_pack12 is the pack12 store form of Model L's coefficient step. It writes the same values as l_coef in
Model M's dec0 "pack12" layout (clean/kernels/decoder.hip WG_DEC_PACK12), which the output stage's _p12
kernels read:

  • image A, 8 bytes per pixel = A0 A1 A2 B0 | B1 B2 C2 (FP16);
  • image C, 4 bytes per pixel = C0 C1 (FP16);
  • the latent as l_coef.

Only the padding bytes of the base form are left out (A byte 3, B byte 3 and C's fourth FP16, all zero), so the
form is lossless. One template switch on l_coef's store gives both kernels from the same body, with the same
arguments (B unused, may be null). This gives native D3D12 a reader for Model L's coefficients through the existing
pack12 path. clean/l/FORMATS.md has the new row.

Tested

GPU record: RX 9070 XT, locked GPU slot, 2 seeds, synthetic data, head 1417f35.
clean/l/runner/l_ops_check.py, new case coef_pack12: 6 cases, 13,478 pixels, including odd render sizes inside
padded grids.

  • Both kernels run on the same FP16 map. Every output buffer is filled with a sentinel byte and followed by 64 bytes
    of sentinel slack.
  • The pack12 images, unpacked, equal l_coef's A, B and C words and latent bytes byte for byte, in every case.
  • No byte past any buffer was written. Every pixel inside R was written: the base form's padding bytes read 0, not
    the sentinel.
  • Negative control: a one-bit change in a pack12 C2 field is detected by the same comparison, in every case.
  • l_coef itself is unchanged in values: A, B and latent codes 0 differ from the oracle; 1 of 40,434 C values
    differs by 1 FP16 ulp, as before. The other kernels of the check also give their earlier results.

CPU: python -m unittest discover -s clean/l/tests -t . passes.

Not tested

  • The D3D12 port of l_coef_pack12 (next, kern2) and the frame that reads it (param's D3D12 frame).

…dec0 pack12 layout), proven lossless against l_coef on the GPU

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 02:49
Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>

# Conflicts:
#	clean/l/FORMATS.md
@phantoslayer21
phantoslayer21 merged commit 926859b into main Nov 14, 2026
9 checks passed
@phantoslayer21
phantoslayer21 deleted the model-l/coef-pack12 branch November 14, 2026 02:58
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