Expand description
Minimal P64-style learned-head weight blob format + bounded parser (AU-LEARNED).
This is the on-disk container every learned audio head loads from. It is deliberately tiny
and self-describing: a magic tag, a format version, a small dims shape vector, and a flat
f32 payload. Real weights are gated on the principal (HA1 corpus / HA6 model); the format
here lets us (a) round-trip a synthetic/test blob and (b) fail closed when a blob is absent
or malformed. Parsing is cold (a Vec is allowed); inference over the parsed blob is the
hot, caller-buffered path and lives in the head modules.
Wire layout (all little-endian):
magic : u32 = "QP64"
version : u32
ndims : u32 (<= MAX_DIMS)
dims : [u32; ndims]
ndata : u32 (<= MAX_DATA)
data : [f32; ndata]The parser requires the byte slice to end exactly after data — trailing bytes are rejected,
so a truncated or padded blob cannot be silently accepted.
Structs§
- Weight
Blob - A parsed learned-head weight blob. Cold-path owned (
Vec); heads borrow it during inference.
Constants§
- MAX_
DATA - Upper bound on
datalength inf32elements (~4M floats = 16 MiB; bounds parsing). - MAX_
DIMS - Upper bound on
dimslength (bounds parsing; a shape vector is always tiny). - WEIGHT_
MAGIC - Blob magic:
QP64little-endian. - WEIGHT_
VERSION - Current blob format version.
Functions§
- make_
blob - Convenience: build a well-formed blob with the current magic/version.
- parse_
weight_ blob - Parse a weight blob from bytes. Bounded and strict: unknown magic →
BackendUnavailable(treated as “no usable weights” so the head fails closed); any structural problem (short read, oversized counts, trailing bytes) →MalformedAudio. Never partially accepts. - write_
weight_ blob - Serialize a weight blob (cold path — tests and fixture generation). Inverse of
parse_weight_blob.