SPEAR is a collection of kernels for AI model architectures developed by Radical Numerics.
Installation
You may use PyPI to install SPEAR:
pip install spear-python
Note that it will take few minutes to compile kernels for your specific GPU architecture.
You may also install it locally using the following method to install the package in development mode:
git clone https://github.com/radicalnumerics/spear.git && cd spear # clone the repository
uv venv && source .venv/bin/activate # virtual env with uv (recommended)
uv pip install -e '.[dev]' # install in development mode
Caching
We use ccache by default. To use it and enable faster compilation (see explanation on the vLLM docs), run:
CCACHE_NOHASHDIR="true" uv pip install --no-build-isolation -e '.[dev]'
Quick Start
import torch
from spear.nn.phalanx import Phalanx
device = "cuda:0" if torch.cuda.is_available() else "cpu"
dtype = torch.bfloat16
dim = 512 # Must be divisible by 16 (head_dim is fixed at 16)
length = 128
batch_size = 1024
layer = Phalanx(dim=dim, length=length, dtype=dtype).to(device)
x = torch.randn(batch_size, length, dim, dtype=dtype, device=device)
y = layer(x)
print(f"Input: {x.shape} -> Output: {y.shape}")
Development
We include pre-commit hooks for linting and formatting (Python, C++, CUDA). To install:
uv run pre-commit install
To run (note they will be run automatically on commit, so not necessary to run manually):
uv run pre-commit run --all-files
To run tests
uv run pytest
Structure
csrc/ # kernels: CUDA/C++ or other DSLs
spear/
├─ ops/ # low-level wrappers per op family
│ └─ <op>/
└─ nn/ # layers built from ops (parametrized)
└─ <layer>/
Target Architectures
Currently supported hardware includes compute capabilities 9.0 (Hopper) and 10.0 (Blackwell).
| Kernel Name | (NVIDIA) sm9.0 | (NVIDIA) sm10.0 | (NVIDIA) sm10.3 |
|---|---|---|---|
swr.btp.fwd.bf16.bdl.hd16-bl16.sm90 |
✔︎ | ~ | ⛔ |
swr.btp.bwd.bf16.bdl.hd16-bl16.sm90 |
✔︎ | ~ | ⛔ |
- ✔︎: optimized
- ~: working but not fully optimized
- ⛔: not available
Metadata
Release files for spear-python 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| spear_python-0.1.1.tar.gz | 44.4 kB | Without provenance | Details for spear_python-0.1.1.tar.gz |
Release files / spear_python-0.1.1.tar.gz
| Download URL | spear_python-0.1.1.tar.gz |
|---|---|
| Size | 44.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ae299d0ffbb97ea9747124c9d0bdd272e88ef7f2147d0aac0bcb97b90c7dba7e
|
|
BLAKE2b-256 checksum How to use checksums |
0df712e5e1fc16d9bcd92c3b22d9fb227363489fdb27135cecd8dc7ec3475d4e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.13
|
Security for spear-python 0.1.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.
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.