fhelium.serialization
Typed value files and Program files with optional Tensor bindings.
COMPRESSED_PLAINTEXT_FORMAT_VERSION
constant View source
COMPRESSED_PLAINTEXT_FORMAT_VERSION = 1FILE_FORMAT
constant View source
FILE_FORMAT = 'fhelium-value'FILE_SCHEMA_VERSION
constant View source
FILE_SCHEMA_VERSION = 2VALUE_SCHEMA_VERSION
constant View source
VALUE_SCHEMA_VERSION = 4ValueEnvelope
class View source
ValueEnvelope(schema_version: int, value_type: str, metadata: dict[str, Any], tensors: dict[str, torch.Tensor])A value description with tensors but no path or store policy.
The envelope is the shared representation for application-owned storage and memory managers. Its tensors may be moved or persisted by the caller, then passed to to_value to reconstruct the original FHElium value type.
Attributes
| Name | Type | Default/value |
|---|---|---|
schema_version | int | |
value_type | str | |
metadata | dict[str, Any] | |
tensors | dict[str, torch.Tensor] |
from_value
method
def from_value(value: TensorResident) -> Self: ...Describe one live value without choosing storage policy.
to_value
method
def to_value() -> TensorResident: ...Reconstruct the concrete FHElium value type.
nbytes
property
nbytes: intValueFileMetadata
class View source
ValueFileMetadata(file_schema_version: int, value_schema_version: int, value_type: str, nbytes: int, tensor_metadata: dict[str, dict[str, Any]], value_metadata: dict[str, Any])Validated metadata inspectable without materializing tensor payloads.
Attributes
| Name | Type | Default/value |
|---|---|---|
file_schema_version | int | |
value_schema_version | int | |
value_type | str | |
nbytes | int | |
tensor_metadata | dict[str, dict[str, Any]] | |
value_metadata | dict[str, Any] |
inspect_compilation
function View source
def inspect_compilation(path: str | os.PathLike[str]) -> ValueFileMetadata: ...Inspect Program and binding metadata without loading numerical payloads.
load_compilation
function View source
def load_compilation(path: str | os.PathLike[str], *, device: torch.device | str='cpu') -> Compilation: ...Restore a Program and saved bindings; leave all other symbols unbound.
Loading does not prepare resources, run passes, compile kernels, or execute the Program. Every stored byte storage is copied to independent writable memory on device once, so views continue to share storage after transfer.
save_compilation
function View source
def save_compilation(compilation: Compilation, path: str | os.PathLike[str], *, include_materials: bool | Collection[str]=False, overwrite: bool=False) -> ValueFileMetadata: ...Save a Program and selected bound Tensors without serializing Python state.
False omits all data; True includes every current binding; a collection selects bound symbols. Missing Program bindings may remain external. The payload retains strided views, shared storage, repeated Tensor objects, and conjugate/negative view bits. Only bytes covered by selected views are copied; holes in their shared storage are zero-filled. Original addresses, devices, autograd history, workspaces, reports, and executables are not saved.
Data is unencrypted. Inclusion is opt-in and does not detect sensitive contents of arbitrary Tensors. Callers own synchronization with live writers.
inspect_value
function View source
def inspect_value(path: str | os.PathLike[str]) -> ValueFileMetadata: ...Inspect one value file without materializing its tensor payloads.
load_value
function View source
def load_value(path: str | os.PathLike[str], *, device: torch.device | str='cpu', expected_type: type[T] | None=None) -> T: ...Load one value from a caller-selected value-file path.
This is a file-codec operation: the caller owns path naming, replacement, and lifecycle. ArtifactStore.get is the separate repository operation for logical names, generations, checksums, and catalog transactions. Materialization defaults to CPU unless device selects another target.
save_value
function View source
def save_value(value: TensorResident, path: str | os.PathLike[str], *, allow_secret: bool=False, overwrite: bool=False) -> ValueFileMetadata: ...Atomically save one value to the caller-selected file path.
The file uses the versioned ValueEnvelope representation. Saving a secret key requires allow_secret=True. The file stores plaintext key data; callers must protect the destination and apply any required encryption.
supported_value_types
function View source
def supported_value_types() -> tuple[str, ...]: ...