Triton-powered framework for training and deploying Spiking Transformers.
Project description
Tether
Tether is a Triton-powered framework for training and deploying Spiking Transformers and deep Spiking Neural Networks (SNNs).
We’ve solved the non-differentiability of discrete spikes by implementing high-performance Triton kernels with modular Surrogate Gradients.
Key Features
- High-Performance Neurons:
- LIF (Leaky Integrate-and-Fire): Standard spiking neuron with fused Triton kernels.
- ALIF (Adaptive LIF): Neurons with adaptive thresholds for better temporal dynamics.
- PLIF (Parametric LIF): Neurons with learnable, per-channel decay and threshold parameters.
- Modular Surrogate Gradients: Choose from
Arctan,Sigmoid, orFastSigmoidto train your SNNs effectively. - Linear Spike-Driven Attention: Eliminates the $O(N^2)$ Softmax bottleneck, allowing for massive context windows with significantly lower energy per inference.
- Data Utilities:
SpikingDatasetWrapperand encoding functions (rate_encoding,latency_encoding) to convert static datasets to spike trains. - Triton-Powered: Leverages OpenAI's Triton language for custom CUDA kernels, enabling massive speedups (60x+) over vanilla PyTorch.
Installation
This project is managed with uv.
uv sync
Or install dependencies manually:
pip install torch triton numpy
Usage
Using PLIF with Sigmoid Surrogate
import torch
from tether import PLIF, Sigmoid
# Create a Parametric LIF layer with Sigmoid surrogate
# Decay and threshold are learnable vectors per neuron
layer = PLIF(
n_neurons=128,
init_decay=0.9,
surrogate=Sigmoid(alpha=4.0)
).cuda()
# Input sequence: (Time, Batch, Neurons)
x = torch.randn(32, 16, 128).cuda()
spikes = layer(x)
Training a Spiking Language Model
The train_stories.py script demonstrates training a Spiking-LLM on the TinyShakespeare dataset.
python train_stories.py
Data Encoding
from tether.data import SpikingDatasetWrapper, rate_encoding
from torchvision.datasets import MNIST
# Wrap MNIST to output spike trains
spiking_mnist = SpikingDatasetWrapper(
MNIST(root="./data", download=True, train=True),
encode_fn=lambda x: rate_encoding(x, n_steps=10)
)
Architecture
tether.kernels: Custom Triton kernels for LIF, ALIF, and PLIF.tether.functional: PyTorch autograd functions wrapping the Triton kernels.tether.nn: Neural network modules includingLIF,ALIF,PLIF,SpikingSelfAttention.tether.data: Utilities for spike encoding and dataset wrapping.
License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tetherpy-0.2.0.tar.gz.
File metadata
- Download URL: tetherpy-0.2.0.tar.gz
- Upload date:
- Size: 37.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af1e1b797b5100a19b4610bd75f1929bc1afa62be1eb12329e22615643acf8f1
|
|
| MD5 |
9d43f719b0c88f82738258bee573922f
|
|
| BLAKE2b-256 |
80044e72ef6f5b746cd80381408a0fb52639f13aa0332c23487a700c78f32eea
|
Provenance
The following attestation bundles were made for tetherpy-0.2.0.tar.gz:
Publisher:
release.yml on Khushiyant/tether
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tetherpy-0.2.0.tar.gz -
Subject digest:
af1e1b797b5100a19b4610bd75f1929bc1afa62be1eb12329e22615643acf8f1 - Sigstore transparency entry: 781179040
- Sigstore integration time:
-
Permalink:
Khushiyant/tether@669912ff1a6b8d8dbe66621251ebc357b5086a74 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Khushiyant
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@669912ff1a6b8d8dbe66621251ebc357b5086a74 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tetherpy-0.2.0-py3-none-any.whl.
File metadata
- Download URL: tetherpy-0.2.0-py3-none-any.whl
- Upload date:
- Size: 31.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa9cec81de162abb9fc1d927675e1a8bb2816549e1367b0e29b62c9194bedb5b
|
|
| MD5 |
cb0eee66734f5457dfb1a5e07d7d15b8
|
|
| BLAKE2b-256 |
d9116d26e13336a85ca9c862c7a95429e0d334870348449b383a7239e7304504
|
Provenance
The following attestation bundles were made for tetherpy-0.2.0-py3-none-any.whl:
Publisher:
release.yml on Khushiyant/tether
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tetherpy-0.2.0-py3-none-any.whl -
Subject digest:
aa9cec81de162abb9fc1d927675e1a8bb2816549e1367b0e29b62c9194bedb5b - Sigstore transparency entry: 781179041
- Sigstore integration time:
-
Permalink:
Khushiyant/tether@669912ff1a6b8d8dbe66621251ebc357b5086a74 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Khushiyant
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@669912ff1a6b8d8dbe66621251ebc357b5086a74 -
Trigger Event:
push
-
Statement type: