Skip to content

Model L: runtime weight packer (C++ port of l_pack.py, #109 layout) - #103

Merged
phantoslayer21 merged 2 commits into
mainfrom
model-l/l-pack-cpp
Nov 14, 2026
Merged

phantoslayer21 merged 2 commits into
mainfrom
model-l/l-pack-cpp

Conversation

@phantoslayer21

@phantoslayer21 phantoslayer21 commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

The runtime's weight packer for Model L's own launches: a C++ port of clean/l/runner/l_pack.py on the layout #109
settled, using the preset-L map's stage and tensor names. It packs byte-identical blobs for the default structure
table. It is not wired into the runtime library yet; that comes with the runtime frame for Model L (#111). Nothing
changes for Model M.

Rebased on main (#101, #109, #110 are in). The branch has two commits:

What is added (clean/l/runtime/, namespace wgrt::l)

  • encoder_launches() / decoder_launches(): mirrors of l_pack.encoder_launches() / decoder_launches() for the
    default table, with every field the Python lists carry:
    • encoder: values (pixel map of 32), the input linears Win1 (acc f16, ReLU then FP8) and Win2, enc0_block
      (offsets "first"), the projection of each token's 2 x 2 pixels (groups 4 x 32, clamp 6.28125);
    • decoder: dec0.project (with the depth-to-space), dec0_block (offsets "second"), coef (value positions from
      the table).
  • pack_linear, pack_project, pack_dec_project (rows R_E(32), K order in groups of 32), kord_groups32.
  • pack_model(params, drow, out, err), with params holding the map's stages enc0, enc0_block, dec0,
    dec0_block. It produces every blob of pack_model_l: enc0.values, enc0.Win1, enc0.Win2, enc0_block,
    enc0.project, dec0.project, dec0_block, dec0.coef. It refuses a missing stage, a missing tensor or a wrong
    number of values, naming the stage and tensor.
  • clean/runtime/model.h: pack_parts::rows_expand, a wrapper of the existing function (Model M's packers are not
    edited).
  • tests/l_pack_dump.cpp and tests/test_l_runtime_pack.py (CI runs them; host C++ compiler or MSVC).

Refs #89

Tested (against the current Python packers on main, i.e. after #109)

  • test_l_runtime_pack.py: 3 tests, OK (clang++ and MSVC):
    • all 8 blobs of l_pack.pack_model_l against wgrt::l::pack_model, byte for byte, for oracle.random_params
      with three seeds;
    • both launch lists field by field against l_pack.encoder_launches() / decoder_launches(), and the coef value
      positions against table.DEC0_VALUES;
    • refusals: missing stage, missing tensor, wrong size in a block, the projection and dec0.project.
  • clean/l/runtime/tests/test_l_runtime_*.py: 8 tests, OK.
  • With clang++: clean.tests.test_model_pack_cpp, test_model_filter, clean.k.tests.test_k_runtime_pack,
    test_k_runtime_tables, clean.l.tests.test_l_pack, test_l_reference: 72 tests, OK.

Not tested

…e_load on main

#110 merged after #109 changed the structure table: the runtime's Model L tensor list still had the earlier layout and its test called table.encoder_shapes, which #109 removed. Now the map's stages (enc0, enc0_block, the ten shared stages, dec0_block, dec0, post), names and shapes; the test checks them against data/preset-L.v1.map.json and table.param_shapes.

Refs #89

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
wgrt::l::encoder_launches / decoder_launches mirror l_pack's launch lists for the default table (#109's layout, the map's stage and tensor names); pack_model packs every blob of pack_model_l: enc0.values, enc0.Win1, enc0.Win2, enc0_block, enc0.project, dec0.project, dec0_block, dec0.coef. model.h pack_parts gains rows_expand (the expand rows of dec0.project). Byte-identical to the Python packer (test_l_runtime_pack.py).

Refs #89

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
@phantoslayer21 phantoslayer21 changed the title Model L: runtime weight packer (C++ port of l_pack.py) Model L: runtime weight packer (C++ port of l_pack.py, #109 layout) Nov 13, 2026
@phantoslayer21
phantoslayer21 marked this pull request as ready for review November 14, 2026 00:16
@phantoslayer21
phantoslayer21 merged commit 72c32fc into main Nov 14, 2026
2 checks passed
@phantoslayer21
phantoslayer21 deleted the model-l/l-pack-cpp branch November 14, 2026 00:24
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