AQIT 0.1.0
Loading...
Searching...
No Matches
aquin.compute.torch_io Namespace Reference

Functions

bool is_corrupt_pytorch_zip (BaseException exc)
Any load_checkpoint (str|Path path, *, Any map_location=None)
dict[str, Any]|None load_norm_stats (str|Path path, *, Any map_location=None)
bool looks_like_catalog_metadata_blob (str|Path path)
bool looks_like_invalid_norm_blob (str|Path path)
bool looks_like_json_error_blob (str|Path path)
bool looks_like_catalog_metadata_dict (Any data)
dict[str, Any] _checkpoint_tensors (Any ckpt)
bool _has_sae_weight_tensors (dict[str, Any] tensors)
bool is_valid_sae_checkpoint_path (str|Path path)

Function Documentation

◆ _checkpoint_tensors()

dict[str, Any] _checkpoint_tensors ( Any ckpt)
protected

Definition at line 155 of file torch_io.py.

Referenced by is_valid_sae_checkpoint_path().

◆ _has_sae_weight_tensors()

bool _has_sae_weight_tensors ( dict[str, Any] tensors)
protected

Definition at line 167 of file torch_io.py.

Referenced by is_valid_sae_checkpoint_path().

◆ is_corrupt_pytorch_zip()

bool is_corrupt_pytorch_zip ( BaseException exc)

Definition at line 14 of file torch_io.py.

Referenced by load_checkpoint().

◆ is_valid_sae_checkpoint_path()

bool is_valid_sae_checkpoint_path ( str | Path path)
False when a cached SAE file is catalog metadata or another non-checkpoint blob.

Definition at line 176 of file torch_io.py.

References _checkpoint_tensors(), _has_sae_weight_tensors(), load_checkpoint(), looks_like_catalog_metadata_blob(), looks_like_catalog_metadata_dict(), and looks_like_json_error_blob().

◆ load_checkpoint()

Any load_checkpoint ( str | Path path,
* ,
Any map_location = None )
Load a trusted Aquin .pt checkpoint (SAE, norm stats, activations).

Definition at line 23 of file torch_io.py.

References is_corrupt_pytorch_zip().

Referenced by is_valid_sae_checkpoint_path(), and load_norm_stats().

◆ load_norm_stats()

dict[str, Any] | None load_norm_stats ( str | Path path,
* ,
Any map_location = None )
Load {mean, std} norm stats from .pt (torch) or .json sidecar.

Definition at line 44 of file torch_io.py.

References load_checkpoint(), looks_like_catalog_metadata_blob(), and looks_like_catalog_metadata_dict().

◆ looks_like_catalog_metadata_blob()

bool looks_like_catalog_metadata_blob ( str | Path path)
True when a .pt file is actually public_saes catalog JSON (not norm stats).

Definition at line 102 of file torch_io.py.

Referenced by is_valid_sae_checkpoint_path(), load_norm_stats(), and looks_like_invalid_norm_blob().

◆ looks_like_catalog_metadata_dict()

bool looks_like_catalog_metadata_dict ( Any data)
True when a loaded checkpoint dict is public_saes row metadata, not SAE weights.

Definition at line 140 of file torch_io.py.

Referenced by is_valid_sae_checkpoint_path(), and load_norm_stats().

◆ looks_like_invalid_norm_blob()

bool looks_like_invalid_norm_blob ( str | Path path)
True when a norm file is catalog JSON or other non-norm JSON.

Definition at line 118 of file torch_io.py.

References looks_like_catalog_metadata_blob().

◆ looks_like_json_error_blob()

bool looks_like_json_error_blob ( str | Path path)
True when a downloaded artifact is likely an API error body, not weights.

Definition at line 132 of file torch_io.py.

Referenced by is_valid_sae_checkpoint_path().