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. It follows each project's interpreter (the Python extension's choice, else .venv), so switching projects or running uv sync needs no setup. If tensi is missing it offers uv add --dev tensi-shapes for the project, or uv tool install tensi-shapes once for all projects. It runs beside Pylance and only adds shapes.

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.12+; rearrange and friends are shape-aware on Python 3.12+ (Pyrefly's einops stubs need it).

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

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.0
File Size Uploaded Provenance Actions
tensi_shapes-0.3.0.tar.gz 86.5 kB With provenance Details for tensi_shapes-0.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 160.7 kB

Release files / tensi_shapes-0.3.0.tar.gz

Download URL tensi_shapes-0.3.0.tar.gz
Size 86.5 kB
Tags Source
SHA-256 checksum
How to use checksums
3dd5bf654624c203e4d4b713bf7d17639ef4bb3b0ef85fe89d1ac3b9820a9495
BLAKE2b-256 checksum
How to use checksums
e18be3071508ca6971a29140a63b3e8f847a6c722496424dc1fd1f4bc94782d9
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.0-py3-none-any.whl

Download URL tensi_shapes-0.3.0-py3-none-any.whl
Size 74.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2a70336aa8bd4080ec1c9e49ad8f471c0f4fb466e243da97732bd197cc46f96b
BLAKE2b-256 checksum
How to use checksums
11d2f6c0d331b1412042a572d00fc6caae343b8f106faf103ba0b501380d2a63
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.0

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