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 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 Distribution

thrindex-0.3.1.tar.gz (62.2 kB view details)

Uploaded Source

Built Distributions

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

thrindex-0.3.1-cp314-cp314-macosx_11_0_arm64.whl (454.7 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

thrindex-0.3.1-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.1-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.1.tar.gz.

File metadata

  • Download URL: thrindex-0.3.1.tar.gz
  • Upload date:
  • Size: 62.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for thrindex-0.3.1.tar.gz
Algorithm Hash digest
SHA256 12e45cd1f0065e39020e54e6c61fd2e0d1944c8cf2d8969d61a6c0a92edfd198
MD5 9d8164658bb0f1c24b344b07265f353f
BLAKE2b-256 11ec90cb51b3be883c524c3bfe678ba23dd294898739deb6e57e9eeb5ca62bf0

See more details on using hashes here.

File details

Details for the file thrindex-0.3.1-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thrindex-0.3.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 65df6cb4158f9b760c2a07cb3f1f8c7d41925d3ba7b5656f15f12c9dfbbbc8e0
MD5 0133bfbced34ba4bef1f26b22f6c0360
BLAKE2b-256 12b680332ff051175194e91243999525f66371a0f1da12925bb886df6e4149af

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thrindex-0.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a30fce2a53f00da0c95bedf3fc431bcb24e5fefc21a6e82ddbaa8fc2e5a3d6ce
MD5 211ed76d3b556c7144b0d127fd09980d
BLAKE2b-256 9bde3b167db52473f2a64d6dd4120dc41084f6d07f4ef02341903e82f473daa3

See more details on using hashes here.

Provenance

The following attestation bundles were made for thrindex-0.3.1-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.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thrindex-0.3.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9d18a6db3d9c4684670915bd21400799a4fdca6f5805ae247a6b381371ff9d6f
MD5 108ddcc4dd127e7479c755d38948e189
BLAKE2b-256 2f0e07183f390d42cc57ff7b7ed8bde511466fcf5714d18503812730cc110687

See more details on using hashes here.

Provenance

The following attestation bundles were made for thrindex-0.3.1-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