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. Spiking neurons meet selective state space models — runs on CPU, CUDA, or Apple Silicon without any compilation hassles.

pip install neuratensor

Requires Python 3.9+ and PyTorch 2.0+.


What this is

Most neuromorphic packages are either academic toys or hardware-locked C++ binaries. NeuraTensor is pure PyTorch — leaky integrate-and-fire neurons with surrogate gradients, a Mamba-style selective SSM with HiPPO initialization, and real spike sparsity (~90% activations are zero). It works wherever PyTorch works, compiles with torch.compile, and lets you fine-tune with standard optimizers.

I built this because existing options were either impractical for production or didn't deliver on the efficiency promises. This does both.


Quickstart

from neuratensor import InferenceEngine
import torch

engine = InferenceEngine.from_preset("small")   # 80M 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}%")

No config files, no CUDA extensions to compile, no surprises.


Presets

Preset Params d_model Layers d_state Attention Max seq
pico ~3M 128 4 8 None 256
nano ~15M 256 6 16 Every 6th 512
small ~80M 512 8 32 Every 4th 1024
medium ~350M 1024 16 64 Every 4th 2048
large ~1.3B 2048 24 128 Every 4th 2048
from neuratensor import list_presets
list_presets()

Architecture (v4)

Each layer is a FusedSpikeBlock:

input → RMSNorm → expand(2×) → [LIF] → [Selective SSM] → sparse gate → project → + residual
                                                     ↓
                              Optional sliding-window attention every N layers

LIF (Leaky Integrate-and-Fire): Membrane potential accumulates input current, fires a binary spike when crossing threshold, then soft-resets. Differentiable via fast-sigmoid surrogate gradient. Decay constant β is learned per neuron. Chunked parallel scan reduces Python overhead from O(T) to O(T/chunk_size).

Selective SSM: Input-dependent B, C, Δ parameters (Mamba-style selection mechanism). HiPPO-inspired A matrix initialization for multi-scale temporal memory. Zero-order-hold discretization. State carries across calls for streaming inference.

Hybrid attention: Optional sliding-window attention with RoPE every N layers for long-range retrieval. Most layers are pure SNN-SSM (faster, sparser); attention is added only where needed.

Sparse inference: Output projection skips computation for positions with no spike activity during inference (~90% speedup when sparsity > 50%).

All pure PyTorch — no compiled extensions. Works with torch.compile 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,
    attn_every=4,        # attention every 4th layer
    attn_heads=8,
    attn_window=512,
    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 autoregressive 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, metrics = engine.generate(
    prompt_ids, 
    max_new_tokens=128, 
    temperature=0.8,
    top_k=50,
    repetition_penalty=1.1,
)

Training and fine-tuning

from neuratensor import NeuraTensorModel
from neuratensor.training import Trainer, TrainConfig, LoRAConfig, apply_lora

model = NeuraTensorModel.from_preset("small")

# Apply LoRA for efficient fine-tuning
apply_lora(model, LoRAConfig(r=16, alpha=32, target_modules=["in_proj", "out_proj"]))

config = TrainConfig(
    max_steps=10000,
    batch_size=8,
    learning_rate=3e-4,
    warmup_steps=500,
    gradient_accumulation_steps=4,
)

trainer = Trainer(model, config, train_data="data.jsonl")
trainer.train()

# Merge LoRA weights back into base model
from neuratensor.training import merge_lora
merge_lora(model)

Benchmark

neuratensor benchmark small --seq-length 64 --iters 100

Example output (NVIDIA A100):

================================================================
  NeuraTensor SMALL | Benchmark Results
================================================================
  Device:         cuda
  Dtype:          torch.bfloat16
  Parameters:     80,224,256
  Batch size:     1
  Seq length:     64
----------------------------------------------------------------
  Latency mean:   7.2 ms ± 0.4 ms
  Latency p99:    8.1 ms
  Throughput:     138.9 seq/s
----------------------------------------------------------------
  Spike rate:     0.082
  Sparsity:       91.8%
================================================================

Inference server

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:4.0.0 .
docker run -p 8080:8080 -e NEURATENSOR_PRESET=small neuratensor:4.0.0

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. Opt out anytime:

export NEURATENSOR_TELEMETRY=0

Or in code:

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

Support

Questions or issues? Reach us at support@neuramorphic.ai

Built by Peter Fullé (Lead Architect) and the team at Neuramorphic, Inc.


License

Apache 2.0. See LICENSE.

Metadata

Release files for neuratensor 4.0.0

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

Source distribution (sdist)

Source distribution for neuratensor 4.0.0
File Size Uploaded Provenance Actions
neuratensor-4.0.0.tar.gz 40.4 kB Without provenance Details for neuratensor-4.0.0.tar.gz

Built distribution (wheel)

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

Total release size: 82.9 kB

Release files / neuratensor-4.0.0.tar.gz

Download URL neuratensor-4.0.0.tar.gz
Size 40.4 kB
Tags Source
SHA-256 checksum
How to use checksums
cbc2b8925a2a39bca6d77af1ce997eb06fed7a607ed6ba8133c945da8b82c99c
BLAKE2b-256 checksum
How to use checksums
461c5872290f2121814065bff15141d45b5ef8127624f44c946342e38ed171c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

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

Download URL neuratensor-4.0.0-py3-none-any.whl
Size 42.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
91dab62c3b33140a81561c2e9a0087054535d7cf8b37a46c9e4019c4aae2707e
BLAKE2b-256 checksum
How to use checksums
71eb75ad98bd91289976a425726372c9c8de16e3b010d03254206319e15f54a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Security for neuratensor 4.0.0

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

4.0.0 This release

2 release files 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