Skip to content

.smoe Binary Format ​

The .smoe file is our sovereign artifact—a self-describing, rigorously page-aligned binary vault. It is the sole output of the Sculptor (shatter_moe.py) and the sole input of the Streamer (streamer.cpp). This document is its uncompromising blueprint.

Immutable Encoding

All integer fields are little-endian. All byte offsets are measured from the start of the file. All expert blobs are perfectly aligned to the Apple Silicon 16 KB hardware page boundary (16,384 bytes).


File Architecture ​

Offset 0x0000
┌──────────────────────────────────────────────────┐
│  FILE HEADER                    (64 bytes)        │
├──────────────────────────────────────────────────┤
│  EXPERT TABLE                   (N × 48 bytes)    │  ← immediately after header
├──────────────────────────────────────────────────┤
│  TENSOR DESCRIPTORS             (N × 3 × 44 bytes)│  ← immediately after table
├──────────────────────────────────────────────────┤
│  ARCH BLOCK "SARC"              (128 bytes)       │  ← reserved_ext (64 B-aligned)
├──────────────────────────────────────────────────┤
│  [zero padding to 16 KB boundary]                 │
├──────────────────────────────────────────────────┤
│  EXPERT BLOB 0                  (padded to 16 KB) │  ← data_offset (16 KB-aligned)
├──────────────────────────────────────────────────┤
│  EXPERT BLOB 1                  (padded to 16 KB) │
├──────────────────────────────────────────────────┤
│  ...                                              │
└──────────────────────────────────────────────────┘

File Header — 64 bytes ​

Anchored at absolute offset 0x0000.

OffsetSizeTypeNameDescription
08uint8[8]magic53 4D 4F 45 DE EA 00 01 — "SMOE" + model marker
84uint32versionFormat version — currently 2; readers accept 1–2
124uint32num_moe_layersNumber of transformer layers harboring MoE experts
164uint32max_experts_per_layerMaximum expert count across all MoE layers
204uint32total_expertsTotal entries in the expert table
248uint64table_offsetByte offset of the first ExpertEntry (always 64)
328uint64data_offsetByte offset of the first expert blob (16 KB-aligned)
404uint32group_sizeSMOE quantisation group size (always 64)
444uint32bitsQuantisation bit depth (2 for SMOE-Q2, 4 for SMOE-Q4)
484uint32d_modelHidden dimension (dynamic, written by Sculptor)
524uint32vocab_sizeVocabulary size (dynamic)
564uint32ffn_dimDense/shared FFN intermediate dimension (dynamic)
604uint32reserved_extv2: byte offset of the arch block. v1: zero

The d_model, vocab_size, and ffn_dim empower the C++ runtime to dynamically construct itself from the vault header, fully independent of the Scout .safetensors file.

Version acceptance

Readers accept versions 1 through 2. A v1 vault has no arch block — the engine falls back to a legacy inference path with Qwen3-family defaults. A v2 vault must carry a valid arch block at reserved_ext; the engine validates it at load (magic, size, SiLU activation, moe_top_k ≤ 16, head_dim ≤ 256, head divisibility) and refuses to start on failure. Pre-v2 vaults upgrade in place with scripts/upgrade_vault_v2.py — the block is written into the existing padding gap, so no expert blob moves.


Arch Block "SARC" — 128 bytes ​

The vault's birth certificate: every model-specific mathematical constant the engine needs, serialised from the checkpoint's HF config.json at shatter time. Located via header.reserved_ext, 64-byte aligned, inside the padding gap before data_offset. Mirrored as SmoeArchBlock in src/common.hpp and ARCH_FMT in shatter_moe.py.

OffsetSizeTypeNameDescription
04uint8[4]magic53 41 52 43 — "SARC"
44uint32block_versionCurrently 1
84uint32block_sizeAlways 128
124uint32flagsbit 0 norm_topk_prob · bit 1 has_qk_norm · bit 2 has_dense_layer_0
164float32rope_thetaRoPE base frequency
204uint32num_headsAttention query heads
244uint32num_kv_headsGQA key/value heads
284uint32head_dimAttention head dimension
324uint32moe_top_kRouted experts per token
364uint32moe_ffn_dimExpert intermediate dimension
404uint32dense_ffn_dimDense-layer intermediate dimension
444uint32shared_expert_ffn_dim0 = no shared expert
484uint32activation0 = SiLU/SwiGLU (the only value the kernels implement)
524uint32num_hidden_layersTotal transformer layers
564float32rms_norm_epsRMS-norm epsilon (kernels compile 1e-6; a differing value warns)
6024char[24]model_typeHF model_type, NUL-padded (e.g. qwen3_moe)
8444uint8[44]reservedMust be zero

The engine trusts the block for math constants (rope_theta, moe_top_k, head geometry, renormalisation) but keeps the Scout's tensor shapes as the authority for structural facts — has_qk_norm, has_dense_layer_0, and the shared-expert dimension are cross-checked against the tensors actually present, with a warning on any disagreement. Shapes don't lie.


Expert Table Entry — 48 bytes each ​

N entries flow immediately after the file header, where N = total_experts.

OffsetSizeTypeNameDescription
04uint32layer_idTransformer layer index
44uint32expert_idExpert index within the layer
88uint64byte_offsetAbsolute file offset of this expert's blob
168uint64raw_sizeActual data bytes before padding
248uint64padded_sizeData bytes rounded perfectly to 16 KB
324uint32group_sizeGroup size used (= header.group_size)
368uint64num_groupsTotal quantisation groups across all three sub-tensors
444uint8[4]reservedMust be zero

Flash Lookup

To pinpoint an expert by (layer_id, expert_id) at runtime, we iterate the expert table once at startup to forge a map<(layer, expert), byte_offset>. The table is sorted by layer ascending, expert ascending.


Tensor Descriptor — 44 bytes each ​

Three descriptors follow each expert entry in table order (gate → up → down). Total: N × 3 descriptors packed contiguously after the expert table.

OffsetSizeTypeNameDescription
01uint8tensor_type0=gate_proj, 1=up_proj, 2=down_proj
11uint8ndimNumber of dimensions (always 2)
22uint8[2]reserved_0Must be zero
44uint32rowsWeight matrix rows (original shape[0])
84uint32colsWeight matrix cols (original shape[1])
128uint64packed_offsetByte offset of packed weights within the expert blob
208uint64packed_sizeByte size of packed weights
288uint64scales_offsetByte offset of float16 scale array within the expert blob
368uint64scales_sizeByte size of float16 scale array

Expert Blob Architecture ​

Each expert blob is an opaque, densely packed byte buffer starting at ExpertEntry.byte_offset. Three sub-tensors are woven together continuously:

[gate_proj packed bytes ] ← ceil(rows×cols × bits / 8) bytes
[gate_proj scale bytes  ] ← float16, ceil(rows×cols / group_size) × 2 bytes
[up_proj   packed bytes ]
[up_proj   scale bytes  ]
[down_proj packed bytes ]
[down_proj scale bytes  ]
[zero padding           ] ← pad to padded_size (16 KB boundary)

We always use TensorDescriptor.packed_offset and scales_offset—never assuming a fixed stride.


C++ Struct Mirror ​

Every struct above is rigidly defined in src/common.hpp and protected by static_assert:

cpp
static_assert(sizeof(SmoeHeader) == 64);
static_assert(sizeof(ExpertEntry) == 48);
static_assert(sizeof(SmoeArchBlock) == 128);

The C++ struct and this specification are the undeniable ground truth. If they diverge, the struct wins.

MIT License.