AnalogLib
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
.analogbinary 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.
Metadata
Release files for analoglib 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| analoglib-0.1.0.tar.gz | 61.7 kB | Without provenance | Details for analoglib-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| analoglib-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for analoglib-0.1.0-py3-none-any.whl |
Total release size: 123.6 kB
Release files / analoglib-0.1.0.tar.gz
| Download URL | analoglib-0.1.0.tar.gz |
|---|---|
| Size | 61.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
13f2252142daaa6d109a1f140c6c5973040d224e3c4f5975f75334b1944cad91
|
|
BLAKE2b-256 checksum How to use checksums |
3f6c22d9cb3177c946a598674e6bc645c2493841d83a00d63effa54b53e57f2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Release files / analoglib-0.1.0-py3-none-any.whl
| Download URL | analoglib-0.1.0-py3-none-any.whl |
|---|---|
| Size | 61.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
212b68f04498851fbd416ac3940bca460d9f966157b1fafbb892dd487b7caa52
|
|
BLAKE2b-256 checksum How to use checksums |
ce866092d9d4733a4d361559950dffc9961ca8c29065965a0532ce4cdd184485
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Security for analoglib 0.1.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.