Metadata-Version: 2.4
Name: hiepy
Version: 0.1.0
Summary: A comprehensive PyTorch framework for Hierarchical Tucker tensors.
Author: Benedikt Schroeter
License-Expression: EUPL-1.2
Project-URL: Documentation, https://beschroe.github.io/HiePy/
Project-URL: Repository, https://github.com/Beschroe/HiePy
Project-URL: Issues, https://github.com/Beschroe/HiePy/issues
Project-URL: Changelog, https://github.com/Beschroe/HiePy/blob/main/CHANGELOG.md
Keywords: tensor,hierarchical tucker,low-rank,tensor decomposition,pytorch
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Typing :: Typed
Requires-Python: ==3.12.*
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: torch>=2.6
Requires-Dist: numpy
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: hypothesis>=6.0.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"
Provides-Extra: docs
Requires-Dist: mkdocs>=1.5.0; extra == "docs"
Requires-Dist: mkdocs-material>=9.0.0; extra == "docs"
Requires-Dist: mkdocstrings[python]>=0.24.0; extra == "docs"
Requires-Dist: pymdown-extensions>=10.0; extra == "docs"
Dynamic: license-file

# HiePy

**hiepy** brings the Hierarchical Tucker (HT) format to PyTorch. An HT tensor stores a high-dimensional tensor as
small matrices and 3-way tensors on a binary tree over its modes. For tensors with low hierarchical ranks, storage
and computation grow linearly instead of exponentially with the number of modes.

**Documentation:** <https://beschroe.github.io/HiePy/>

> Status: alpha. The API may still change; see the [changelog](https://github.com/Beschroe/HiePy/blob/main/CHANGELOG.md).

## Features

- **Construction** from dense tensors with a prescribed accuracy, or directly with factories for tensors that do
  not fit into memory.
- **Arithmetic**: sums, scaling, multiplication along a mode, elementwise and inner products — exact, without
  forming dense tensors.
- **Truncation** with a guaranteed error bound `‖x − x̃‖ ≤ atol + rtol·‖x‖`, and orthogonalization.
- **Indexing** like torch with integers and slices.
- **Autograd**: gradients flow through all operations, as in torch.

## Installation

Requires Python 3.12 and PyTorch 2.6 or newer.

```bash
pip install hiepy
```

## Quickstart

```python
import torch
import hiepy

torch.set_default_dtype(torch.float64)

g = torch.linspace(0, 1, 10)
T = torch.sin(sum(torch.meshgrid(*[g] * 5, indexing="ij")))  # 10^5 entries
x = hiepy.to_htt(T, {"rtol": 1e-10})                         # ranks 2, 1 KB

y, _ = (x * x + x).truncate({"rtol": 1e-10})                 # computed in the HT format
print(torch.linalg.norm(y.full() - (T * T + T)) / torch.linalg.norm(T * T + T))  # < 1e-9
```

Next: [Getting started](https://beschroe.github.io/HiePy/getting-started/),
[User Guide](https://beschroe.github.io/HiePy/user-guide/ht-format/),
[API Reference](https://beschroe.github.io/HiePy/api/).

## Reporting bugs

Please report bugs as an [issue on GitHub](https://github.com/Beschroe/HiePy/issues/new/choose), with a small
example that reproduces the problem.

## License

[EUPL-1.2](https://github.com/Beschroe/HiePy/blob/main/LICENSE)
