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 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, with the language server inside it: code --install-extension shapescript.shapescript --pre-release. Other editors can run shapescript-lsp, which this package puts on the environment's PATH.

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.1b1

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.1b1
File Size Uploaded Provenance Actions
shapescript-0.1.1b1.tar.gz 734.2 kB Without provenance Details for shapescript-0.1.1b1.tar.gz

Built distributions (wheels)

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

Total release size: 42.2 MB

Release files / shapescript-0.1.1b1.tar.gz

Download URL shapescript-0.1.1b1.tar.gz
Size 734.2 kB
Tags Source
SHA-256 checksum
How to use checksums
3731068a20b1334b61fdf6115498c902d740c9b4af066735e2107dd9a4e8f34f
BLAKE2b-256 checksum
How to use checksums
9afaf1eec3923be59f6b512e080240ce9fff856d5566c896cc337f8dd8212aee
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.1b1-cp39-abi3-win_amd64.whl

Download URL shapescript-0.1.1b1-cp39-abi3-win_amd64.whl
Size 8.1 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
4c9a4972a21494b725af9dc9186f31656962de206f6b797c49ca2d5d2169b9d8
BLAKE2b-256 checksum
How to use checksums
068f4d4fbf4a16d2ddec8e3a8039814d03f16a510726be4816d51b7982f09391
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.1b1-cp39-abi3-manylinux_2_28_x86_64.whl

Download URL shapescript-0.1.1b1-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
607c84a64717c1cd767fda37d089bc55435467e650bad43c128c93f01eed909d
BLAKE2b-256 checksum
How to use checksums
677e6de564f8238b403e6cee1f6b89c328e6f5f782955206b182fbe5b4d3f754
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.1b1-cp39-abi3-manylinux_2_28_aarch64.whl

Download URL shapescript-0.1.1b1-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
a030a2f0b27dbdc46a3b20512495487f99a1aa1c46f0597e360bfb6c07cfc18f
BLAKE2b-256 checksum
How to use checksums
5c1ce46f1a63979bd5ebc3168bc573d258e0e25b38bffe65650903277fa2f74c
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.1b1-cp39-abi3-macosx_11_0_arm64.whl

Download URL shapescript-0.1.1b1-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
7bdbded73ebe9b8d1f728ce451db7e51b33be9447956c51d24fe9f5349bce812
BLAKE2b-256 checksum
How to use checksums
dd660bf2854c82187ec5555a69bf1f3086bbb7aabd87c8ebdd56531695afc849
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.1b1-cp39-abi3-macosx_10_12_x86_64.whl

Download URL shapescript-0.1.1b1-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
0c10dab487a16a65b481bbcdda3abc49cde538a9fb8166704bbe631cee81c241
BLAKE2b-256 checksum
How to use checksums
3a119a94e8732c079a133d9db1af33e5ead1202640767e006046de258e089d8d
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.1b1

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