fhelium.serialization.safetensors
Single-file safetensors persistence for FHElium values.
FILE_FORMAT
constant View source
FILE_FORMAT = 'fhelium-value'FILE_SCHEMA_VERSION
constant View source
FILE_SCHEMA_VERSION = 2T
constant View source
T = TypeVar('T', bound=TensorResident)ValueFileMetadata
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] |
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.
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.