---
title: "TensorsContainer"
sidebar_label: "TensorsContainer"
description: "The clika_runtime.io TensorsContainer class."
---

<!-- Generated by tools/api_reference/generate_api_docs.py. Do not edit. -->

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__`

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

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

## `contains`

```python
containscontains(self, name: str) -> bool
```

contains(self, name: str) -> bool

contains(name) -> bool

Whether `name` is an entry.

## `entry`

```python
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`

```python
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`

```python
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`

```python
evict_allevict_all(self) -> None
```

evict_all(self) -> None

evict_all() -> None

Drop every materialized entry back to disk.

## `get`

```python
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`

```python
keyskeys(self) -> list[str]
```

keys(self) -> list[str]

keys() -> list[str]

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

## `load_all`

```python
load_allload_all(self) -> dict
```

load_all(self) -> dict

load_all() -> dict[str, Tensor]

Every entry materialized, as a dict.

## `load_into`

```python
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`

```python
namesnames(self) -> list[str]
```

names(self) -> list[str]

names() -> list[str]

Every entry name, header order.

## `open`

```python
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`

```python
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`

```python
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`

```python
sizesize(self) -> int
```

size(self) -> int

size() -> int

The entry count.

## `subset`

```python
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`

```python
total_bytestotal_bytes(self) -> int
```

total_bytes(self) -> int

total_bytes() -> int

The payload bytes of every entry, summed.
