Metadata-Version: 2.4
Name: neuromap
Version: 0.1.4
Summary: SDK for programming Neuromap neuromorphic chips
License: MIT
License-File: LICENSE
Author: Neuromap
Author-email: contact@neuromap.ca
Requires-Python: >=3.10,<4.0
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Dist: numpy (>=1.24)
Requires-Dist: pyserial (>=3.5)
Requires-Dist: snntorch (>=0.9)
Requires-Dist: torch (>=2.0)
Project-URL: Bug Tracker, https://github.com/laurent-colas/neuromap/issues
Project-URL: Homepage, https://neuromap-two.vercel.app
Project-URL: Repository, https://github.com/laurent-colas/neuromap
Description-Content-Type: text/markdown

# Neuromap SDK

Python SDK for programming Neuromap neuromorphic chips.

## Installation

```bash
pip install neuromap
```

For development (using Poetry):

```bash
cd neuro-sim
poetry install --with dev
```

## Quick Start

```python
from neuromap import Network, Trainer, Exporter, chips

# Build a network matching the NeuroSoC-v1 chip
net = Network(chips.NEUROSOC_V1)
print(net.summary())

# Train
trainer = Trainer(net, lr=1e-3, epochs=20)
history = trainer.fit(train_loader, val_loader)

# Export for deployment
Exporter(net).quantize().save("model.nmap")
```

## Simplified API (snnTorch)

The SDK provides convenience functions backed by [snnTorch](https://snntorch.readthedocs.io/) for a streamlined workflow:

```python
import neuromap as nm

# Encode raw data to spike trains (wraps snntorch.spikegen)
spike_data = nm.encode_sensor_data(raw_images, num_steps=100)

# Build network from the fixed chip topology
model = nm.Network(nm.chips.NEUROSOC_V1)

# Configure surrogate gradients for training
nm.compile_model(model, surrogate="atan")

# Train, then quantize & export to hardware
nm.quantize_and_export_to_spi(model, path="model.nmap")
```

Available surrogate gradients: `"atan"` (default), `"fast_sigmoid"`, `"straight_through"`, `"spike_rate_escape"`.

Available encoding methods: `"rate"` (default), `"latency"`, `"delta"`.

## Running Tests

```bash
poetry run pytest tests/ -v
```

Or via Nx from the repo root:

```bash
npx nx run neuro-sim:test
```

## Linting & Formatting

```bash
poetry run ruff check .
poetry run ruff format .
```

