Skip to main content

tensi

tensi sees your tensors.
Hover any PyTorch tensor and see its shape, with every dimension named.


def forward(self, x):
    B, T, C = x.size()
    q, k, v = self.c_attn(x).split(self.n_embd, dim=2)
    k = k.view(B, T, self.n_head, C // self.n_head).transpose(1, 2)
    #   hover k → Tensor[[b, n_head, t, n_embd // n_head]]

Install

VS Code: install tensi from the Marketplace and open a PyTorch project. It uses the project's own .venv (what uv sync makes; else the Python extension's interpreter), and if tensi isn't there yet it offers to install it with one click: uv add --dev tensi-shapes in a uv project, else into the project's environment. Switching projects or running uv sync restarts it by itself. It runs beside Pylance and only adds shapes; the status bar shows when it is working out a file.

Command line, CI, other editors:

uv add --dev tensi-shapes      # or: pip install tensi-shapes, into the project's environment
uv tool install tensi-shapes   # or once for all projects; it reads torch from each project's .venv
tensi doctor                   # checks Pyrefly, the stubs and the interpreter Pyrefly picks, with one real probe

The package is tensi-shapes on PyPI; the command and the import are tensi. It brings Pyrefly 1.5.0 and its torch shape stubs; your project needs torch installed.

Any editor that speaks LSP can run tensi lsp as a language server for Python files. Python 3.10+, einops included.

Try it

$ tensi peek model.py
tensi peek v0.3.0  model.py  2.0s

  CausalSelfAttention.forward
    56  q, k, v   [b, t, n_embd]
    57  k         [b, n_head, t, n_embd // n_head]
    67  att       [b, n_head, t, t]
    72  y         [b, t, n_embd]
  MLP.forward
    88  x         [b, t, 4 * n_embd]
  GPT.forward
   177  tok_emb   [b, t, n_embd]
   178  pos_emb   [t, n_embd]
   186  logits    [b, t, vocab_size]
  GPT.generate
   321  v, _      [b, int]
   326  idx_next  [b, 1]

  37 tensors, 32 fully named
$ tensi check model.py
tensi check v0.3.0  model.py  2.0s
  ok no shape errors

$ tensi check bad.py
tensi check v0.3.0  bad.py  819ms
  x bad.py:17:9  Argument `Tensor[[b, 7, v]]` is not assignable to parameter `x` with type `Tensor[[b, 7, d]]` in function `Block.forward`
  x bad.py:18:9  `@` is not supported between `Tensor[[b, d]]` and `Tensor[[v, 3]]`

  2 shape errors

tensi check src/ checks every Python file under a folder and exits 1 when it finds a shape error, so it can gate CI.

Contributing

See CONTRIBUTING.md for the development setup, tests and releases.

tensi is built on Pyrefly (MIT) and its torch stubs. The mascot is a small tensor that is very good at looking.

Metadata

Release files for tensi-shapes 0.3.1

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

Source distribution (sdist)

Source distribution for tensi-shapes 0.3.1
File Size Uploaded Provenance Actions
tensi_shapes-0.3.1.tar.gz 91.5 kB With provenance Details for tensi_shapes-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tensi-shapes 0.3.1
File Interpreter ABI Platform Actions
tensi_shapes-0.3.1-py3-none-any.whl Python 3 none any Details for tensi_shapes-0.3.1-py3-none-any.whl

Total release size: 172.4 kB

Release files / tensi_shapes-0.3.1.tar.gz

Download URL tensi_shapes-0.3.1.tar.gz
Size 91.5 kB
Tags Source
SHA-256 checksum
How to use checksums
88784cd1104faf58e269a1e853d57836737ca89c245d5fe6671dfa8cf608d9de
BLAKE2b-256 checksum
How to use checksums
62c85f26c6f0da3ef74268a3a89431d93b8ffb9b177e1c9be9c30d0b45264221
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 20, 2026.

Transparency log

Release files / tensi_shapes-0.3.1-py3-none-any.whl

Download URL tensi_shapes-0.3.1-py3-none-any.whl
Size 80.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ed317bbb02c05ac2ef133209fb48c16d3bd5ced727949db79678b436d0e8251
BLAKE2b-256 checksum
How to use checksums
294503792af45e81a9383096eeabfaac7e0be6ac0a3bf68e447b87107a19761e
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 20, 2026.

Transparency log

Security for tensi-shapes 0.3.1

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 tensi_shapes-0.3.1.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 20, 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.

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