Skip to main content

The neuromorphic infrastructure SDK

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.0.tar.gz (62.0 kB view details)

Uploaded Source

Built Distribution

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

thrindex-0.3.0-cp314-cp314-macosx_11_0_arm64.whl (454.6 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for thrindex-0.3.0.tar.gz
Algorithm Hash digest
SHA256 d2c88983c02cc797e7217d04f7ba66066ac9cf03d2609afc232e3c1324efd0ac
MD5 744b623a58d7a535ac6d743f3bab5798
BLAKE2b-256 ca39cbd558d0a2096672d5f30390bde7085b02f6f1f4b8f25a92ade839651f30

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thrindex-0.3.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 54daac0a35bddcfbe89e82e5a001b2226aaa884ae98f4a33d4fe2cdee552a124
MD5 148032454bcee1d1aa80850127e6a944
BLAKE2b-256 a4abab81f7222702ce56b99d8ac6f4470ae095f07d9302db3a515e326170daec

See more details on using hashes here.

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