Add a GGUF architecture
Adding an architecture is one model file and one CPU test. The test compares mashbox’s logits with llama.cpp’s CPU logits on a small random GGUF file. It needs no chip and no secrets.
- Model file.
src/mashbox/gguf/archs/<arch>.py, named after the file’sgeneral.architecture. Follow llama.cpp’s graph (src/models/<arch>.cpp) and its converter (conversion/) for anything the converter changes on the way in (forqwen35: norms stored asw + 1exceptssm_norm,ssm_astored as-exp(A_log)). It providesConfig(file),load(file, config),tensor_roles(file, config),new_state(config, slots, ctx, extra_groups=0)andmake_forward(config), with the same contract asarchs/qwen35.py(archs/dense.pyis the shorter example: one module forllama,qwen2andqwen3): the forward takes the engine’skeep,verifyandhiddenarguments (seetests/cpu/test_gguf_engine_hooks.py). Weights go throughmashbox.ops(prepare,qmatmul,take_rows), never through your own dequantization, so every block type and every TPU kernel works without more code. - Register it in
src/mashbox/gguf/archs/__init__.py(ARCHS). - Fixture. Add a writer and an entry in
tools/gguf_fixtures/fixtures.py: small shapes, seeded random weights, every metadata key llama.cpp reads for the architecture, written withgguf’sGGUFWriter. - Reference logits and greedy ids. With a llama.cpp checkout at the commit in
fixtures.pyand a CPU build inbuild/:python tools/gguf_fixtures/fixtures.py make --llama-cpp ../llama.cpp --only <name>, thenpython tools/gguf_fixtures/greedy.py make --llama-cpp ../llama.cpp --only <name>. Commit the.json,.logits.f32,.greedy.jsonand.greedy.logits.f32files (a few KB). Filesggufcan write are rebuilt by the test from the seed and checked by sha256. - Contract case. Add the architecture to
CONTRACTSintests/contracts/test_arch.py: a float case at the architecture’s own eps, an eps-sensitive case, and a block case when a fixture is quantized, each naming the features its fixture carries.python3 -m pytest tests/contracts/test_arch.pycompares logits and greedy ids with llama.cpp’s for a prefill and for decode steps, and fails while an architecture inARCHShas no case or a fixture is in no contract. Atests/cpu/test_gguf_<arch>.pyis only for what the contract does not cover, and its docstring says what that is. - A real file, if you have one:
python tools/gguf_check.py FILE.gguf.
Open the pull request with the test output. Say in it which llama.cpp converter steps the file follows.