torch-named-linops
A flexible linear operator abstraction implemented in PyTorch.
$ pip install torch-named-linops
Quick Example
import torch
from torchlinops import Dense, Diagonal, Dim
# Create operators with named dimensions
W = torch.randn(3, 7)
A = Dense(W, Dim("MN"), ishape=Dim("N"), oshape=Dim("M"))
# Apply, take adjoint, compose
x = torch.randn(7)
y = A(x) # Forward: y = W @ x
z = A.H(y) # Adjoint: z = W^H @ y
w = A.N(x) # Normal: w = W^H @ W @ x
# Compose operators with @
d = torch.randn(3)
B = Diagonal(d, ioshape=Dim("M"))
C = B @ A # Chain: C(x) = diag(d) @ W @ x
Or use the simplified API - no dimension names needed:
import torch
from torchlinops import Dense
# Simple usage - auto-infers shapes
W = torch.randn(5, 3)
A = Dense(W)
x = torch.randn(3)
y = A(x) # Equivalent to W @ x
# Batched usage
W_batch = torch.randn(2, 5, 3) # (batch, M, N)
A_batch = Dense(W_batch)
x_batch = torch.randn(2, 3) # (batch, N)
y_batch = A_batch(x_batch) # Batched matmul
See the Getting Started guide for a full walkthrough.
Selected Feature List
- A dedicated abstraction for naming linear operator dimensions.
- A set of core linops, including:
DenseDiagonalFFTArrayToBlocks1 (similar to PyTorch's unfold but in 1D/2D/3D/arbitrary dimensions)- Useful for local patch extraction
Interpolate1 (similar to SigPy's interpolate/gridding)- Comes with
kaiser_besseland first-ordersplinekernels.
- Comes with
.Hand.Nproperties for adjoint $A^H$ and normal $A^HA$ linop creation.ChainandAddfor composing linops together.- Splitting a single linop across multiple GPUs.
- Full support for complex numbers. Adjoint takes the conjugate transpose.
- Full support for
autograd-based automatic differentiation.
Documentation
The documentation is built using Zensical with tutorials authored as Marimo notebooks.
Building Documentation Locally
Install just (a command runner):
# Install with uv
uv tool install just
# Or with other package managers
# Homebrew: brew install just
# Cargo: cargo install just
Build the documentation:
# Build tutorials and documentation
just docs
# Or serve locally with auto-reload
just dev
Available commands:
| Command | Description |
|---|---|
just tutorials |
Build tutorials from marimo notebooks |
just docs |
Build full documentation (includes tutorials) |
just serve |
Serve documentation locally |
just dev |
Build and serve documentation |
Editing Tutorials
Tutorials are marimo notebooks in tutorials/*.py. To edit:
# Edit a tutorial interactively
uv run marimo edit tutorials/basics.py
# Rebuild markdown after edits
just tutorials
Other Packages
This package was heavily inspired by a few other influential packages. In no particular order:
- einops: named dimensions/naming things in general.
- sigpy: the linop abstraction and the idea of having dedicated adjoint and normal properties. Also inspired the NUFFT, Interpolate, and ArrayToBlocks/BlocksToArray operators.
- torch_linops: another linop abstraction. Geared more towards optimization.
Release files for torch-named-linops 0.7.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| torch_named_linops-0.7.4.tar.gz | 350.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| torch_named_linops-0.7.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 538.0 kB
Release files / torch_named_linops-0.7.4.tar.gz
| Download URL | torch_named_linops-0.7.4.tar.gz |
|---|---|
| Size | 350.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
71f8d87e127f08f56c64c7561623475f2d6baa399d6ccc27fcf8d76cb960bec0
|
|
BLAKE2b-256 checksum How to use checksums |
b43de790828d357964414d53c944b8e6be8e0a1d3550bcf4159f6ed0101f1122
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 7, 2026.
Transparency logRelease files / torch_named_linops-0.7.4-py3-none-any.whl
| Download URL | torch_named_linops-0.7.4-py3-none-any.whl |
|---|---|
| Size | 187.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9ed365ebf348474844d95efda4ccaded644c1ec92ad12de282646096e8ed7f3c
|
|
BLAKE2b-256 checksum How to use checksums |
37b3d86918028a4ca85a9cf0fbb7f1e278fbc976ee6d7a1d6b1139858d57bc13
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 7, 2026.
Transparency log