Skip to main content

AnalogLib

PyPI Version License: MIT Python 3.10+

AnalogLib is an open-source Python library for simulating analog in-memory computing (IMC) and neural network inference on resistive crossbar architectures (ReRAM, Phase-Change Memory, Flash, and memristive arrays).


Key Features

  • Analog Intermediate Representation (AIR): Decoupled intermediate representation schema with lowering compiler passes.
  • Neural Network Converters: Convert PyTorch models (nn.Module) or NumPy weight lists straight to analog crossbar engines.
  • Physical Device Models: Quantized ReRAM device models with multi-state conductance, read noise, and spatial variation.
  • Tiled Crossbar Subsystem: Automatically partition large weight matrices across 2D grids of physical crossbar tiles.
  • Physical Hardware Non-Idealities: Parasitic wire IR drop, Arrhenius temperature dependence, and power-law retention drift.
  • Analytics & Profiler: Calculate array power, read energy, ADC/DAC energy overhead, cell area, latency, and TOPS/W.
  • SPICE Netlist Exporter: Export crossbar layers to standalone SPICE netlists for ngspice or LTspice.
  • Encrypted Model Format: Secure, encrypted .analog binary format (AES-256-GCM + MsgPack).

Quick Start

Installation

pip install analoglib

To install optional PyTorch and visualization support:

pip install "analoglib[torch,viz]"

5-Minute Usage Example

High-Level Model API

import analoglib as al
import numpy as np

# 1. Load trained weight matrices (or convert PyTorch nn.Module)
W1 = np.random.randn(784, 128)
W2 = np.random.randn(128, 10)

# 2. Build AnalogModel via AIR
model = al.AnalogModel.from_numpy([W1, W2], activations=["relu", "softmax"])

# 3. Target physical ReRAM crossbars + ADC/DAC + Hardware Effects
model.compile(
    device=al.ReRAM(g_min=1e-6, g_max=100e-6, num_states=256, read_noise_sigma=0.01),
    adc_bits=8,
    dac_bits=8,
    r_wire=1.0,     # Parasitic IR drop
    E_a=0.1,        # Thermal Arrhenius scaling
    nu=0.05,        # Retention drift
)

# 4. Simulate inference
x_input = np.random.uniform(0, 1, 784)
result = model.simulate(x_input, mode="hardware")

# 5. Print hardware profiling & energy report
result.report()

PyTorch Model Conversion

import torch.nn as nn
import analoglib as al

# PyTorch network
torch_model = nn.Sequential(
    nn.Linear(784, 128),
    nn.ReLU(),
    nn.Linear(128, 10)
)

# Convert & compile to analog crossbars
model = al.AnalogModel.from_torch(torch_model)
model.compile(device=al.ReRAM(num_states=256), adc_bits=8, dac_bits=8)
result = model.simulate(x_input, mode="hardware")

Command Line Interface (CLI)

# Inspect a saved .analog file
analog info model.analog

# Run hardware inference
analog simulate model.analog --mode hardware

# Profile array power, TOPS/W, latency, and area
analog profile model.analog

# Export to SPICE netlist
analog export-spice model.analog --out circuit.cir --dialect ngspice

Documentation

For full guides and API references:


License

MIT License. See LICENSE for details.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

analoglib-0.1.0.tar.gz (61.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

analoglib-0.1.0-py3-none-any.whl (61.8 kB view details)

Uploaded Python 3

File details

Details for the file analoglib-0.1.0.tar.gz.

File metadata

  • Download URL: analoglib-0.1.0.tar.gz
  • Upload date:
  • Size: 61.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.5

File hashes

Hashes for analoglib-0.1.0.tar.gz
Algorithm Hash digest
SHA256 13f2252142daaa6d109a1f140c6c5973040d224e3c4f5975f75334b1944cad91
MD5 c950af094ad179928e0bfbfd62a169b8
BLAKE2b-256 3f6c22d9cb3177c946a598674e6bc645c2493841d83a00d63effa54b53e57f2c

See more details on using hashes here.

File details

Details for the file analoglib-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: analoglib-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 61.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.5

File hashes

Hashes for analoglib-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 212b68f04498851fbd416ac3940bca460d9f966157b1fafbb892dd487b7caa52
MD5 9c26380c501db23d89a4f3a590eea241
BLAKE2b-256 ce866092d9d4733a4d361559950dffc9961ca8c29065965a0532ce4cdd184485

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page