A comprehensive tool for modeling and analyzing parasitic effects in crossbar arrays. This repository provides two main functionalities:
- Model Comparison – Benchmarks a variety of parasitic resistance models from the literature.
- Hardware-Aware Training – Enables training and evaluation of neural networks using the models.
- Features
1.1 Model Comparison
1.2 Hardware-Aware Training - Installation
- Usage
3.1 Crossbar Simulation
3.2 Parasitic-Aware Neural Network - Suggestions for Improvement
- Citation
-
Supported Models
- Ideal, Jeong, DMR, αβ-matrix, CrossSim, Memtorch, ngSpice, LTSpice.
- Easily switch the reference model (CrossSim by default). -
Parametric Analysis
- Adjustable array sizes.
- Configurable parasitic resistance values and memory window ratios (HRS/LRS).
- Tunable sparsity levels (% of HRS devices).
- Device variability for realistic crossbar simulation. -
Performance Metrics
- Execution time benchmarking.
- Current/voltage error measurements (relative error).
- Robustness evaluations under varying crossbar parameters.
-
Memristive Neural Network Setup
- Two-layer fully connected architecture for MNIST classification, with configurable hidden layer.
- Flexible tile partitioning, linear mapping of weights to conductances and quantization. -
Training and Testing
- Parasitic resistance incorporation into training, using parasitic models with automatic differentiation.
- Weights, biases, and confusion matrix visualizations after training. 2D and 3D accuracy plots for evaluation.
-
Clone the Repository
git clone https://github.com/alambertini01/Crossbar_Models_Comparison cd Crossbar_Models_Comparison
-
Create and Activate a Virtual Environment (Optional)
Windows:python -m venv .venv .venv\Scripts\activate
macOS/Linux:
python -m venv .venv source .venv/bin/activate
-
Install the Package
pip install -e .
-
(Optional) Installing NgSpice
If you plan to use the NgSpice-based model:pyspice-post-installation --install-ngspice-dll pyspice-post-installation --check-install
python Crossbar_Simulator.py
- Ideal for in-depth current and voltage analysis on custom-sized arrays.
- Offers detailed parameter tuning (resistance ratios, device variability, etc.).
python Crossbar_Simulator_Robustness.py
- Runs comprehensive simulation sweeps across multiple parameters.
- Generates robustness metrics (radar plots, 3D MSE plots).
python NN_Training.py
- Trains a two-layer MNIST classifier with PyTorch-based crossbar models (located in
CrossbarModels/Crossbar_Models_pytorch.py
). - Command-line prompts allow setting parasitic resistance, HRS, tile size, etc.
- Additional parameters (LRS, quantization bits, training checkpoints) can be modified within the script.
- Trained models are saved in
TrainedModels/ModelName
. - For GPU acceleration make sure to install pytorch based on your specific cuda version.
python NN_testing.py
- Loads a trained model and evaluates its accuracy.
- Different models can be used as reference, but it's recommended to use the CrossSim model for reliable validation.
- Further analysis on accuracy can be performed by sweeping parameters like R_HRS and bits.
@software{crossbar_simulator,
author = {Lambertini, Alessandro},
title = {Crossbar Parasitics Simulator},
year = {2024},
publisher = {GitHub},
url = {https://github.com/alambertini01/Crossbar_Models_Comparison}
}