Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

ShapeScript

A typed tensor language that compiles to PyTorch. Axis names and sizes are part of the syntax, and the checker verifies every shape before any code runs. It's einops built into a language: no pattern strings, no dim=-1, no unsqueeze, and no dropping back into Python halfway through an expression.

dim D  = 768
dim H  = 12
dim Dh = D / H

fn causal_attention(x: [b n D], w_qkv: [D 3*D], w_o: [D D]) -> [b n D]:
    q, k, v = x @ w_qkv
        |> split(b n (3 H Dh) -> b H n Dh)

    att = einsum(q, k: b H n Dh, b H m Dh -> b H n m)
        |> scale(1 / sqrt(Dh))
        |> masked_fill(!causal[n m], -inf)
        |> softmax(over=m)

    return einsum(att, v: b H n m, b H m Dh -> b H n Dh)
        |> rearrange(b H n Dh -> b n (H Dh))
        |> matmul(w_o)

Swap two letters in the last einsum, writing b H m n for the attention weights, and PyTorch still runs it, since n and m have the same size. ShapeScript doesn't compile it: error E0408, the pattern calls axis 3 m, but m is axis 4.

This package is a pre-release. It has the compiler (shapescript), the language server (shapescript-lsp), the runtime, import of .ss files from Python and the notebook magic (%%shapescript), with prebuilt binaries for Linux (x86_64, aarch64), macOS (arm64, x86_64) and Windows (x64). It needs PyTorch:

pip install torch
pip install --pre shapescript
shapescript check model.ss
import shapescript
shapescript.install()   # then `import model` loads model.ss

The editor support is the ShapeScript extension for VS Code, on the Visual Studio Marketplace and Open VSX, with the language server inside it.

See the repository for the tour, and the language reference. Licensed under MIT or Apache-2.0, at your option.

Metadata

Release files for shapescript 0.1.0b1

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

Source distribution (sdist)

Source distribution for shapescript 0.1.0b1
File Size Uploaded Provenance Actions
shapescript-0.1.0b1.tar.gz 733.9 kB Without provenance Details for shapescript-0.1.0b1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for shapescript 0.1.0b1
File Actions
shapescript-0.1.0b1-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for shapescript-0.1.0b1-cp39-abi3-win_amd64.whl
shapescript-0.1.0b1-cp39-abi3-manylinux_2_28_x86_64.whl CPython 3.9 abi3 Linux glibc 2.28+ x86-64 Details for shapescript-0.1.0b1-cp39-abi3-manylinux_2_28_x86_64.whl
shapescript-0.1.0b1-cp39-abi3-manylinux_2_28_aarch64.whl CPython 3.9 abi3 Linux glibc 2.28+ ARM64 Details for shapescript-0.1.0b1-cp39-abi3-manylinux_2_28_aarch64.whl
shapescript-0.1.0b1-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for shapescript-0.1.0b1-cp39-abi3-macosx_11_0_arm64.whl
shapescript-0.1.0b1-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details for shapescript-0.1.0b1-cp39-abi3-macosx_10_12_x86_64.whl

Total release size: 42.2 MB

Release files / shapescript-0.1.0b1.tar.gz

Download URL shapescript-0.1.0b1.tar.gz
Size 733.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b2276fc1e8cdef6c87fdff7cf16da971ab8157fb8c67332c1fc6e758e7eebd75
BLAKE2b-256 checksum
How to use checksums
3f56bde334aea841970ca559706c7137d8eb964e4afc7c2b0753a1c3aaff3d55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.12

Release files / shapescript-0.1.0b1-cp39-abi3-win_amd64.whl

Download URL shapescript-0.1.0b1-cp39-abi3-win_amd64.whl
Size 8.1 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
a10acf97645e8de10d812c43f253fccfedd66ac12152482ee7d7df6bc1dfd8b9
BLAKE2b-256 checksum
How to use checksums
2cf1ee0a359cf3899a841ddfe418cc6ae06bdeb07dc140edd43dd5ff4ba4361e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.12

Release files / shapescript-0.1.0b1-cp39-abi3-manylinux_2_28_x86_64.whl

Download URL shapescript-0.1.0b1-cp39-abi3-manylinux_2_28_x86_64.whl
Size 8.1 MB
Tags CPython 3.9 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
2976d981702674b4367a58257e2c0db45c24b21607c5a7629d602eee76963c4f
BLAKE2b-256 checksum
How to use checksums
1f90af645b3d030fee751324ebd40d15f3df25ea11151c97c2cf2766964ebb43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.12

Release files / shapescript-0.1.0b1-cp39-abi3-manylinux_2_28_aarch64.whl

Download URL shapescript-0.1.0b1-cp39-abi3-manylinux_2_28_aarch64.whl
Size 8.5 MB
Tags CPython 3.9 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
d839272b282125316791efe1b1a957dd7b79d63cabbaf982d259d360a89108b2
BLAKE2b-256 checksum
How to use checksums
a34245dc8115694843b7385895170f82d5c78fd9ebd0334887d58ab9ad4f9a92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.12

Release files / shapescript-0.1.0b1-cp39-abi3-macosx_11_0_arm64.whl

Download URL shapescript-0.1.0b1-cp39-abi3-macosx_11_0_arm64.whl
Size 8.2 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1c0cc7e2118ed2fc6b9c6c779d22fa43ef5ab3dc20db57a334ca8b8d961c66e4
BLAKE2b-256 checksum
How to use checksums
dad01fd27c689b6a0df51507ac847361dd79d47077cca05daa05b98bf3117886
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.12

Release files / shapescript-0.1.0b1-cp39-abi3-macosx_10_12_x86_64.whl

Download URL shapescript-0.1.0b1-cp39-abi3-macosx_10_12_x86_64.whl
Size 8.6 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
b0780adaa0555e265379112ae2a4b136734b0fb458e11fedf17a96feaf684c31
BLAKE2b-256 checksum
How to use checksums
2995d79e529f949d1113f1d297b492e6022f12b207494aa7f099b6f15d06d212
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.12

Security for shapescript 0.1.0b1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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