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

$ 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 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.
  1. Includes a functional interface and triton backend for 1D/2D/3D. ↩ ↩2

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)

Source distribution for torch-named-linops 0.7.4
File Size Uploaded
torch_named_linops-0.7.4.tar.gz 350.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for torch-named-linops 0.7.4
File Interpreter ABI Platform
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 log

Release 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

Release history Release notifications | RSS feed

This release

0.7.4 This release

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.5

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.8

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.22

2 release files

0.3.20

2 release files

0.3.19

2 release files

0.3.18

2 release files

0.3.17

2 release files

0.3.16

2 release files

0.3.15

2 release files

0.3.14

2 release files

0.3.13

2 release files

0.3.12

2 release files

0.3.10

2 release files

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