Skip to content

Reference and packers: model-keyed stage tables (Model M unchanged) - #92

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

phantoslayer21 merged 1 commit into
mainfrom
model-l/reference-tables

Conversation

@phantoslayer21

Copy link
Copy Markdown
Owner

The CPU reference's Swin stage table and the packers' stage lists are now keyed by model, with Model M as the default
everywhere. A second model of the same family can add its rows next to Model M's without editing any M code path.
Nothing changes for Model M: same tables, same packed bytes, same reference outputs, same error texts.

What is model-keyed now

  • clean/reference/swin.py: MODEL_STAGES ("M" is the existing STAGES object), WINDOW_OFFSETS (Model M's
    window-offset rule as data), and the accessors stage_table(model) and window_offset(stage, parity, model).
    run_stage, random_params and random_inputs take model="M".
  • clean/runner/packing.py: MODEL_BNECK_STAGES, MODEL_MID_STAGES, bneck_stages(model) and mid_stages(model).
    stage_sections, check_tensors, pack_stage, stage_blob_size, pack_bneck, split_bneck, pack_mid and
    split_mid take model="M". The error texts are built from the model's lists, which gives exactly the old wording
    for Model M.
  • clean/runner/pipeline.py: MODEL_SWIN_ORDER and swin_order(model) ("M" is the existing SWIN_ORDER).
  • clean/runner/stage_runner.py: MODELS comes from the models with a reference stage table, plus K (still
    ("M", "K")). The Runner passes its model to the table lookups and packers of the non-K path.
  • An unknown model is refused by name ("no reference stage table for model 'X'; known: M").

The Model M kernel-specific paths (the bneck megakernel and swin_mid launch setup in the stage runner) are left as
they are: they drive Model M's kernels.

Refs #89

Tested

  • Bit-identity for Model M: a fingerprint script computed 69 SHA-256 hashes from one clone with fixed seeds, on main
    (d9c697e) and on this branch. The two outputs are byte for byte identical. They cover the stage table, the window
    offsets of every stage and parity, the bneck / mid stage lists, every stage's section offsets and blob size, the
    Swin order, the synthetic parameters, pack_stage for every stage in both D-row layouts (gfx12, gfx11), the bneck
    and mid blobs and the mid split, the synthetic inputs, and run_stage outputs for every stage at both parities.
  • New clean/tests/test_model_tables.py (6 tests, CI runs it):
    • Model M's rows equal the literals of the previous code: the table and its order, the offset rule, the stage lists,
      the Swin order, MODELS;
    • the M error texts are unchanged;
    • an unknown model is refused;
    • a synthetic second model built from Model M's own stages under new names packs to the same bytes and computes the
      same reference outputs as Model M's stages, and leaves Model M's offsets untouched.
  • python tools/ci/run_python_tests.py --jobs 2 (the CI Python test set): 642 tests ran, 105 skipped (the modules state their reasons: emulator needs Linux, GPU opt-ins), 0 modules failed.

Not tested

  • No GPU run. No GPU path changes: kernels, the runtime library and the C++ tables are not touched.

The CPU reference's Swin stage table and window offsets, the packers' bneck and mid stage lists and the
pipeline's Swin order are now tables keyed by model, Model M the default everywhere (the existing
objects are Model M's rows). The functions that use them take model="M"; an unknown model is refused by
name. Model M's tables, packed bytes, reference outputs and error texts are unchanged.

test_model_tables.py checks Model M's rows against the previous literals and plugs in a synthetic second
model built from Model M's own stages.

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:08
@phantoslayer21
phantoslayer21 merged commit eb66c98 into main Nov 13, 2026
2 checks passed
@phantoslayer21
phantoslayer21 deleted the model-l/reference-tables branch November 13, 2026 22:08
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