Metadata-Version: 2.4
Name: mbirtorch
Version: 0.0.1
Summary: High-performance tomographic reconstruction using PyTorch
Author-email: MBIRTORCH development team <buzzard@purdue.edu>
License: BSD 3-Clause License
        
        Copyright (c) 2024, Charles A. Bouman and Gregery T. Buzzard
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
Project-URL: source, https://github.com/cabouman/mbirtorch
Keywords: tomography,tomographic reconstruction,computed tomography
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: torch>=2.13
Requires-Dist: numpy
Requires-Dist: matplotlib
Requires-Dist: h5py
Requires-Dist: scipy
Requires-Dist: tifffile
Requires-Dist: tqdm
Requires-Dist: pywavelets
Requires-Dist: osqp
Requires-Dist: opencv-python
Requires-Dist: olefile
Requires-Dist: gdown
Requires-Dist: scikit-learn
Requires-Dist: psutil
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: pytest-xdist; extra == "test"
Provides-Extra: docs
Requires-Dist: sphinx; extra == "docs"
Requires-Dist: sphinxcontrib-bibtex; extra == "docs"
Requires-Dist: sphinx-book-theme>=1.0.1; extra == "docs"
Requires-Dist: sphinx-design; extra == "docs"
Requires-Dist: sphinx-copybutton; extra == "docs"
Dynamic: license-file

# mbirtorch

[![CI](https://github.com/cabouman/mbirtorch/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/cabouman/mbirtorch/actions/workflows/ci.yml)
[![Documentation Status](https://readthedocs.org/projects/mbirtorch/badge/?version=latest)](https://mbirtorch.readthedocs.io/en/latest/)

A PyTorch port of [mbirjax](https://github.com/cabouman/mbirjax): high-performance
tomographic reconstruction with multi-GPU support.

This repo is the home for the port evaluated in
`mbirjax_plans/plans/torch_port/port_plan.md` (checked out parallel to this
repo).  The plan defines the motivation, the parity gates against mbirjax,
the incremental phase plan, and a progress record; its findings pages and the
supporting scripts live alongside it under `mbirjax_plans/plans/`.

## Setup

Create the conda environment and install the package in editable mode:

```bash
conda env create -f environment.yml
conda activate mbirtorch
pip install -e ".[test]"
```

## Tests

```bash
dev_scripts/run_tests.sh
```

## Caches

mbirtorch keeps one on-disk cache: compiled `torch.compile` artifacts, under
`~/.mbirtorch/torch_cache`.  It exists to make cold starts fast -- with it, a
fresh process reuses prior compilations instead of recompiling (roughly 14 s
down to 2 s for a first small reconstruction).  It grows with the number of
distinct compiled shapes and typically stays in the tens of megabytes; it is
never cleaned automatically.  To remove it:

```python
import mbirtorch
mbirtorch.clear_cache()   # deletes ~/.mbirtorch entirely (recreated empty)
```

The location can be redirected by setting the `TORCHINDUCTOR_CACHE_DIR`
environment variable before the first compile (e.g. to node-local or scratch
storage on a cluster, where home quotas are tight); `clear_cache()` does not
touch a redirected location.

Everything else the package caches is in-memory only and is freed with the
objects that hold it (e.g. the per-model pixel-index cache); nothing besides
`~/.mbirtorch` is written to disk.
