Skip to content

Model L: weight packing of Model L's own launches (Python) - #99

Merged
phantoslayer21 merged 1 commit into
mainfrom
model-l/packers
Nov 13, 2026
Merged

phantoslayer21 merged 1 commit into
mainfrom
model-l/packers

Conversation

@phantoslayer21

Copy link
Copy Markdown
Owner

Python weight packing for Model L's own launches (step P7, Python part). Refs #89

clean/l/runner/l_pack.py derives the encoder's launch list from the structure table (clean/l/reference/table.py) and packs one blob per launch. Each blob uses a format Model M already has (clean/FORMATS.md), so the kernels can be built from Model M's building blocks:

Blob Format
enc0.values Model M's enc0 blob with a zero projection (dither table and the two scalars only)
enc0.<w> per linear merge / expand section format: bias tile vector, fragments with rows R_L(C_out), K order K_L(C_in); a select feeding the linear is folded in as zero weights
enc0.<block>, dec0.<block> packing.pack_block at the block's width, padded to 256
enc0.project bias tile vector, fragments in groups of 32 input channels (dec0's K order over every group)
dec0 Model M's dec0 blob

The ten shared Swin stages keep packing.pack_stage. No existing file changes except clean/l/README.md.

The C++ port for the runtime follows in its own PR, once clean/runtime/model.cpp's block packer and fragment helpers are exposed (requested from the runtime tables PR series).

Tested

  • python -m unittest discover -s clean/l/tests -t . -p "test_l_[pr]*.py": all pass (10 new tests, plus the existing reference tests). Covered:
    • round trips of every format;
    • the block packer gives Model M's stage blobs byte for byte (b0, dec1), and C = 32 gets the layout's size (one MLP unit of 8 KB);
    • the weights decoded from the blobs, applied the way the kernels apply them (whole input maps, zero weights outside a select), give the oracle's maps byte for byte (both linears, the block input, the features).
  • python -m unittest discover -s clean/tests -t . -p test_model_tables.py: passes.
  • python tools/ci/check_line_endings.py: 0 problems.

Not tested

  • No kernels yet: the blobs are checked through the decoders and the oracle only.

clean/l/runner/l_pack.py derives the encoder's launch list from the structure
table (a select is folded into the linear it feeds as zero weights) and packs
one blob per launch, each in a format Model M already uses:

- enc0.values: Model M's enc0 blob with a zero projection (dither table and
  the two scalars only);
- enc0.<w> per linear: the merge / expand section format (bias tile vector,
  fragments with rows R_L(C_out) and K order K_L(C_in));
- enc0.<block>, dec0.<block>: packing.pack_block at the block's width;
- enc0.project: bias, then fragments in groups of 32 input channels (dec0's
  K order over every group);
- dec0: Model M's dec0 blob.

The ten shared Swin stages keep packing.pack_stage. Decoders for the blobs are
included for the tests.

Tests (synthetic): round trips of every format, the block packer against Model
M's stage blobs byte for byte, and the weights decoded from the blobs applied
the kernels' way (whole input maps, zero weights outside a select) against the
oracle's maps, byte for byte.

Refs #89

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
@phantoslayer21
phantoslayer21 marked this pull request as ready for review November 13, 2026 22:37
@phantoslayer21
phantoslayer21 merged commit e6500a8 into main Nov 13, 2026
2 checks passed
@phantoslayer21
phantoslayer21 deleted the model-l/packers branch November 13, 2026 22:37
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