# helia_edge.export.record

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.

## helia_edge.export.record.RECORD_SCHEMA

`constant` · `python`

```python
RECORD_SCHEMA = 'helia-edge/export-record@1'
```

Source: `helia_edge/export/record.py:20`

## helia_edge.export.record.GOLDEN_SCHEMA

`constant` · `python`

```python
GOLDEN_SCHEMA = 'helia-model-zoo/golden@2'
```

Source: `helia_edge/export/record.py:21`

## helia_edge.export.record.DIGEST

`constant` · `python`

```python
DIGEST = Annotated[str, Field(pattern='^sha256:[0-9a-f]{64}$')]
```

Source: `helia_edge/export/record.py:22`

## helia_edge.export.record.Source

`class` · `python`

```python
Source()
```

A file named by content: its sha256 and, optionally, where to fetch it (never a local path).

Source: `helia_edge/export/record.py:28`

### helia_edge.export.record.Source.model_config

`attribute` · `python`

```python
model_config = _CONFIG
```

Source: `helia_edge/export/record.py:31`

### helia_edge.export.record.Source.sha256

`attribute` · `python`

```python
sha256: SHA256
```

Source: `helia_edge/export/record.py:33`

### helia_edge.export.record.Source.uri

`attribute` · `python`

```python
uri: str | None = None
```

Source: `helia_edge/export/record.py:34`

## helia_edge.export.record.WeightImport

`class` · `python`

```python
WeightImport()
```

