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

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.2
File Size Uploaded Provenance Actions
torch_named_linops-0.8.2.tar.gz 400.8 kB With provenance Details for torch_named_linops-0.8.2.tar.gz

Built distribution (wheel)

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

Total release size: 599.8 kB

Release files / torch_named_linops-0.8.2.tar.gz

Download URL torch_named_linops-0.8.2.tar.gz
Size 400.8 kB
Tags Source
SHA-256 checksum
How to use checksums
02092b086edcb9744a3f6e319c8862e5055db73b09faf8f310d1feefa017b4fb
BLAKE2b-256 checksum
How to use checksums
037697fcc04fc0fbdb6c6bef2b4e83a7fb963424413da2e27eed48ed82749a18
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 12, 2026.

Transparency log

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

Download URL torch_named_linops-0.8.2-py3-none-any.whl
Size 199.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9d667e0babf2d46c0a94896f8dabc91a24e012dcaf92da096c21f81be7de5ce2
BLAKE2b-256 checksum
How to use checksums
f2b327d66ffa8bfbb25aa38a619b8a128f9a0367fd8ab8629edb54b70b420bf0
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 12, 2026.

Transparency log

Security for torch-named-linops 0.8.2

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.2.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 12, 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.2 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