#!/usr/bin/env python3 # SPDX-License-Identifier: AGPL-3.0-or-later """Parametrized .rpi generator for controlled benchmarks. Usage: gen_param_model.py [perm_per_cell=2] Varies ONE structural axis at a time so the NEON-vs-scalar speedup can be attributed to working-set residency vs per-token vocab-scoring (Amdahl). Same structure/seed as gen_test_model.py; corrected embed offset (cell=36B). """ import struct, random, os, sys RPI_MAGIC = 0x21495052 RPI_VERSION = 1 RPI_LANES = 64 N_BANKS = 4 N_ROUTES_PER = 4 N_EMITS_PER = 4 CELL_SIZE = 36 # 8xu32 + 2xu16 (packed '<', no padding) PERM_SIZE = RPI_LANES + 8 def write_rpi(path, n_cells, vocab, perm_per_cell): n_perm = n_cells * perm_per_cell n_routes = n_cells * N_ROUTES_PER n_emits = n_cells * N_EMITS_PER cells_per_bank = max(1, n_cells // N_BANKS) with open(path, 'wb') as f: embed_offset = (128 + N_BANKS * 32 + n_cells * CELL_SIZE + n_perm * PERM_SIZE + n_routes * 8 + n_emits * 8) f.write(struct.pack(' 4 else 2 write_rpi(out, n_cells, vocab, ppc)