TensorPlay
API symbolsserialization
Copy
View MarkdownDownload .md

tensorplay.serialization.load

tensorplay.serialization.load(f: str | PathLike[str], map_location: Any | None = None, *, mmap: bool = False, weights_only: bool = True) Any[source]

Load a checkpoint saved by tp.save or torch.save.

Format is detected by extension or content sniffing: .mega (and MEGA shard indexes), .safetensors, and torch archives (.pt/.pth – zip, magic-number stream, and tar layouts).

Parameters:
  • f – path or file-like object (seekable binary).

  • map_location – controls where tensors land. Accepts a device string / tensorplay.Device (all tensors), a mapping of saved location -> target, or a callable invoked per storage as fn(storage_stub, location) returning None, a device, or a TensorPlay tensor receiving the data.

  • mmap – if true, MEGA and safetensors tensors are zero-copy views over a private (copy-on-write) mapping of the file; the returned containers keep the mapping alive, and bytes are paged in on first touch. Explicit device remapping still copies. Torch archives load eagerly.

  • weights_only – accepted for API familiarity; every TensorPlay loader is weights-only by construction. Passing False warns.

Ask DeepWiki