Skip to main content

The open compiler for spiking neuromorphic compute.

Reason this release was yanked:

incomplete release - use newest

Project description

Thrindex — The open compiler for spiking neuromorphic compute

The open compiler for spiking neuromorphic compute.
Author spiking neural networks in Python. Compile them to neuromorphic hardware.


Website · Docs · Discussions



CI PyPI Downloads License: Apache 2.0 Python 3.11+


What is it?

thrindex is the full-stack toolkit for spiking neural networks (SNNs) — from model authoring to deployment on neuromorphic hardware.

It gives you a PyTorch-native authoring API for building and training SNNs with surrogate gradients, a deterministic Rust simulation engine for fast, reproducible model validation, and a compiler + runtime that targets real neuromorphic chips — all through one unified SDK.

import thrindex as thx
import thrindex.snn as snn

model = snn.Sequential(
    snn.Dense(784, 1000),
    snn.LIF(threshold=1.0, tau_mem=5.0),
    snn.Dense(1000, 10),
    snn.LIF(threshold=1.0, tau_mem=5.0),
)

# train with surrogate gradients — standard PyTorch loop
loss = thx.train.rate_loss(model(encoded_input), labels)
loss.backward()

Install

pip install thrindex

Requires Python 3.11+ and PyTorch 2.0+.


Quickstart

import torch
import thrindex as thx
import thrindex.snn as snn
from thrindex.encoders import rate
from thrindex.train import rate_loss

# Build a two-layer LIF network
model = snn.Sequential(
    snn.Dense(784, 1000),
    snn.LIF(threshold=1.0, tau_mem=5.0, reset="subtract"),
    snn.Dense(1000, 10),
    snn.LIF(threshold=1.0, tau_mem=5.0, reset="subtract"),
)

# Rate-encode your input (explicit generator — no global RNG state)
gen = torch.Generator()
gen.manual_seed(42)
spikes = rate(x_batch, T=25, generator=gen)   # [T, batch, 784]

# Forward + loss
spk_out = model(spikes)                        # [T, batch, 10]
loss = rate_loss(spk_out, labels)

# Standard PyTorch backward
loss.backward()
optimizer.step()

Key features

Feature Detail
SNN layers LIF, Sequential, Dense, Conv2d — all nn.Module subclasses
Surrogate gradients Fast-sigmoid, analytically verified backward pass
Spike encoders Rate (Bernoulli), latency (time-to-first-spike), delta (change coding)
Deterministic numerics Parameterizable fixed-point Q<INT, FRAC> types; round-half-even; bit-identical across platforms
Typed errors Stable E#### error codes — every error tells you what happened, why, and how to fix it
Hardware target Compile .thx artifacts and deploy to neuromorphic silicon (M2+)

LIF neuron

The LIF module follows the exact per-timestep update order:

(i)   mem_t    = α · mem_prev + x_t          # leak + integrate
(ii)  spk_t    = H(mem_t − threshold)         # fire  (Heaviside; surrogate in backward)
(iii) mem_out  = mem_t − spk_t · threshold   # reset (subtract mode)

where α = exp(−dt / τ_mem) (exact exponential discretization, dt = 1 ms).

Canonical parameters: threshold, tau_mem, tau_syn, reset, delay.


Encoders

from thrindex.encoders import rate, latency, delta

# Rate: Bernoulli-sample — always pass an explicit generator
gen = torch.Generator(); gen.manual_seed(0)
spikes = rate(x, T=25, generator=gen)          # [T, *x.shape]

# Latency: higher value spikes earlier — deterministic, no RNG
spikes = latency(x, T=25)

# Delta: fires on change above threshold — deterministic, no RNG
spikes = delta(x_sequence, T=25, threshold=0.1)

Stack

