Skip to main content

The open compiler for spiking neuromorphic compute.

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 Distribution

thrindex-0.3.4.tar.gz (62.8 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.4-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (564.5 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

thrindex-0.3.4-cp314-cp314-macosx_11_0_arm64.whl (498.6 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

thrindex-0.3.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (564.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

thrindex-0.3.4-cp313-cp313-macosx_11_0_arm64.whl (498.1 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

thrindex-0.3.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (564.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

thrindex-0.3.4-cp312-cp312-macosx_11_0_arm64.whl (497.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

thrindex-0.3.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (567.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

thrindex-0.3.4-cp311-cp311-macosx_11_0_arm64.whl (502.8 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file thrindex-0.3.4.tar.gz.

File metadata

  • Download URL: thrindex-0.3.4.tar.gz
  • Upload date:
  • Size: 62.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for thrindex-0.3.4.tar.gz
Algorithm Hash digest
SHA256 c4bae2e817d4383ab34b4a972735297e235e3e5d49284893b436371b4c473c3c
MD5 23593e2ebc2501afe3e80323e7cea4ed
BLAKE2b-256 0bd072580c5774d4da3bab8449c51ee7a1fc4b2a1cabbfc02c9af583d311ba92

See more details on using hashes here.

Provenance

The following attestation bundles were made for thrindex-0.3.4.tar.gz:

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.4-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thrindex-0.3.4-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e99161acd57d69f27024985bbad8f82f142712a17f9d439f8d0bf3e81c0c9f47
MD5 fa17916d73b6130468aad07875027020
BLAKE2b-256 50761c5c2d05c92117b89c67e8c48ebb70461796f1823cb42ca6c69b203b0285

See more details on using hashes here.

Provenance

The following attestation bundles were made for thrindex-0.3.4-cp314-cp314-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.4-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thrindex-0.3.4-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 18055b8b32baa1de58bf7affcd5c00704ffeadc7a058b86b39498e52f05e807b
MD5 085b0e99d12fa9f97f4f15182c73c4a5
BLAKE2b-256 36b236a4406c81dc73e701b01fde4e6da47b2e3aa33252aeb266fab35438ccbe

See more details on using hashes here.

Provenance

The following attestation bundles were made for thrindex-0.3.4-cp314-cp314-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.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thrindex-0.3.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a081e20692d42ef0c9c41b644461a8777f84360fe98d85f4f399b9bba4f36873
MD5 8e136e364db2326882f27932ef4a8c6a
BLAKE2b-256 a19556593de3b8242e5f442eafeca79c09aec91272b3f4d300d41461b300a33b

See more details on using hashes here.

Provenance

The following attestation bundles were made for thrindex-0.3.4-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.4-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thrindex-0.3.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 02e6f107bed611ed669be0c98f808c7e40020bfa919c8833de7989a7d75deae1
MD5 c8822af7803fb2b331bdf712c40faea9
BLAKE2b-256 7d32636d9e7daef88cd5f88868b910235f3d0ea081e144c8ad8d25096fb5ba97

See more details on using hashes here.

Provenance

The following attestation bundles were made for thrindex-0.3.4-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.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thrindex-0.3.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 44ece207cdfe221242c119aba25881f0fbec179d3a80ea3ccdf94685730b93fe
MD5 109f7cdd4e1530d9fbdf875b608f5049
BLAKE2b-256 e7901f47b478479e534a11cfd4e3d6429f7dcb1aee9e28b5a91397f2e08d8734

See more details on using hashes here.

Provenance

The following attestation bundles were made for thrindex-0.3.4-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.4-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thrindex-0.3.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e52f71fede69f4fee30a74f4ba3dc544b4802b4e91bea1b96309a58a64654854
MD5 31081d76e9987cef8c1f8500e8df4e3c
BLAKE2b-256 2f3830e83f6d1562cee3f7d93ebba91b3a7ab461c7f72e4b9ea8a2d5371d19ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for thrindex-0.3.4-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.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thrindex-0.3.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cfed032495f9cc097a18896c6091502035d04e4b344ce98adc99fd0871a0e084
MD5 09c03625e7e03b129ef00b58fe474659
BLAKE2b-256 85809345ae0a5df9de39a48edd21e003ebdeb1d21efe1d8de1e197dfff5e52da

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for thrindex-0.3.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ad19bd98428000ce790a548c6cb53c4d8a699c128b0700b5fb7f60c9bc5ecf00
MD5 2ce0a4be294e0577398c4cf6c3852e36
BLAKE2b-256 a78e7ce5cf4cf61ae953ae0445a4d9d2f52afa151ec0e08b4a83517f683f7353

See more details on using hashes here.

Provenance

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