Skip to main content

Python bindings for the zTensor library.

Project description

zTensor File Format

Version 0.1.0

zTensor is a binary format for storing large multi-dimensional arrays (tensors), designed for efficient, safe, and flexible access. It supports raw and compressed (zstd) encodings, quantized and sparse layouts, and is extensible.

For dense tensors stored with encoding: "raw" and matching endianness, zTensor enables zero-copy access to tensor data.

File Layout

+-------------------------------+
| Magic Number (8 bytes)        |
+-------------------------------+
| Tensor Blob 0 (aligned)       |
+-------------------------------+
| Padding (if needed)           |
+-------------------------------+
| Tensor Blob 1 (aligned)       |
+-------------------------------+
| ...                           |
+-------------------------------+
| CBOR Metadata Array           |
+-------------------------------+
| CBOR Array Size (8 bytes)     |
+-------------------------------+
  • Magic Number: ASCII "ZTEN0001" at offset 0.
  • Tensor Blobs: Each tensor's data, starting at a 64-byte aligned offset. No per-blob headers. Padding (undefined value, usually zero) is inserted as needed.
  • CBOR Metadata Array: At the end of the file, a CBOR-encoded array of metadata maps (one per tensor).
  • CBOR Array Size: Last 8 bytes, little-endian uint64, gives the size of the CBOR array.

Tensor Metadata (CBOR Map)

Each tensor's metadata is a CBOR map with these required fields:

  • name (string): Tensor name.
  • offset (uint64): Absolute file offset to tensor data (multiple of 64).
  • size (uint64): On-disk size in bytes (compressed if applicable).
  • dtype (string): Data type (see below).
  • shape (array): Array of dimensions (empty for scalar).
  • encoding (string): Data encoding (see below).
  • layout (string): "dense" (default) or "sparse". For sparse, see below.

Optional fields:

  • data_endianness (string): "little" or "big" (default: little, for raw multi-byte types).
  • checksum (string): e.g., "crc32c:0x1234ABCD" or "sha256:...".
  • Custom fields are allowed; unknown keys are ignored by readers.

Supported Data Types (dtype)

  • float64, float32, float16, bfloat16
  • int64, int32, int16, int8
  • uint64, uint32, uint16, uint8
  • bool

Supported Encodings (encoding)

  • raw: Direct binary dump of tensor elements (with data_endianness if multi-byte).
  • zstd: Zstandard-compressed data. size is compressed size.

Layouts

  • dense (default): Standard contiguous tensor data.
  • sparse: Data is stored in a sparse format. The metadata map must include a sparse_format field (e.g., "csr", "coo") and any additional fields required to describe the sparse structure (such as index arrays, indptr, etc.).

Index Reading

To read the index:

  1. Read the last 8 bytes for the CBOR array size.
  2. Seek backwards by that amount to read the CBOR metadata array.

As a result, the start offset of the metadata is: (file size) - (size of the metadata) - (8 byte).

Zero-Tensor Files

A valid zTensor file may contain zero tensors:

  • 8 bytes magic, 1 byte empty CBOR array (0x80), 8 bytes size (0x01...00).
  • Total: 17 bytes.

Extensibility

  • New dtype, encoding, and layout values may be added in future versions.
  • Custom metadata fields are allowed; unknown fields are ignored.