python/thrindex/       Python SDK — strictly typed, zero logic
crates/thrindex-py/    PyO3 bridge (maturin)
crates/thrindex-sim/   Behavioral simulator — deterministic, seeded, CPU-parallel  (M2)
crates/thrindex-compiler/  Compiler: capture → validate → quantize              (M3)
crates/thrindex-numerics/  Fixed-point core — zero dependencies, consumed bit-for-bit

Rust engines are MIT/Apache-2.0. The Python SDK wraps them with no logic of its own.


Status

M5 complete — templates, public docs, CI snippet tests, conformance suite, and energy benchmark harness are all shipped. M6 (first silicon bring-up) is next.

Issues and discussions are open.
See SECURITY.md for responsible disclosure.


License

Apache 2.0 — see 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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

thrindex-0.3.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (563.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

thrindex-0.3.2-cp313-cp313-macosx_11_0_arm64.whl (497.3 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

thrindex-0.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (564.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

thrindex-0.3.2-cp312-cp312-macosx_11_0_arm64.whl (497.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

thrindex-0.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (566.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

thrindex-0.3.2-cp311-cp311-macosx_11_0_arm64.whl (502.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file thrindex-0.3.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thrindex-0.3.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1445cdfdf3b2cf548f28d1500a98c1e05c6f9f3861f70e915094de9337a4c459
MD5 9c77477715881a9abb6dc50f1e512fac
BLAKE2b-256 10b9177081144143ae9dfbb9de91efc2f15065af53fff30a924015c0f9c70cc8

See more details on using hashes here.

Provenance

The following attestation bundles were made for thrindex-0.3.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on thrindex/thrindex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file thrindex-0.3.2-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thrindex-0.3.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2ddf1e203978085c668d8cd351b4c2b6a8e20a1d5efaba358ada8b08275225d8
MD5 31ace38220b2b7962e183821b07c27db
BLAKE2b-256 d83d90c2d974965a9a8a35c472939e758f878fdaa23dd455fd036c7837c89bef

See more details on using hashes here.

Provenance

The following attestation bundles were made for thrindex-0.3.2-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: release.yml on thrindex/thrindex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file thrindex-0.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thrindex-0.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 674f9de3efc51cd5f43d6a3d06b323dafbd969477def3719816aff2885eda376
MD5 afb6683791a7ca157ea1ed6c8fe4939d
BLAKE2b-256 b4a3b0ea1f1b3b01cc7305d301d783df0d4c736018b1b5acfada5114c08b0fb5

See more details on using hashes here.

Provenance

The following attestation bundles were made for thrindex-0.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on thrindex/thrindex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file thrindex-0.3.2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thrindex-0.3.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e8e292d1a0a00078d42573574566a9d2e07635743b36b8f1e0f2516445c9c7e5
MD5 707a3df30d36e36af7044402c0a96c85
BLAKE2b-256 6ec732d7edb88ac835996f42a0b539fd3c64ec72a8770e01853f0fa7438fe1ff

See more details on using hashes here.

Provenance

The following attestation bundles were made for thrindex-0.3.2-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on thrindex/thrindex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file thrindex-0.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thrindex-0.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3f2471e5bcf96ee0d19d33ba48a31992060143cde7d4c5754126541d68d339a7
MD5 9a3175f18febb73f4df98b86598ace62
BLAKE2b-256 ff80c06bfec4e026bfb561c4ff7af12d18efb375ff4147ec0ce69c216c3ec5f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for thrindex-0.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on thrindex/thrindex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file thrindex-0.3.2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thrindex-0.3.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 331c8978eb0f6bbf9c6fcfb3cf3080ac74bd10afb5601db421dd5315bacb8426
MD5 bd8b7cdf4c4af8fe477798476e2724c1
BLAKE2b-256 b4938173b39fb59eb58c8878465e2d7654aee75da46551a253bcfe3b657ceaa3

See more details on using hashes here.

Provenance

The following attestation bundles were made for thrindex-0.3.2-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: release.yml on thrindex/thrindex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page