Weights imported from another framework through ``mapping`` (a name in the family's ``MAPPINGS``).

Source: `helia_edge/export/record.py:37`

### helia_edge.export.record.WeightImport.model_config

`attribute` · `python`

```python
model_config = _CONFIG
```

Source: `helia_edge/export/record.py:40`

### helia_edge.export.record.WeightImport.mapping

`attribute` · `python`

```python
mapping: str
```

Source: `helia_edge/export/record.py:42`

### helia_edge.export.record.WeightImport.source

`attribute` · `python`

```python
source: Source
```

Source: `helia_edge/export/record.py:43`

## helia_edge.export.record.WeightsRecord

`class` · `python`

```python
WeightsRecord()
```

The weights, by ``weights_digest``, and their import when they came from another framework.

Source: `helia_edge/export/record.py:46`

### helia_edge.export.record.WeightsRecord.model_config

`attribute` · `python`

```python
model_config = _CONFIG
```

Source: `helia_edge/export/record.py:49`

### helia_edge.export.record.WeightsRecord.digest

`attribute` · `python`

```python
digest: DIGEST
```

Source: `helia_edge/export/record.py:51`

### helia_edge.export.record.WeightsRecord.import_

`attribute` · `python`

```python
import_: WeightImport | None = Field(default=None, alias='import')
```

Source: `helia_edge/export/record.py:52`

## helia_edge.export.record.ExportOptions

`class` · `python`

```python
ExportOptions()
```

Format options of a LiteRT export.

Source: `helia_edge/export/record.py:55`

### helia_edge.export.record.ExportOptions.model_config

`attribute` · `python`

```python
model_config = _CONFIG
```

Source: `helia_edge/export/record.py:66`

### helia_edge.export.record.ExportOptions.strict

`attribute` · `python`

```python
strict: StrictBool = True
```

For calibrated precisions, refuse operators without an integer kernel.

Source: `helia_edge/export/record.py:68`

### helia_edge.export.record.ExportOptions.state_tie_tolerance

`attribute` · `python`

```python
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``).

Source: `helia_edge/export/record.py:69`

### helia_edge.export.record.ExportOptions.mode

`attribute` · `python`

```python
mode: Literal[ConversionMode.KERAS, ConversionMode.CONCRETE] = ConversionMode.KERAS
```

How the model is traced: ``keras`` keeps the model's batch; ``concrete`` traces batch 1, so it
exports ``batch_size`` 1 only.

Source: `helia_edge/export/record.py:70`

## helia_edge.export.record.CalibrationRecord

`class` · `python`

```python
CalibrationRecord()
```

The calibration array as stored (``.npy``), its length and, for a streaming model, the state resets.

Source: `helia_edge/export/record.py:73`

### helia_edge.export.record.CalibrationRecord.model_config

`attribute` · `python`

```python
model_config = _CONFIG
```

Source: `helia_edge/export/record.py:76`

### helia_edge.export.record.CalibrationRecord.sha256

`attribute` · `python`

```python
sha256: SHA256
```

Source: `helia_edge/export/record.py:78`

### helia_edge.export.record.CalibrationRecord.uri

`attribute` · `python`

```python
uri: str | None = None
```

Source: `helia_edge/export/record.py:79`

### helia_edge.export.record.CalibrationRecord.samples

`attribute` · `python`

```python
samples: int = Field(gt=0)
```

Source: `helia_edge/export/record.py:80`

### helia_edge.export.record.CalibrationRecord.resets

`attribute` · `python`

```python
resets: tuple[int, ...] = ()
```

Source: `helia_edge/export/record.py:81`

## helia_edge.export.record.ExportSettings

`class` · `python`

```python
ExportSettings()
```

How the artifact was exported. ``batch_size`` is the batch of every model input.

Source: `helia_edge/export/record.py:84`

### helia_edge.export.record.ExportSettings.model_config

`attribute` · `python`

```python
model_config = _CONFIG
```

Source: `helia_edge/export/record.py:87`

### helia_edge.export.record.ExportSettings.format

`attribute` · `python`

```python
format: Literal['litert'] = 'litert'
```

Source: `helia_edge/export/record.py:89`

### helia_edge.export.record.ExportSettings.precision

`attribute` · `python`

```python
precision: Precision
```

Source: `helia_edge/export/record.py:90`

### helia_edge.export.record.ExportSettings.io_dtype

`attribute` · `python`

```python
io_dtype: IODType
```

Source: `helia_edge/export/record.py:91`

### helia_edge.export.record.ExportSettings.batch_size

`attribute` · `python`

```python
batch_size: StrictInt = Field(ge=1, le=2 ** 31 - 1)
```

Source: `helia_edge/export/record.py:92`

### helia_edge.export.record.ExportSettings.options

`attribute` · `python`

```python
options: ExportOptions = ExportOptions()
```

Source: `helia_edge/export/record.py:93`

### helia_edge.export.record.ExportSettings.calibration

`attribute` · `python`

```python
calibration: CalibrationRecord | None = None
```

Source: `helia_edge/export/record.py:94`

## helia_edge.export.record.FileRecord

`class` · `python`

```python
FileRecord()
```

A file written next to the record, by name, sha256 and size.

Source: `helia_edge/export/record.py:114`

### helia_edge.export.record.FileRecord.model_config

`attribute` · `python`

```python
model_config = _CONFIG
```

Source: `helia_edge/export/record.py:117`

### helia_edge.export.record.FileRecord.file

`attribute` · `python`

```python
file: str
```

Source: `helia_edge/export/record.py:119`

### helia_edge.export.record.FileRecord.sha256

`attribute` · `python`

```python
sha256: SHA256
```

Source: `helia_edge/export/record.py:120`

### helia_edge.export.record.FileRecord.bytes

`attribute` · `python`

```python
bytes: int = Field(ge=0)
```

Source: `helia_edge/export/record.py:121`

## helia_edge.export.record.TensorEntry

`class` · `python`

```python
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``).

Source: `helia_edge/export/record.py:124`

### helia_edge.export.record.TensorEntry.model_config

`attribute` · `python`

```python
model_config = _CONFIG
```

Source: `helia_edge/export/record.py:128`

### helia_edge.export.record.TensorEntry.name

`attribute` · `python`

```python
name: str
```

Source: `helia_edge/export/record.py:130`

### helia_edge.export.record.TensorEntry.role

`attribute` · `python`

```python
role: TensorRole
```

Source: `helia_edge/export/record.py:131`

### helia_edge.export.record.TensorEntry.shape

