Skip to main content

TensorsContainer

A checkpoint's tensors, materialized on demand: get(name) reads one entry onto the load policy's device, load_all() reads every entry, prefetch() starts reads ahead of use, evict() drops a materialized entry back to disk. names(), len() and in read the header only.

__init__​

__init__(self, /, *args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

contains​

containscontains(self, name: str) -> bool

contains(self, name: str) -> bool

contains(name) -> bool

Whether name is an entry.

entry​

entryentry(self, name: str) -> clika_runtime._core.io.ContainerEntry | None

entry(self, name: str) -> clika_runtime._core.io.ContainerEntry | None

entry(name) -> ContainerEntry | None

The parsed metadata of one entry with no payload IO; None for an unknown or a composed name.

entry_bytes​

entry_bytesentry_bytes(self, name: str) -> int

entry_bytes(self, name: str) -> int

entry_bytes(name) -> int

The on-disk payload bytes of one entry.

evict​

evictevict(self, name: str) -> None

evict(self, name: str) -> None

evict(name) -> None

Drop a materialized entry back to disk; the next get() reads it again.

evict_all​

evict_allevict_all(self) -> None

evict_all(self) -> None

evict_all() -> None

Drop every materialized entry back to disk.

get​

getget(self, name: str) -> clika_runtime._core.Tensor

get(self, name: str) -> clika_runtime._core.Tensor

get(name) -> Tensor

The entry materialized on the load policy's device (read from disk on first use, then cached until evicted).

keys​

keyskeys(self) -> list[str]

keys(self) -> list[str]

keys() -> list[str]

Every entry name (the dict spelling of names()).

load_all​

load_allload_all(self) -> dict

load_all(self) -> dict

load_all() -> dict[str, Tensor]

Every entry materialized, as a dict.

load_into​

load_intoload_into(self, name: str, dst: clika_runtime._core.Tensor, where: object | None = None) -> None

load_into(self, name: str, dst: clika_runtime._core.Tensor, where: object | None = None) -> None

load_into(name, dst, where=None) -> None

Read the entry into an existing tensor of the same shape and dtype, which ends carrying the entry's quantization scheme (none for a plain entry).

names​

namesnames(self) -> list[str]

names(self) -> list[str]

names() -> list[str]

Every entry name, header order.

open​

openopen(path: str, *, device: object | None = None, sticky: bool = False) -> clika_runtime._core.io.TensorsContainer

open(path: str, *, device: object | None = None, sticky: bool = False) -> clika_runtime._core.io.TensorsContainer

open(path, *, device=None, sticky=False) -> TensorsContainer

Open a checkpoint by its suffix: .safetensors, a torch checkpoint (.pt / .pth / .bin / .ckpt) or .gguf. Entries materialize on device (a Device, a device string or a Stream; None = the CPU); sticky keeps their lineage on disk so derived tensors can be evicted and re-read.

prefetch​

prefetchprefetch(self, names: collections.abc.Sequence[str], where: object | None = None) -> None

prefetch(self, names: collections.abc.Sequence[str], where: object | None = None) -> None

prefetch(names, where=None) -> None

Start reading the named entries ahead of use, onto where (a Device, a device string or a Stream; None = the load policy's device).

release​

releaserelease(self, name: str) -> None

release(self, name: str) -> None

release(name) -> None

Drop the container's own handle to a materialized entry; tensors already handed out stay valid.

size​

sizesize(self) -> int

size(self) -> int

size() -> int

The entry count.

subset​

subsetsubset(self, prefix: str | None = None, *, regex: str | None = None, strip: bool = True, return_clone: bool = False) -> clika_runtime._core.io.TensorsContainer

subset(self, prefix: str | None = None, *, regex: str | None = None, strip: bool = True, return_clone: bool = False) -> clika_runtime._core.io.TensorsContainer

subset(prefix=None, *, regex=None, strip=True, return_clone=False) -> TensorsContainer

A sub-container over the entries a prefix selects (every name starting with it) or a regular expression selects (RE2 syntax, matched against the whole name), the one a block loads its weights from by its own names (load_state_dict's strict check then reads the sub-container's names alone). strip=True serves the entries with the prefix removed, or under the pattern's first capture group (a pattern with no group raises); strip=False keeps the full names. By default the entries MOVE out of this container (one owner per name: they leave names(), and a second subset of the same names is empty); return_clone=True shares them and this container keeps serving them too (a weight two modules bind). No tensor data is read or copied either way, and a weight read through both containers is one tensor. An empty selection is an empty sub-container; two entries producing one name, an empty produced name or a pattern that does not compile raise.

total_bytes​

total_bytestotal_bytes(self) -> int

total_bytes(self) -> int

total_bytes() -> int

The payload bytes of every entry, summed.