Skip to content

neuromap.export

neuromap.export

Export Neuromap networks to chip-compatible artifacts.

The :class:Exporter quantizes model weights to match the hardware DAC bit-width and packages them into a .nmap archive that can be loaded onto a Neuromap chip.

Example::

from neuromap import Exporter, Network, chips

net = Network(chips.NEUROSOC_V1)
Exporter(net).quantize().save("model.nmap")

Exporter

Quantize and serialise a :class:~neuromap.network.Network.

The primary output format is .nmap - a simple ZIP archive containing:

  • manifest.json - chip spec, topology, quantization metadata.
  • weights/layer_<i>_weight.npy - per-layer quantized weight matrices as integer numpy arrays.
  • weights/layer_<i>_bias.npy - per-layer bias vectors.

Parameters:

Name Type Description Default
network Any

A :class:~neuromap.network.Network instance whose underlying model will be exported.

required

quantize(bits=None)

Apply post-training quantization to the model weights.

Parameters:

Name Type Description Default
bits int | None

Bit-width for quantization. Defaults to the chip's weight_bits setting.

None

Returns:

Name Type Description
This Exporter

class:Exporter instance for chaining.

to_weight_map()

Extract per-layer quantized weight arrays.

Returns:

Type Description
dict[str, ndarray]

Dictionary mapping "layer_<i>_weight" (and optionally

dict[str, ndarray]

"layer_<i>_bias") to numpy arrays. When :meth:quantize

dict[str, ndarray]

was called, weight values are clipped integer arrays.

save(path)

Save a .nmap bundle (ZIP archive with manifest + weights).

Parameters:

Name Type Description Default
path str | Path

Destination file path (conventionally *.nmap).

required

load_nmap(path, *, device='cpu') classmethod

Load a .nmap bundle and reconstruct a :class:Network.

Parameters:

Name Type Description Default
path str | Path

Path to the .nmap file.

required
device str | device

Device to load the model onto.

'cpu'

Returns:

Name Type Description
A Any

class:~neuromap.network.Network instance with the

Any

stored weights loaded.

to_bytes()

Export the model as in-memory .nmap bytes.

Produces the same ZIP archive as :meth:save without writing to disk.

Returns:

Type Description
bytes

ZIP archive bytes identical to what :meth:save would write.