Skip to main content

torch-named-linops

GitHub Actions Workflow Status Codecov PyPI - Version GitHub License

A flexible linear operator abstraction implemented in PyTorch.

Documentation

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:
    • Dense
    • Diagonal
    • FFT
    • ArrayToBlocks1 (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_bessel and first-order spline kernels.
  • .H and .N properties for adjoint $A^H$ and normal $A^HA$ linop creation.
  • Chain and Add for 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.
  1. Includes a functional interface and triton backend for 1D/2D/3D. ↩ ↩2

Metadata

Release files for torch-named-linops 0.8.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for torch-named-linops 0.8.5
File Size Uploaded Provenance Actions
torch_named_linops-0.8.5.tar.gz 533.9 kB With provenance Details for torch_named_linops-0.8.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for torch-named-linops 0.8.5
File Interpreter ABI Platform Actions
torch_named_linops-0.8.5-py3-none-any.whl Python 3 none any Details for torch_named_linops-0.8.5-py3-none-any.whl

Total release size: 738.2 kB

Release files / torch_named_linops-0.8.5.tar.gz

Download URL torch_named_linops-0.8.5.tar.gz
Size 533.9 kB
Tags Source
SHA-256 checksum
How to use checksums
3ec8176fd51b74b2fbf3be736c1875594dc1abafbf2cc60525cefe5f8c48fd9d
BLAKE2b-256 checksum
How to use checksums
ed3b81062e1e462270ee52799861a4cb8df48ccfe1964758ff30650656ea8b78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 10, 2026.

Transparency log

Release files / torch_named_linops-0.8.5-py3-none-any.whl

Download URL torch_named_linops-0.8.5-py3-none-any.whl
Size 204.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
df53cf1901f7a362e3b4a4dfbda61ade277b29aded91342f6baae4deb667fb90
BLAKE2b-256 checksum
How to use checksums
5ed7f3a5f68d8f07a12b19779963bdf941cce54c2886279561596a2e0c1127a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 10, 2026.

Transparency log

Security for torch-named-linops 0.8.5

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.

Select from 2 files

Attestation for torch_named_linops-0.8.5.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 Nov 10, 2026.

Transparency log

A 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.

Release history Release notifications | RSS feed

This release

0.8.5 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page