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.3.tar.gz (62.3 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.3-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (564.2 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

thrindex-0.3.3-cp314-cp314-macosx_11_0_arm64.whl (498.4 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

thrindex-0.3.3-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.3-cp313-cp313-macosx_11_0_arm64.whl (497.3 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

thrindex-0.3.3-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.3-cp312-cp312-macosx_11_0_arm64.whl (497.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

thrindex-0.3.3-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.3-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.3.tar.gz.

File metadata

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

File hashes

Hashes for thrindex-0.3.3.tar.gz
Algorithm Hash digest
SHA256 a503407ce9c94763fe224317e6f884f6aac1ea37c67635a8d23db2dde7dc967a
MD5 514169872393dab9210be762e9d056bd
BLAKE2b-256 9681724a02eb934004bdbacf0b8596c490a4b552192669138d280100dc89a881

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for thrindex-0.3.3-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 68a0157ea14b2982e099ab111c544ded464bebf8f080fb3f084782506f1cbe33
MD5 9f57f26e250226d78b4957a04dd7d124
BLAKE2b-256 18a9c11764b2db801e6d7a30dcb595410d8e694e27635fd5ae1771f8fb394a21

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for thrindex-0.3.3-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 174bac75df54df542d6ebaa9796d2bd95e960e5ffe71dad29c3a79ee8cc87a03
MD5 e029d1733d42cde1633b8554b38204e6
BLAKE2b-256 d5b2187604e022ffce3a30b67faf81352c02a359539651d6159902f962aaf8e3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for thrindex-0.3.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c35072bfe5ef552886b523265645d82706a20eb603b66a9633ff213c0075f1c1
MD5 a835801d9a74f3b01c5eb28f064f2c27
BLAKE2b-256 db4cf0dce35d0090f04bce76f663bd30e797dd51bc21b15f8e2b28db9203e030

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for thrindex-0.3.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 eb59bdc696a728e079239c859806b5b757188d07b2bee4e5db2d68af9c69d1bb
MD5 79fccb87e5667f03ce738034f296e6eb
BLAKE2b-256 a7e7bbb770eb7debd644af391f19c7f4aef64639e53ca7999e8469afa0122cce

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for thrindex-0.3.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c38930025df9244e2001481bf27dd2d6ec6c8ef7c5548fc244461187d4333719
MD5 5752fa3f47e3bf503513229394b743ac
BLAKE2b-256 3971ee901754dd406fd11d7b32d7ddf9c9a8e6375245526bdad8b2b6beec4e85

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for thrindex-0.3.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 72486411678cc3434bb09893e5a08464e2ae1c596ed64200b8c1fb4a170a8817
MD5 cd3b97731b293d9c9fb8872361c82fa6
BLAKE2b-256 deff1e6e09beef1e06f61e8f601a3358a51209c4eea83fdbe5507e76de4d10e5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for thrindex-0.3.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3485ad68a5c2f323cc362d9f7bc60f151586054d40027a7e399a3c008cc1ddc9
MD5 2aeca52fff75a1da72d1acaf86ecb1e8
BLAKE2b-256 218821bcc36cf69aac824b2ff3706b68d4bdda07b1d7a13e5b8ed6d9e108b05b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for thrindex-0.3.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 51067425e20c47a1942b5975af7f7126c6a975f697ea3db2b50b525fbf5bf09d
MD5 2cdef6e1105b36d59903d8a965b84a95
BLAKE2b-256 fe03f19dad382ace40506725acb0aa37fcc05257cf8b078b5b6deb51eae9462f

See more details on using hashes here.

Provenance

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