Skip to main content

PyPI Python CI License: Apache 2.0

mrve32-snn

SNN layer accelerator device module for the MRVE32 RISC-V emulator: a behavioural (golden) model of a memory-mapped spiking-layer accelerator, spec v0 draft.

  • LIF/IF neurons, i16 saturating potentials, i8 weights, reset by subtraction
  • one layer per START, local SRAM (spikes, weights, potentials, bias)
  • analytical cycle model, completion interrupt (MEIP)
  • the computation sits behind a swappable SnnBackend (default: ReferenceLif)

It plugs into the emulator through the public device interfaces only (BusDevice in Rust, the device C ABI in Python), like any third-party device; see docs/devices.md.

Install

pip install mrve32-snn        # also installs mrve32 and NumPy

Wheels exist for Linux, macOS and Windows, CPython 3.10 and newer. The emulator's own Python API is documented in docs/python.md.

Python

import numpy as np
import mrve32
from mrve32_snn import SnnAccelerator, SnnDriver, reference_step

emu = mrve32.Emulator()
emu.map_device(0x1000_0000, SnnAccelerator())
dev = SnnDriver(emu, 0x1000_0000)

rng = np.random.default_rng(0)
weights = rng.integers(-128, 128, size=(64, 32), dtype=np.int8)   # [n_in, n_out]
dev.load_layer(weights, v_th=100, leak_shift=4)

vmem = np.zeros(32, np.int16)
for t in range(10):
    spikes = rng.random(64) < 0.2
    out = dev.step(spikes)                    # write inputs, START, wait, read outputs
    expected, vmem = reference_step(spikes, weights, vmem, v_th=100, leak_shift=4)
    assert (out == expected).all() and (dev.read_vmem() == vmem).all()
print(dev.cycles, "cycles for the last step")

SnnDriver drives the device from Python through the emulated bus, with no firmware: useful to test models and data. Firmware programs the same registers itself; the driver's code is a readable reference for the programming sequence.

SnnAccelerator

SnnAccelerator(*, max_inputs=1024, max_outputs=512, weight_bytes=131072,
               t_setup=8, t_neuron=1, t_syn=1, lanes=8)

The device; map it with Emulator.map_device (a 1 MiB window). The arguments set its capacity and its timing model (how many cycles a step takes, spec §6). It raises the machine external interrupt when a step finishes, if enabled.

SnnDriver(emu, base)

Raises ValueError if there is no accelerator at base. Attributes: max_inputs, max_outputs, weight_bytes (read from the device), and n_in, n_out (the configured layer).

Method
load_layer(weights, *, v_th, leak_shift=0, bias=None) write int8[n_in, n_out] weights (and optional int16[n_out] bias) and configure the layer from their shape
configure(n_in, n_out, *, v_th, leak_shift=0, bias=False) set the layer size and neuron parameters only
write_bias(bias), write_vmem(vmem), read_vmem(n=None) bias and membrane potentials, int16
clear_vmem() reset all potentials to 0
write_input_spikes(spikes), read_output_spikes(n=None) boolean vectors
start(*, clear_vmem=False) start one timestep
wait(*, max_cycles=10_000_000, chunk=64) Emulator.tick until done; raises SnnError on a configuration error, TimeoutError if it never finishes
step(spikes_in) -> bool[n_out] write inputs, start, wait, acknowledge, return output spikes
enable_irq(enabled=True), ack_irq() the completion interrupt
status, busy, cycles, in_spikes, out_spikes status registers; cycles is the duration of the last step

Functions

  • reference_step(spikes_in, weights, vmem, *, v_th, leak_shift=0, bias=None) -> (spikes_out, vmem_out): one timestep in NumPy, bit-exact with the device (spec §5). Use it as the golden model in tests.
  • pack_spikes(spikes) -> uint32[] and unpack_spikes(words, n) -> bool[n]: convert between boolean vectors and the device's packed format (neuron k is bit k % 32 of word k // 32).