Notes

  • All offsets are absolute and account for the 8-byte magic number.
  • All tensor data blobs are 64-byte aligned.
  • No per-blob headers; all metadata is in the CBOR array at the end of the file.
  • For encoding: "raw" and multi-byte dtype, data is little-endian unless data_endianness is specified.
  • For sparse tensors, the metadata must fully describe the sparse structure.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ztensor-0.1.0.tar.gz (26.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ztensor-0.1.0-py3-none-win_amd64.whl (404.1 kB view details)

Uploaded Python 3Windows x86-64

ztensor-0.1.0-py3-none-win32.whl (367.8 kB view details)

Uploaded Python 3Windows x86

ztensor-0.1.0-py3-none-musllinux_1_2_x86_64.whl (897.4 kB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

ztensor-0.1.0-py3-none-musllinux_1_2_i686.whl (928.4 kB view details)

Uploaded Python 3musllinux: musl 1.2+ i686

ztensor-0.1.0-py3-none-musllinux_1_2_armv7l.whl (930.6 kB view details)

Uploaded Python 3musllinux: musl 1.2+ ARMv7l

ztensor-0.1.0-py3-none-musllinux_1_2_aarch64.whl (882.5 kB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

ztensor-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (723.4 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

ztensor-0.1.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl (732.5 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ s390x

ztensor-0.1.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (800.5 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ ppc64le

ztensor-0.1.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (658.7 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARMv7l

ztensor-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (664.8 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

ztensor-0.1.0-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (746.5 kB view details)

Uploaded Python 3manylinux: glibc 2.5+ i686

ztensor-0.1.0-py3-none-macosx_11_0_arm64.whl (536.3 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

ztensor-0.1.0-py3-none-macosx_10_12_x86_64.whl (646.2 kB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file ztensor-0.1.0.tar.gz.

File metadata

  • Download URL: ztensor-0.1.0.tar.gz
  • Upload date:
  • Size: 26.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.9.0

File hashes

Hashes for ztensor-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f8e3262ad0ad044f9b52099fea5a83d7a1c1e8cc5fd7557469ed9723c0f2bbb0
MD5 1381e919104953b4f217ffc338f02f06
BLAKE2b-256 6b405b6897a8b93d2994391c98ceca3c95c6ddaceaeb610f3b229e512fe74b2c

See more details on using hashes here.

File details

Details for the file ztensor-0.1.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: ztensor-0.1.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 404.1 kB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.9.0

File hashes

Hashes for ztensor-0.1.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 5e1b531a6f7f57b53a4e86182679d2f5436a1939fcae3d3b59d22403198bb256
MD5 ffef7190a092e8e324bfd5e7721dd25a
BLAKE2b-256 f73a99df30555c2016bca110781314aebfa4584b4a31d07bcef464946c011efb

See more details on using hashes here.

File details

Details for the file ztensor-0.1.0-py3-none-win32.whl.

File metadata

  • Download URL: ztensor-0.1.0-py3-none-win32.whl
  • Upload date:
  • Size: 367.8 kB
  • Tags: Python 3, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.9.0

File hashes

Hashes for ztensor-0.1.0-py3-none-win32.whl
Algorithm Hash digest
SHA256 f4f62a2f535e949edef597cb5e49e4fdede8373c12186a80488c20deb7331528
MD5 83636e25fa30cd8c82c3636037059fa1
BLAKE2b-256 1d2a9b5f7057d5893ad0eed026f6792308641a3b47a197b6b104f11542275004

See more details on using hashes here.

File details

Details for the file ztensor-0.1.0-py3-none-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for ztensor-0.1.0-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 438da03fe089bb41af65e0e7fd4d64df628d2c15fb5f97e65963187e64a2bdff
MD5 c1e24bb02dc1ba10b355503747bc4023
BLAKE2b-256 e35fc1c6da3778561132bf2382469aa592fe81d1c3fe855cea2ff90a9658daee

See more details on using hashes here.

File details

Details for the file ztensor-0.1.0-py3-none-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for ztensor-0.1.0-py3-none-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 c4244e0a381bd869fdd98aafd4c2dcb92be50e7339fab2803c9c8d8ec7be630f
MD5 53b602bd208a48ca485e43d1721c30ae
BLAKE2b-256 bd311b91cd1fef8b7c2613b5da7ab6ecdbe5a681834278f440e93a3d1696b336

See more details on using hashes here.

File details

Details for the file ztensor-0.1.0-py3-none-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for ztensor-0.1.0-py3-none-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 fffee0b005f4adef984e435f51593430c87dc61b89eaf787c6a00099b9889d4b
MD5 712f2ce08c4c862bafe22d099e941665
BLAKE2b-256 67ac6e7d79b7c60832e8f0b743a3f3cff296249be07d5f48c46cbb52b44bd135

See more details on using hashes here.

File details

Details for the file ztensor-0.1.0-py3-none-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for ztensor-0.1.0-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 d71b5c07a40a9482f14df9664fea287909893b5703092afc84ff45228e4a9fd3
MD5 721b78aaf8a0ac63ff5db0c20c44ccad
BLAKE2b-256 e1d2e7022a3ab32e24adcf8ba8e6c590cabb22ecdf06a6894e612309f5ee40f6

See more details on using hashes here.

File details

Details for the file ztensor-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ztensor-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f9c172f8da09a29d939b730e499ef47bb59e1e7ee93bdd78f0e56787a653d21c
MD5 c6ad2cd4d65b74e16a84e986847ba4af
BLAKE2b-256 2b49917d12f4487227c2ec8cb25438f2cf8eb386b754c3f5a4574f91dab7d202

See more details on using hashes here.

File details

Details for the file ztensor-0.1.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for ztensor-0.1.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 52103115b25848c0dc9c5d03f2d486e13d59ae5bfb68102c4e542b3286e8d501
MD5 6cd6c726fd215bb1f71ba020ae044faf
BLAKE2b-256 9056f4351919f431ab1aaccbb89095aface0ae2c266dfb6f743996a449bbeaed

See more details on using hashes here.

File details

Details for the file ztensor-0.1.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for ztensor-0.1.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 812d9698d90c53a26d7dcb3e0554b4e5c2451a12b30ce0753c9a1f2ff2d8d8d0
MD5 9a9701c587b3447b35aadb2e0ef160d8
BLAKE2b-256 3651033e6b1f224d1efd4b013245c9e6195761ce3b5248055670dde1b01959c3

See more details on using hashes here.

File details

Details for the file ztensor-0.1.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for ztensor-0.1.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 50929974e7dbe57ffdc9de490e95db901ec60c376bb6670aaa6e7400cb077f6c
MD5 5615e29f0014acaa6c1b72775dae9a02
BLAKE2b-256 8e2b541c7e401099481fc6b1a5f05f754d20cac5d851f38cf7878f4743015ea8

See more details on using hashes here.

File details

Details for the file ztensor-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ztensor-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 35de99f58cfbdacf415e6e52a4d1ce48df2cf7afb5008c60afd24ce56213e0d1
MD5 ef6dae22cdf0b72fad6696ef6082debf
BLAKE2b-256 c92027b2603f499a87a953f6e602e5d90d449d1fb86dac140a43c1dd7a886991

See more details on using hashes here.

File details

Details for the file ztensor-0.1.0-py3-none-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for ztensor-0.1.0-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 b8aecd6680b6b1b86bb1547228e70bd9fb384ccb922988fd15a46119cd9303f9
MD5 fe8f5195127a6531cc685173066d0551
BLAKE2b-256 4f64f849bd2b14af6088a1676cc067129c4e0eeea7e0cc2383a8e5f662594287

See more details on using hashes here.

File details

Details for the file ztensor-0.1.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ztensor-0.1.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 927e8adc347024b21dac5a657d73a08196d63421670641fbf5e469c014f2c05e
MD5 984ea2b0ee428f911e513eea8b9b9ab5
BLAKE2b-256 f474d90733d185f5f10be46ab4e74ff0b88f5e788752381931bf94d15545eb44

See more details on using hashes here.

File details

Details for the file ztensor-0.1.0-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for ztensor-0.1.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4743a6e736e45d5a5a366ec8f59721f7140a46400c340d23f1c5b7339c596178
MD5 1d0e7d24906dc7bd61fb247457393aa5
BLAKE2b-256 29fdc0a6a3d3d67e61a0d3f7e49106d987dc0a1538bb273a1fe5d2c5c2aa8491

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page