Skip to main content

Tensor-free randomized HOSVD (randomized Tucker decomposition)

Project description

TensorRSVD

PyPI version CI Documentation License: MIT

Tensor-free randomized Higher-Order SVD (Tucker decomposition).

TensorRSVD computes Tucker decompositions of high-dimensional tensors that are defined as Python functions without ever forming the dense tensor in memory. It uses randomized linear algebra (Halko et al. 2011) to approximate the dominant factor matrices mode-by-mode, scaling to tensors that would be impossible to store explicitly.

Installation

pip install tensorrsvd

Optional backends for GPU or JIT-compiled acceleration:

pip install "tensorrsvd[jax]"          # JAX (CPU / GPU / TPU)
pip install "tensorrsvd[jaxcuda12]"    # JAX with CUDA 12
pip install "tensorrsvd[jaxcuda13]"    # JAX with CUDA 13
pip install "tensorrsvd[cupy]"         # CuPy (NVIDIA GPU, CUDA required)

Note: CuPy wheels are CUDA-version-specific. If the above does not match your CUDA installation, install CuPy manually following the CuPy installation guide.

Quick start

import numpy as np
from tensorrsvd import ho_rsvd

# Define your tensor as a callable
def my_tensor(x0, x1, x2):
    return x0 - x1 + x2

# Compute the randomized Tucker factors
U_list, S_list = ho_rsvd(
    tensor=my_tensor,
    tensor_shape=(64, 64, 64),
    dtype=np.float64,
    rank=4,
    num_oversamples=10,
    num_idxs=3,
)

# U_list[i] has shape (n_i, rank_i) with orthonormal columns
# S_list[i] has shape (rank_i,) (descending singular values)
print([U.shape for U in U_list])   # [(64, 4), (64, 4), (64, 4)]

Switch to a JAX or CuPy backend by passing backend="jax" or backend="cupy".

Documentation

Full documentation (installation, user guide, theory, and API reference, etc.) is available at tensorrsvd.readthedocs.io.

References

  • N. Halko, P. G. Martinsson, and J. A. Tropp, Finding Structure with Randomness: Probabilistic Algorithms for Constructing Approximate Matrix Decompositions, SIAM Review, 53(2):217–288, 2011. doi:10.1137/090771806

  • L. De Lathauwer, B. De Moor, and J. Vandewalle, A Multilinear Singular Value Decomposition, SIAM Journal on Matrix Analysis and Applications, 21(4):1253–1278, 2000. doi:10.1137/S0895479896305696

License

MIT (see LICENSE)

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

tensorrsvd-0.1.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

tensorrsvd-0.1.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tensorrsvd-0.1.0.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tensorrsvd-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3c4aa92b8a79b127420e02ef229f05a34c32e584cbcf7c54ea8646a2ea6e58e9
MD5 759e5ec54b40c09204afedf4ab868acf
BLAKE2b-256 fdffb207e56a530c1cb4d35cb558f15328294279ba7627af0dde66e0c9ffb5be

See more details on using hashes here.

Provenance

The following attestation bundles were made for tensorrsvd-0.1.0.tar.gz:

Publisher: publish.yml on PaulVirally/TensorRSVD

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tensorrsvd-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tensorrsvd-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tensorrsvd-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 718caa0c7c274303cea7dcf5f139a194a9232626b04ba7a80001e5f35abb35d5
MD5 8e308a5285604c2f7e5725f8f6907675
BLAKE2b-256 dbe1e425b3d451577b9af6180f8bde22797b04c24b4646fa20ca13bfc005a3ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for tensorrsvd-0.1.0-py3-none-any.whl:

Publisher: publish.yml on PaulVirally/TensorRSVD

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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