SnnError(code) is raised for a configuration error; code is one of ERR_INVALID_LAYER_SIZE, ERR_WEIGHTS_DO_NOT_FIT, ERR_INVALID_THRESHOLD. The module also exports the register offsets and bit masks of the specification (REG_CTRL, REG_STATUS, WEIGHTS_BASE, CTRL_START, STATUS_DONE, ...) for firmware-style access with emu.read_u32 and emu.write_u32.

Rust

use mrve32::Bus;
use mrve32_snn::{SNN_WINDOW_SIZE, SnnAccelerator, SnnConfig};

let mut bus = Bus::new();
bus.map_device(0x1000_0000, SNN_WINDOW_SIZE, Box::new(SnnAccelerator::new(SnnConfig::default())))
    .unwrap();

Metadata

Release files for mrve32-snn 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mrve32-snn 0.1.1
File Size Uploaded Provenance Actions
mrve32_snn-0.1.1.tar.gz 191.5 kB With provenance Details for mrve32_snn-0.1.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for mrve32-snn 0.1.1
File Actions
mrve32_snn-0.1.1-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for mrve32_snn-0.1.1-cp310-abi3-win_amd64.whl
mrve32_snn-0.1.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for mrve32_snn-0.1.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
mrve32_snn-0.1.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for mrve32_snn-0.1.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
mrve32_snn-0.1.1-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for mrve32_snn-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
mrve32_snn-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for mrve32_snn-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 1.4 MB

Release files / mrve32_snn-0.1.1.tar.gz

Download URL mrve32_snn-0.1.1.tar.gz
Size 191.5 kB
Tags Source
SHA-256 checksum
How to use checksums
3e46dc9fddbbc18e38eea58cb4a59e40c554a4494e2ea0e368662b4e5ee3f20e
BLAKE2b-256 checksum
How to use checksums
857ddf2f2d86adcf4e59242791713e563879994d4aba47983da409d2ca277c71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / mrve32_snn-0.1.1-cp310-abi3-win_amd64.whl

Download URL mrve32_snn-0.1.1-cp310-abi3-win_amd64.whl
Size 139.4 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
307af13850111004915131b0a470d9bfb47ec10b00c7b043013904c36102850c
BLAKE2b-256 checksum
How to use checksums
93b93ca8a22ed1bf26c329c92d56a52dbcc9de07efd55d6d8c633150f713ef77
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / mrve32_snn-0.1.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL mrve32_snn-0.1.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 279.7 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
85c33cba487cce52ac24bf2ccc5055075e9a8e7500680ace9d94068b33fe5687
BLAKE2b-256 checksum
How to use checksums
5b10db9d1765432005c89a6b844a34a12f148733b59d6468fe3d7bca0c951177
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / mrve32_snn-0.1.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL mrve32_snn-0.1.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 274.0 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
91a8de9649cf45b0aa522005ceb9005ddeed5f8186e39b9c4c7b73d59429f939
BLAKE2b-256 checksum
How to use checksums
a8f3f017a4f44450ddda3c52c79cc521429c4dd2baa207f97bd8af5ae1e4d5c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / mrve32_snn-0.1.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL mrve32_snn-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
Size 241.3 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f94bbcff83c15bdafd5abd60a3611fb7e2511dae12a5a6b4eb09ccad8c000cd3
BLAKE2b-256 checksum
How to use checksums
78b96861e2dceb92471e56fbff6a4a7b6ed8f8ccfe44ba59c39566a78a52128f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / mrve32_snn-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl

Download URL mrve32_snn-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl
Size 240.7 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
5ec1df893246f05c59738010872b67c89db73b3fb2d5dd6bdff6673ba2f730e8
BLAKE2b-256 checksum
How to use checksums
7facdd79e7444487b0336e048449fc419a9688173bf31455486f08b08cbb61ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Security for mrve32-snn 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for mrve32_snn-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

6 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page