RECORD_SCHEMA
PythonRECORD_SCHEMA = 'helia-edge/export-record@1'Export record (helia-edge/export-record@1): what export produced and how to produce it again.
One small JSON file per exported artifact, written next to it. With the weights it names by digest and the calibration it names by sha256, it is enough to rebuild the model, export it again and compare the bytes. It names files only by content hash and an optional URI, never by local path. Importable without Keras.
RECORD_SCHEMAconstantGOLDEN_SCHEMAconstantDIGESTconstantSourceclassA file named by content: its sha256 and, optionally, where to fetch it (never a local path).WeightImportclassWeights imported from another framework through mapping (a name in the family's MAPPINGS).WeightsRecordclassThe weights, by weightsdigest, and their import when they came from another framework.ExportOptionsclassFormat options of a LiteRT export.CalibrationRecordclassThe calibration array as stored (.npy), its length and, for a streaming model, the state resets.ExportSettingsclassHow the artifact was exported.FileRecordclassA file written next to the record, by name, sha256 and size.TensorEntryclassA model input or output; dynamic dimensions are -1.IORecordclassThe artifact's inputs and outputs in subgraph order, read back from the artifact.GoldenRecordclassA helia-model-zoo/golden@2 sequence: steps calls with the state carried and reset at resets, run with LiteRT's reference kernels from the signal named by input…HeliaEdgeRecordclassThe helia-edge that exported: its version, how the version identifies the code, and the commit for a VCS install.EnvironmentEntryclassVersions that can change exported bytes.ExportRecordclassOne exported artifact: the model, its weights, how it was exported, and the result.file_recordfunctionThe record of data written as name.weights_digestfunctionsha256: over the model's weights in model.weights order, independent of the file they came from.RECORD_SCHEMA = 'helia-edge/export-record@1'GOLDEN_SCHEMA = 'helia-model-zoo/golden@2'DIGEST = Annotated[str, Field(pattern='^sha256:[0-9a-f]{64}$')]A file named by content: its sha256 and, optionally, where to fetch it (never a local path).
Source()A file named by content: its sha256 and, optionally, where to fetch it (never a local path).
model_config = _CONFIGsha256: SHA256uri: str | None = NoneWeights imported from another framework through mapping (a name in the family's MAPPINGS).
WeightImport()Weights imported from another framework through mapping (a name in the family’s MAPPINGS).
model_config = _CONFIGmapping: strsource: SourceThe weights, by weightsdigest, and their import when they came from another framework.
WeightsRecord()The weights, by weights_digest, and their import when they came from another framework.
model_config = _CONFIGdigest: DIGESTimport_: WeightImport | None = Field(default=None, alias='import')Format options of a LiteRT export.
ExportOptions()Format options of a LiteRT export.
model_config = _CONFIGstrict: StrictBool = TrueFor calibrated precisions, refuse operators without an integer kernel.
state_tie_tolerance: StrictFloat = Field(default=0.01, ge=0.0, le=0.5)For calibrated precisions with integer I/O, the largest relative difference
between the scales of a state pair that export ties to one scale (see ExportSpec).
mode: Literal[ConversionMode.KERAS, ConversionMode.CONCRETE] = ConversionMode.KERASHow the model is traced: keras keeps the model’s batch; concrete traces batch 1, so it
exports batch_size 1 only.
The calibration array as stored (.npy), its length and, for a streaming model, the state resets.
CalibrationRecord()The calibration array as stored (.npy), its length and, for a streaming model, the state resets.
model_config = _CONFIGsha256: SHA256uri: str | None = Nonesamples: int = Field(gt=0)resets: tuple[int, ...] = ()How the artifact was exported.
ExportSettings()How the artifact was exported. batch_size is the batch of every model input.
model_config = _CONFIGformat: Literal['litert'] = 'litert'precision: Precisionio_dtype: IODTypebatch_size: StrictInt = Field(ge=1, le=2 ** 31 - 1)options: ExportOptions = ExportOptions()calibration: CalibrationRecord | None = NoneA file written next to the record, by name, sha256 and size.
FileRecord()A file written next to the record, by name, sha256 and size.
model_config = _CONFIGfile: strsha256: SHA256bytes: int = Field(ge=0)A model input or output; dynamic dimensions are -1.
TensorEntry()A model input or output; dynamic dimensions are -1. A state tensor has the index pair of its
state pair (state_in_k and state_out_k).
model_config = _CONFIGname: strrole: TensorRoleshape: tuple[int, ...]dtype: IODTypescale: float | Nonezero_point: int | Nonepair: int | None = Nonefrom_record(record: TensorRecord) -> TensorEntryclassmethod
The artifact's inputs and outputs in subgraph order, read back from the artifact.
IORecord()The artifact’s inputs and outputs in subgraph order, read back from the artifact.
state_scales_tied is True when every integer state pair has one scale and zero point, and None
without integer state pairs.
model_config = _CONFIGinputs: tuple[TensorEntry, ...]outputs: tuple[TensorEntry, ...]state_scales_tied: bool | None = NoneA helia-model-zoo/golden@2 sequence: steps calls with the state carried and reset at resets, run with LiteRT's reference kernels from the signal named by input…
GoldenRecord()A helia-model-zoo/golden@2 sequence: steps calls with the state carried and reset at
resets, run with LiteRT’s reference kernels from the signal named by inputs.
model_config = _CONFIGfile: FileRecordschema_: Literal['helia-model-zoo/golden@2'] = Field(default=GOLDEN_SCHEMA, alias='schema')kind: Literal['sequence'] = 'sequence'steps: int = Field(gt=0)resets: tuple[int, ...] = ()inputs: SourceThe helia-edge that exported: its version, how the version identifies the code, and the commit for a VCS install.
HeliaEdgeRecord()The helia-edge that exported: its version, how the version identifies the code, and the commit for a VCS install.
model_config = _CONFIGversion: strsource: HeliaEdgeSourcecommit: str | None = NoneVersions that can change exported bytes.
EnvironmentEntry()Versions that can change exported bytes.
model_config = _CONFIGhelia_edge: HeliaEdgeRecordpython: strplatform: strpackages: dict[str, str | None]from_record(record: EnvironmentRecord) -> EnvironmentEntryclassmethod
One exported artifact: the model, its weights, how it was exported, and the result.
ExportRecord()One exported artifact: the model, its weights, how it was exported, and the result.
model, weights and export together identify the export. model is None for a model
that no ModelSpec describes; such a record cannot be rebuilt.
model_config = _CONFIGschema_: Literal['helia-edge/export-record@1'] = Field(default=RECORD_SCHEMA, alias='schema')model: ModelSpec | Noneweights: WeightsRecordexport: ExportSettingsartifact: FileRecordio: IORecordgolden: GoldenRecord | None = Noneenvironment: EnvironmentEntryWrite the record as JSON.
write(path: Path | str) -> NoneWrite the record as JSON.
Read a record written by write.
read(path: Path | str) -> ExportRecordclassmethod
Read a record written by write.
The record of data written as name.
file_record(name: str, data: bytes) -> FileRecordThe record of data written as name.
sha256: over the model's weights in model.weights order, independent of the file they came from.
weights_digest(model) -> strsha256: over the model’s weights in model.weights order, independent of the file they came from.
For each weight it hashes the NumPy dtype name and the shape, each followed by a NUL byte, then the
C-order bytes of the value. Weight paths are not hashed: Keras numbers unnamed layers by how many it
has built in the process, so paths can differ between two builds of one spec. The record’s model
names the architecture.