You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The SafeTensors reader in VirtualiZarr allows you to reference tensors stored in SafeTensors files. This guide explains how to use the reader effectively.
4
+
5
+
## What is SafeTensors Format?
6
+
7
+
SafeTensors is a file format for storing tensors (multidimensional arrays) that offers several advantages:
8
+
- Safe: No use of pickle, eliminating security concerns
9
+
- Efficient: Zero-copy access for fast loading
10
+
- Simple: Straightforward binary format with JSON header
11
+
- Language-agnostic: Available across Python, Rust, C++, and JavaScript
12
+
13
+
The format consists of:
14
+
- 8 bytes (header size): little-endian uint64 containing the size of the header
15
+
- JSON header: Contains metadata for all tensors (shapes, dtypes, offsets)
16
+
- Binary data: Contiguous tensor data
17
+
18
+
## How VirtualiZarr's SafeTensors Reader Works
19
+
20
+
VirtualiZarr's SafeTensors reader allows you to:
21
+
- Work with the tensors as xarray DataArrays with named dimensions
22
+
- Access specific slices of tensors from cloud storage
23
+
- Preserve metadata from the original SafeTensors file
min-deps = ["dev", "test", "hdf", "hdf5", "hdf5-lib"] # VirtualiZarr/conftest.py using h5py, so the minimum set of dependencies for testing still includes hdf libs
187
192
# Inherit from min-deps to get all the test commands, along with optional dependencies
0 commit comments