`attribute` · `python`

```python
shape: tuple[int, ...]
```

Source: `helia_edge/export/record.py:132`

### helia_edge.export.record.TensorEntry.dtype

`attribute` · `python`

```python
dtype: IODType
```

Source: `helia_edge/export/record.py:133`

### helia_edge.export.record.TensorEntry.scale

`attribute` · `python`

```python
scale: float | None
```

Source: `helia_edge/export/record.py:134`

### helia_edge.export.record.TensorEntry.zero_point

`attribute` · `python`

```python
zero_point: int | None
```

Source: `helia_edge/export/record.py:135`

### helia_edge.export.record.TensorEntry.pair

`attribute` · `python`

```python
pair: int | None = None
```

Source: `helia_edge/export/record.py:136`

### helia_edge.export.record.TensorEntry.from_record

`method` · `python`

```python
from_record(record: TensorRecord) -> TensorEntry
```

`classmethod`

Source: `helia_edge/export/record.py:138`

## helia_edge.export.record.IORecord

`class` · `python`

```python
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.

Source: `helia_edge/export/record.py:143`

### helia_edge.export.record.IORecord.model_config

`attribute` · `python`

```python
model_config = _CONFIG
```

Source: `helia_edge/export/record.py:150`

### helia_edge.export.record.IORecord.inputs

`attribute` · `python`

```python
inputs: tuple[TensorEntry, ...]
```

Source: `helia_edge/export/record.py:152`

### helia_edge.export.record.IORecord.outputs

`attribute` · `python`

```python
outputs: tuple[TensorEntry, ...]
```

Source: `helia_edge/export/record.py:153`

### helia_edge.export.record.IORecord.state_scales_tied

`attribute` · `python`

```python
state_scales_tied: bool | None = None
```

Source: `helia_edge/export/record.py:154`

## helia_edge.export.record.GoldenRecord

`class` · `python`

```python
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``.

Source: `helia_edge/export/record.py:157`

### helia_edge.export.record.GoldenRecord.model_config

`attribute` · `python`

```python
model_config = _CONFIG
```

Source: `helia_edge/export/record.py:161`

### helia_edge.export.record.GoldenRecord.file

`attribute` · `python`

```python
file: FileRecord
```

Source: `helia_edge/export/record.py:163`

### helia_edge.export.record.GoldenRecord.schema_

`attribute` · `python`

```python
schema_: Literal['helia-model-zoo/golden@2'] = Field(default=GOLDEN_SCHEMA, alias='schema')
```

Source: `helia_edge/export/record.py:164`

### helia_edge.export.record.GoldenRecord.kind

`attribute` · `python`

```python
kind: Literal['sequence'] = 'sequence'
```

Source: `helia_edge/export/record.py:165`

### helia_edge.export.record.GoldenRecord.steps

`attribute` · `python`

```python
steps: int = Field(gt=0)
```

Source: `helia_edge/export/record.py:166`

### helia_edge.export.record.GoldenRecord.resets

`attribute` · `python`

```python
resets: tuple[int, ...] = ()
```

Source: `helia_edge/export/record.py:167`

### helia_edge.export.record.GoldenRecord.inputs

`attribute` · `python`

```python
inputs: Source
```

Source: `helia_edge/export/record.py:168`

## helia_edge.export.record.HeliaEdgeRecord

`class` · `python`

```python
HeliaEdgeRecord()
```

The helia-edge that exported: its version, how the version identifies the code, and the commit
for a VCS install.

Source: `helia_edge/export/record.py:176`

### helia_edge.export.record.HeliaEdgeRecord.model_config

`attribute` · `python`

```python
model_config = _CONFIG
```

Source: `helia_edge/export/record.py:180`

### helia_edge.export.record.HeliaEdgeRecord.version

`attribute` · `python`

```python
version: str
```

Source: `helia_edge/export/record.py:182`

### helia_edge.export.record.HeliaEdgeRecord.source

`attribute` · `python`

```python
source: HeliaEdgeSource
```

