DocumentationArchitecture

LoadWeights

A zoomed-in view of one operation in Piro’s stateful inference loop.

Architecture detail

LoadWeights

Reads the durable model revision and prepares runtime weights for inference; external fast-state loading belongs to the caller.

← Full model
manifest = R2Get("models/{modelId}/weights/current/manifest.json")
for each component in manifest.components:
bytes = R2Get(component.key, component.byteRange)
if Hash(bytes) != component.checksum:
return Error("weight object checksum mismatch")
tensor = Decode(bytes, component.format, component.shape, component.scales)
if tensor is missing or shape is incompatible:
return Error("weight object cannot reconstruct declared tensor")
runtime[component.owner][component.name] = ToBF16ComputeTensor(tensor)
return AttachFastOverlay(runtime)

What it does

Reads models/{modelId}/weights/current/manifest.json from the piro-kb R2 bucket, follows its logical base, overlay, and state objects, checks checksums and shapes, dequantizes base tensors for BF16 compute, and attaches fast overlays.

Why it exists

A 256M mixed-precision model fits comfortably below R2's single-upload and per-object limits; the manifest still gives us revision and ownership semantics without forcing physical sharding.

← Back to architecture