Skip to main content

Tensor Train linear algebra package for efficient high-dimensional tensor operations

Project description

TTGlow Logo

TTGlow

A Tensor Train linear algebra package for efficient high-dimensional tensor operations in PyTorch.

Overview

TTGlow provides an efficient implementation of the Tensor Train (TT) decomposition, a powerful technique for representing and manipulating high-dimensional tensors with reduced memory footprint and computational cost. This package is particularly useful for:

  • High-dimensional data analysis
  • Quantum many-body physics simulations
  • Machine learning with tensor methods
  • Efficient storage and computation of large-scale tensors

Installation

Using Pixi (Recommended)

# Clone the repository
git clone https://github.com/romanellerbrock/ttglow.git
cd ttglow

# Install dependencies with pixi
pixi install

# Activate the environment
pixi shell

Using pip

pip install -e .

Quick Start

import torch
from ttglow import TensorTrain, dot, add, scale

# Create a random Tensor Train
dims = [10, 20, 15]  # Tensor dimensions
ranks = [3, 5]        # TT-ranks
tt = TensorTrain.random(dims, ranks)

# Convert to full tensor
full_tensor = tt.to_tensor()

# Create a constant tensor in TT format
tt_ones = TensorTrain.ones([10, 20, 15], value=3.14)

# Dot product (inner product)
tt1 = TensorTrain.random([4, 5, 6], [2, 3])
tt2 = TensorTrain.random([4, 5, 6], [2, 3])
matrices = dot(tt1, tt2)
inner_product = matrices[-1].item()  # Scalar result
norm_squared = dot(tt1, tt1)[-1].item()  # Self inner product

# Addition
tt_sum = add(tt1, tt2)  # Returns new TT with ranks = r1 + r2

# Scalar multiplication
tt_scaled = scale(tt1, 2.5)  # Multiply by scalar

Features

  • Efficient TT representation: Store high-dimensional tensors with minimal memory
  • Core operations:
    • dot: Inner product of two TT tensors
    • hadamard: Element-wise multiplication
    • add: Summation of TT tensors
    • scale: Scalar multiplication
  • Flexible construction: Create TT tensors from scratch or via decomposition
  • PyTorch backend: Full GPU support and automatic differentiation

Development

Running Tests

pixi run test

Code Formatting

pixi run format

Linting

pixi run lint

Test Coverage

pixi run test-cov

Project Structure

ttglow/
├── src/ttglow/           # Main package code
│   ├── __init__.py
│   └── tensortrain.py    # TT implementation
├── tests/                # Test suite
│   └── test_tensortrain.py
├── examples/             # Usage examples
├── pixi.toml             # Pixi configuration
└── pyproject.toml        # Python package metadata

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

References

  • Oseledets, I. V. (2011). "Tensor-train decomposition". SIAM J. Sci. Comput., 33(5), 2295-2317.

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

ttglow-0.1.1.tar.gz (68.4 kB view details)

Uploaded Source

Built Distribution

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

ttglow-0.1.1-py3-none-any.whl (44.4 kB view details)

Uploaded Python 3

File details

Details for the file ttglow-0.1.1.tar.gz.

File metadata

  • Download URL: ttglow-0.1.1.tar.gz
  • Upload date:
  • Size: 68.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for ttglow-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c133dd01cd01e3412719b9d71517222a32669629cd082927c1ad5731d9de3bf8
MD5 95ad259e4e15863949396c81dfbb8e0c
BLAKE2b-256 9c1f45fde55dd450e3e64ddfa7f159f560c95dd687d975b0816589ffebac111b

See more details on using hashes here.

File details

Details for the file ttglow-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ttglow-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 44.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for ttglow-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7aaf168d8b028b6852e3b6ff6d396ba0025cb22ad4b75a76e22cba8838484d69
MD5 2b333f8d229e6d141477e7576a9749e5
BLAKE2b-256 39bdc16e9f8df214f486776f0c650c431cd378395bd87ed7b05db788ad0954c0

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