Source: `helia_edge/export/record.py:183`

### helia_edge.export.record.HeliaEdgeRecord.commit

`attribute` · `python`

```python
commit: str | None = None
```

Source: `helia_edge/export/record.py:184`

## helia_edge.export.record.EnvironmentEntry

`class` · `python`

```python
EnvironmentEntry()
```

Versions that can change exported bytes.

Source: `helia_edge/export/record.py:187`

### helia_edge.export.record.EnvironmentEntry.model_config

`attribute` · `python`

```python
model_config = _CONFIG
```

Source: `helia_edge/export/record.py:190`

### helia_edge.export.record.EnvironmentEntry.helia_edge

`attribute` · `python`

```python
helia_edge: HeliaEdgeRecord
```

Source: `helia_edge/export/record.py:192`

### helia_edge.export.record.EnvironmentEntry.python

`attribute` · `python`

```python
python: str
```

Source: `helia_edge/export/record.py:193`

### helia_edge.export.record.EnvironmentEntry.platform

`attribute` · `python`

```python
platform: str
```

Source: `helia_edge/export/record.py:194`

### helia_edge.export.record.EnvironmentEntry.packages

`attribute` · `python`

```python
packages: dict[str, str | None]
```

Source: `helia_edge/export/record.py:195`

### helia_edge.export.record.EnvironmentEntry.from_record

`method` · `python`

```python
from_record(record: EnvironmentRecord) -> EnvironmentEntry
```

`classmethod`

Source: `helia_edge/export/record.py:197`

## helia_edge.export.record.ExportRecord

`class` · `python`

```python
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.

Source: `helia_edge/export/record.py:209`

### helia_edge.export.record.ExportRecord.model_config

`attribute` · `python`

```python
model_config = _CONFIG
```

Source: `helia_edge/export/record.py:216`

### helia_edge.export.record.ExportRecord.schema_

`attribute` · `python`

```python
schema_: Literal['helia-edge/export-record@1'] = Field(default=RECORD_SCHEMA, alias='schema')
```

Source: `helia_edge/export/record.py:218`

### helia_edge.export.record.ExportRecord.model

`attribute` · `python`

```python
model: ModelSpec | None
```

Source: `helia_edge/export/record.py:219`

### helia_edge.export.record.ExportRecord.weights

`attribute` · `python`

```python
weights: WeightsRecord
```

Source: `helia_edge/export/record.py:220`

### helia_edge.export.record.ExportRecord.export

`attribute` · `python`

```python
export: ExportSettings
```

Source: `helia_edge/export/record.py:221`

### helia_edge.export.record.ExportRecord.artifact

`attribute` · `python`

```python
artifact: FileRecord
```

Source: `helia_edge/export/record.py:222`

### helia_edge.export.record.ExportRecord.io

`attribute` · `python`

```python
io: IORecord
```

Source: `helia_edge/export/record.py:223`

### helia_edge.export.record.ExportRecord.golden

`attribute` · `python`

```python
golden: GoldenRecord | None = None
```

Source: `helia_edge/export/record.py:224`

### helia_edge.export.record.ExportRecord.environment

`attribute` · `python`

```python
environment: EnvironmentEntry
```

Source: `helia_edge/export/record.py:225`

### helia_edge.export.record.ExportRecord.write

`method` · `python`

```python
write(path: Path | str) -> None
```

Write the record as JSON.

Source: `helia_edge/export/record.py:236`

### helia_edge.export.record.ExportRecord.read

`method` · `python`

```python
read(path: Path | str) -> ExportRecord
```

`classmethod`

Read a record written by ``write``.

Source: `helia_edge/export/record.py:240`

## helia_edge.export.record.file_record

`function` · `python`

```python
file_record(name: str, data: bytes) -> FileRecord
```

The record of ``data`` written as ``name``.

Source: `helia_edge/export/record.py:246`

## helia_edge.export.record.weights_digest

`function` · `python`

```python
weights_digest(model) -> str
```

``sha256:`` 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.

Source: `helia_edge/export/record.py:251`
