torch-named-linops
A flexible linear operator abstraction implemented in PyTorch.
uv add torch-named-linops
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 other works. In no particular order:
- einops: named dimensions.
- 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.
Metadata
Release files for torch-named-linops 0.8.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| torch_named_linops-0.8.3.tar.gz | 404.9 kB | With provenance | Details for torch_named_linops-0.8.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| torch_named_linops-0.8.3-py3-none-any.whl | Python 3 | none | any | Details for torch_named_linops-0.8.3-py3-none-any.whl |
Total release size: 605.8 kB
Release files / torch_named_linops-0.8.3.tar.gz
| Download URL | torch_named_linops-0.8.3.tar.gz |
|---|---|
| Size | 404.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9466a49d94b94b225bcd87d51438c36485f5ccbff1f6c594d152cb5e54057198
|
|
BLAKE2b-256 checksum How to use checksums |
ad716e0170db36b92c0981561269515b69dc88be076bda28e927b0215426c7bb
|
| 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 Oct 15, 2026.
Transparency logRelease files / torch_named_linops-0.8.3-py3-none-any.whl
| Download URL | torch_named_linops-0.8.3-py3-none-any.whl |
|---|---|
| Size | 200.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d43c3624140598c9a5581408934d9762738e01801c56107d6d420e005ee3a668
|
|
BLAKE2b-256 checksum How to use checksums |
a0448d621ab26e815784d97d43143bace09727960ad8d30273f5d11990de4d1d
|
| 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 Oct 15, 2026.
Transparency logSecurity for torch-named-linops 0.8.3
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for torch_named_linops-0.8.3.tar.gz
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 Oct 15, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.