Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Consider using release 4.3.0 instead.
Reason given by maintainers: Critical bugs fixed in v4.0.4: chunked LIF scan produces incorrect spikes and NaN

NeuraTensor

Fast neuromorphic inference for Python. Built around a hybrid SNN-SSM architecture — spiking neurons feeding into a state space model — that runs on anything from a laptop CPU to a datacenter GPU without any CUDA compilation steps.

pip install neuratensor

Requires Python 3.9+ and PyTorch 2.0+. Works on CPU, CUDA, and Apple Silicon (MPS).


Why this exists

Most "neuromorphic" Python packages are either toy implementations or wrappers around C++ runtimes that only run on specific hardware. NeuraTensor is neither. The core is pure PyTorch — leaky integrate-and-fire neurons with real surrogate gradients, a diagonal state space model with ZOH discretization — so it runs wherever PyTorch runs, compiles with torch.compile, and produces real gradient flow for fine-tuning.

The spike sparsity is a genuine property of the architecture, not a claim. On typical inputs, ~90% of activations are zero, which matters for edge deployment and energy-constrained environments.


Quickstart

from neuratensor import NeuraTensor, ModelConfig
import torch

# Use a preset
from neuratensor import get_preset, InferenceEngine

engine = InferenceEngine.from_preset("small")   # 64M params, auto device
input_ids = torch.randint(0, 32000, (1, 64))
result = engine.run(input_ids)

print(f"Latency:  {result.latency_ms:.1f} ms")
print(f"Sparsity: {result.metrics['estimated_sparsity_pct']:.1f}%")

That's it. No config files, no CUDA extensions to compile, no environment variables to set.


Available presets

Preset Params d_model Layers d_state Max seq
nano ~8M 256 6 16 512
small ~64M 512 12 32 1024
medium ~256M 1024 24 64 2048
large ~1B 2048 32 128 2048
from neuratensor import list_presets
list_presets()

Architecture

Each layer is a FusedSNNSSMBlock:

input → LayerNorm → Linear(2×) → [LIF neurons] → [SSM] → gate → Linear → + residual

LIF (Leaky Integrate-and-Fire): membrane potential accumulates input, fires a binary spike when it crosses threshold, then resets. Differentiable through a fast-sigmoid surrogate gradient. The membrane decay β is a learnable parameter per neuron.

SSM (State Space Model): diagonal S4D-style layer with zero-order-hold discretization. Processes the spike trains as temporal sequences. Maintains a hidden state that can be carried across calls for streaming inference.

Both components are pure PyTorch — no compiled extensions. torch.compile works out of the box.


Custom model

from neuratensor import NeuraTensorModel, ModelConfig

config = ModelConfig(
    vocab_size=50000,
    d_model=768,
    n_layers=16,
    d_state=32,
    expand=2,
    dropout=0.1,
)

model = NeuraTensorModel(config)
print(f"{model.count_parameters():,} parameters")

input_ids = torch.randint(0, 50000, (4, 128))
logits, states, metrics = model(input_ids)
# metrics: spike_rate, estimated_sparsity_pct, per_layer_spike_rate

Streaming inference

Carry state between calls — useful for real-time or token-by-token generation:

engine = InferenceEngine.from_preset("small")

# Process chunk by chunk, state flows through
for chunk in token_stream:
    result = engine.run(chunk, reset_state=False)
    yield result.logits

# Or use built-in generate
output = engine.generate(prompt_ids, max_new_tokens=128, temperature=0.8)

Benchmark

neuratensor benchmark small --seq-length 64 --iters 100
================================================================
  NeuraTensor SMALL | Benchmark Results
================================================================
  Device:         cuda
  Dtype:          torch.bfloat16
  Parameters:     64,512,000
  Batch size:     1
  Seq length:     64
----------------------------------------------------------------
  Latency mean:   8.4 ms ± 0.3 ms
  Latency p99:    9.1 ms
  Throughput:     119.0 seq/s
----------------------------------------------------------------
  Spike rate:     0.074
  Sparsity:       92.6%
================================================================

Inference server (AWS / Docker)

pip install 'neuratensor[server]'
neuratensor serve --preset small --port 8080

Endpoints: GET /health, GET /info, POST /infer, POST /generate, GET /metrics (Prometheus format).

Docker:

docker build -t neuratensor:3.0.1 .
docker run -p 8080:8080 -e NEURATENSOR_PRESET=small neuratensor:3.0.1

For ECS/EKS, see deploy/ecs_task_definition.json.


Save and load

engine.save("checkpoint.pt")

from neuratensor import InferenceEngine
engine = InferenceEngine.from_checkpoint("checkpoint.pt")

CLI

neuratensor info              # device + backend info
neuratensor presets           # list all presets with param counts
neuratensor benchmark small   # run benchmark
neuratensor serve --preset medium --port 8080

Telemetry

NeuraTensor collects anonymous usage data (SDK version, Python version, OS, preset name, latency) to help prioritize development. No personally identifiable information is collected. Disable at any time:

export NEURATENSOR_TELEMETRY=0

Or in code:

import os
os.environ["NEURATENSOR_TELEMETRY"] = "0"
import neuratensor

License

Apache 2.0. See LICENSE.

Built by Neuramorphic, Inc.

Metadata

Release files for neuratensor 3.0.2

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

Built distribution (wheel)

Table of built distributions (wheels) for neuratensor 3.0.2
File Interpreter ABI Platform Actions
neuratensor-3.0.2-py3-none-any.whl Python 3 none any Details for neuratensor-3.0.2-py3-none-any.whl

Release files / neuratensor-3.0.2-py3-none-any.whl

Download URL neuratensor-3.0.2-py3-none-any.whl
Size 28.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c11a5c0afbe0decccc87d99c3d970cc40a664e04e06ddf00af0071b366e85206
BLAKE2b-256 checksum
How to use checksums
0594fd9298cfa0ae20a2cfa1e66330e25c0f118e93f38f82064f2a3c1e688b48
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Security for neuratensor 3.0.2

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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

3.0.2 This release

1 release file No 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