Authors: Jason Ho, James. A. Boyle, Linshen Liu, and Andreas Gerstlauer
Affiliation: The University of Texas at Austin, System-Level Architecture and Modeling Group (SLAM Lab)
Conference: Machine Learning on Computer-Aided Design (MLCAD) 2025
Corresponding Contact: [email protected]
Neuromorphic systems using in-memory or event-driven computing are motivated by the need for more energy-efficient processing of artificial intelligence workloads. Emerging neuromorphic architectures aim to combine traditional digital designs with the computational efficiency of analog computing and novel device technologies. A crucial problem in the rapid exploration and co-design of such architectures is the lack of tools for fast and accurate modeling and simulation. Typical mixed-signal design tools integrate a digital simulator with an analog solver like SPICE, which is prohibitively slow for large systems. By contrast, behavioral modeling of analog components is faster, but existing approaches are fixed to specific architectures with limited energy and performance modeling. In this paper, we propose LASANA, a novel approach that leverages machine learning to derive data-driven surrogate models of analog sub-blocks in a digital backend architecture. LASANA uses SPICE-level simulations of a circuit to train ML models that predict circuit energy, performance, and behavior at analog/digital interfaces. Such models can provide energy and performance annotation on top of existing behavioral models or function as replacements to analog simulation. We apply LASANA to an analog crossbar array and a spiking neuron circuit. Running MNIST and spiking MNIST, LASANA surrogates demonstrate up to three orders of magnitude speedup over SPICE, with energy, latency, and behavioral error less than 7%, 8%, and 2%, respectively.
This repository contains the code and scripts used for our paper: LASANA: Large-Scale Surrogate Modeling for Analog Neuromorphic Architecture Exploration, accepted at MLCAD 2025. The code is structured for a Code Ocean capsule (link above), an immutable, reproducible container that contains code, datasets, and outputs from a run on their systems. We detail some of the limitations / guardrails put in place to successfully emulate our environment and results using Code Ocean below.
-
For reproducability sake, much of the randomness associated with this code (random-generated inputs, ML model initial weights, etc.) have been set to a specific seed. That said, the exact seeds used to exactly recreate the results in the paper exactly are unknown, and thus, the results do not exactly match the numbers found in the paper. We find that the results fall within the expected margin of variation. In a future section, we will dictate exactly how to disable these guardrails to enable randomness.
-
Due to the limitations of Code Ocean capsules, any section that deals with proprietary CAD tools (testbench generation, dataset creation, SPICE runs, SystemVerilog Real Number Modeling Runs) have been commented out of the main script, but available to enable if one has access to these tools.
-
Another limitation for Code Ocean is the lack of runtime / space. Thus, a limited set of results are evaluated. Specifically, on the MNIST and Spiking MNIST runs, we only run the first 500 test images, rather than the full 10k image set used in the evaluation of LASANA in the paper. This can be changed by the user and detailed below, but requires access to CAD tools (Synopsys HSpice, and Cadence Spectre) to generate the full golden results.
This artifact serves to create all possible experiments for LASANA, excluding the ones that require access to CAD tools. In the event that CAD tools are required, we have provided the output files that are generated by the CAD tool scripts, as well as provide the CAD tool scripts that have been verified on our machines to create the data output files provided. For this same reason, we are unable to produce the results that LASANA surrogate models are compared against (SPICE, SV-RNM). For MNIST and Spiking MNIST, we instead provide the first 500 inferences as golden results, as well as providing the scripts to generate the entire 10k test inference set if a researcher wants.
Specifically this artifact trains the PCM crossbar ML models, spiking neuron ML models, and then generates Table I, Table II, Figure 6, and Figure 7 from those results. We then run the trained spiking neuron models through the error propagation experiment to generate Table III and Figure 8. We then run the first 500 inferences of spiking MNIST and MNIST for the spiking neuron and crossbar, respectively, and generate the comparison results there too.
Referencing the camera-ready paper, we recreate section V in this artifact evaluation:
-
Section VA, VB: Using pre-made datasets due to no CAD tools, generate Table I, Table II, Figure 6 (a,b,c,d) and Figure 7 (a,b,c,d) by training PCM Crossbar (diff 30) and LIF Neuron models.
-
Section VC: Using the trained spike models from the previous section, recreate Table III by running with an oracle state predictor and a predicted state predictor for a 20,000 neuron layer run for 500ns. We additionally generate Figure 8 the predicted state predictor 20k run.
-
Section VD: For runtime scaling, we provide the scripts that provide the numbers (Ours) in Table IV. We additionally provide the scripts used to get the SV-RNM times and the SPICE times under
code/systemverilog
andcode/spice_run_20000_neurons_time.py
. -
Section VE: We recreate the experiments for MNIST and Spiking MNIST using the trained models from the previous sections for the first 500 test inferences. Since we cannot run the SPICE_equivalent circuits, we provide the golden results in
/data
, as well as providing the code used to generate these logs (code/spice_crossbar_mnist.py
,code/spice_mnist.py
, respectively.) Here, we compare the results from the golden results to our LASANA runs (code incode/lasana_crossbar_mnist/
andcode/lasana_spiking_mnist
, respectively) and then produce accuracy, average total energy and latency error per inference, and average per-inference dynamic energy and latency MAPE.
The following section will list off the files produced in the results section after the reproducible Code Ocean run and relate them back to where the exist in the paper. We have listed the following in alphabetical order:
-
crossbar_mnist_lasana_spice_comparison/
: This folder contains results relevant to Section VE for the Crossbar MNIST results. It contains two files.metrics_summary.txt
contains the high-level metrics comparing the LASANA Crossbar MNIST simulation to the golden results for the first 500 test images.per_inference_statistics.csv
contains the per-inference metrics. -
figures/
: This folder contains Figure 6 (labeled as pcm_crossbar_catboost_) for the PCM Crossbar, Figure 7 (labeled as mlp_) for the spiking neuron, and Figure 8 (labeled asml_inference_wrapper_MSE_over_time.png
). -
ml_inference_wrapper_intermediate_results/
: This folder contains the intermediate results that are used to create table iii. We have provided this file as there are other metrics that are shown that may be of interest beyond the paper. -
pcm_crossbar_diff_10_ml_models/
: This folder contains the trained CatBoost models for the PCM Crossbar with output with Gain 10 as well as the training summaries for each of the tested models in the paper as .csvs. -
pcm_crossbar_diff_30_ml_models/
: This folder contains the trained CatBoost models for the PCM Crossbar with output with Gain 30 as well as the training summaries for each of the tested models in the paper as .csvs. We note that these .CSVs and all results in Table I, Table II, and Figure 6 use these intermediate results. -
spiking_mnist_lasana-spice_comparison/
: This folder contains results relevant to Section VE for the Spiking MNIST results. It contains two files.metrics_summary.txt
contains the high-level metrics comparing the LASANA Spiking MNIST simulation to the golden results for the first 500 test images.per_inference_statistics.csv
contains the per-inference metrics. -
spiking_neuron_ml_models/
: This folder contains the trained MLP models and the standard scalar for the Indiveri LIF spiking neuron as well as the training summaries for each of the tested models in the paper as .csvs. We note that these .CSVs and all results in Table I, Table II, and Figure 7 use these intermediate results to craft their results. -
ml_inference_wrapper_spiking_neuron_timing_table.csv
: This CSV contains results relevant to Table IV. The resulting CSV is only for the (Ours) section, as we are unable to run any of the other models due to tool limitations. -
table_i.csv
: This CSV is a generated CSV of Table I in the paper. -
table_ii.csv
: This CSV is a generated CSV of Table II in the paper. -
table_iii.csv
: This CSV is a generated CSV of Table III in the paper.
The code is organized in the structure of the Code Ocean compute capsules, where from the root directory, there is a code/
section, a data/
section, and a results/
section. We describe the two folders and their main scripts in the following in alphabetical order:
-
code/lasana_crossbar_mnist/imac_mnist.py
: This script runs the experiment from Section VE, which runs LASANA on the first 500 test images of MNIST with the trained PCM Crossbar Arrays. This file uses a digital sigmoid neuron between layers as the activation layer. The first two hidden layers have a gain of 30, while the last layer has a gain of 10. -
code/lasana_spiking_mnistrun_mnist_lasana.py
: This script runs the experiment from Section VE, which runs LASANA on the first 500 test images of Spiking MNIST with the trained spiking LIF neurons. This file uses a three-layer spiking neura network. -
code/systemverilog
: This folder contains the relevant code used to generate the SV-RNM runs for Table IV timing. We have included both the PCM Crossbar SV-RNM behavioral models as well as the spiking neuron SV-RNM models. There is a .README here that explains what all of the different files do. -
code/circuit_dataset_creation.py
: This script uses the raw SPICe runs fromtestbench_generation.py
to generate the .CSV files that are used for the rest of the LASANA flow. In Figure 3 of the paper, this would correspond to the "Event Processing" block. -
code/config_pcm_crossbar_gain_10.py
: This is the configuration file that is used to generate the testbenches for SPICE runs, circuit_dataset_creation, and then training of the ML models for the 32x1 PCM Crossbar with a differential op-amp gain of 10. We note that Table I, Table II, etc. do not use these results, but this circuit is necessary for the MNIST experiments. We have included the intermediate result CSV files for the training of this, but since the results are very similar to the pcm crossbar with a gain of 30, we treat them as the same in results. -
code/config_pcm_crossbar_gain_30.py
: This is the configuration file that is used to generate the testbenches for SPICE runs, circuit_dataset_creation, and then training of the ML models for the 32x1 PCM Crossbar with a differential op-amp gain of 30. -
code/config_spiking_neuron.py
: This is the configuration file that is used to generate the testbenches for SPICE runs, circuit_dataset_creation, and then training of the ML models for the Indiveri LIF spiking neuron model. -
code/create_spikes.py
: Helper file used for creating spike trains in testbench generation and spiking MNIST. -
code/create_table_i_ii_iii.py
: Uses the intermediate results from training the models for the pcm crossbar and spiking neurons, as well as the error propagation study to create the results table i, table ii, and table iii. -
code/map*
: These files are a modification of IMAC-SIM, and are primarily helper files for the main script:code/spice_crossbar_mnist.py
. -
code/ml_inference_wrapper_pcm_crossbar.py
: While not used in this artifact, we wanted to provide code to recreate Table IV's runtime for the MAC unit -
code/ml_inference_wrapper_spiking_neuron_timing.py
: Same asml_inference_wrapper-spiking_neuron.py
, but sweeps through the neuron layer sizes to get the timing of each of the layers for a 500ns simulation run. -
code/ml_inference_wrapper_spiking_neuron.py
: Runs which create Table III, and Figure 8. This is the ML_inference_wrapper that is used and described in Algorithm 1. -
code/pcm_crossbar_predict_*
: Four files that train the different ML models using the dataset for PCM crossbars. These files also create Figure 6 (a,b,c,d). -
code/predict_*
: This is the equivalent scripts for the spiking neuron, but with an extra state predictor. This is used for the generation of the MLP models for the spiking neuron, and create Figure 7 (a,b,c,d). -
code/run_lasana.py
: MAIN SCRIPT. Calls everything and used for Code Ocean headless run to reproduce all the results. -
code/spice_crossbar_mnist.py
: Runs 10k test images of MNIST SPICE. It uses the models and .sp files from the/data/pcm_crossbar_mac_mnist_spice_files
anddata/iamc_mnist_model
. -
code/spice_mnist.py
: Runs 10k test images of Spiking MNIST SPICE. Note that this file takes an incredible amount of time to run (2404 hours for me on an i7-13700, 32GB ram), but is used to generate the golden results for spiking MNIST. -
code/spice_run_20000_neurons_time.py
: Script not used in this artifact. Uses spectre to generate 10 to 20k neuron runs using the same input .PWL files used in the other files. -
code/spice_versus_lasana_imac_comparison.py
: Comparison script that compares the golden SPICE Crossbar MNIST results to the LASANA generated results. -
code/spice_versus_lasana_spiking_comparison.py
: Comparison script that compares the golden SPICE spiking MNIST results to the LASANA generated results. -
code/SpikeData.py
: Helper file that contains the SpikeData datatype for us to easily move data around. -
code/stat_helpers.py
: As the name suggests, a file of stat_helper functions. -
code/testbench_generation.py
: Referring to Figure 3, this is the "Testbench Generation" block. This script takes circuit input ranges, and circuit parameter ranges, as well as the config files to generate uniformly sampled, random testbenches to characterize analog circuits. -
code/tools_helper_imac.py
: Very similar to tools_helper.py, but has a couple of specific things for hspice runs forspice_crossbar_mnist.py
. -
code/tools_helper.py
: This file contains much of the abstraction layer for the CAD tools. This is a pivotal file that allows us to script in python and control the CAD tools.
-
data/crossbar_mnist_golden_results/
: Contains the golden results of the first 500 test images from PCM Crossbar runs in SPICE. -
data/iamc_mnist_model/
: Contains the various files taken from IMAC-SIM, for their 4 layer fully connected neural network. It also contains binary-MNIST dataset, which is needed for the Crossbar MNIST runs. -
data/MNIST
: The original MNIST dataset, used for conversion to Spiking MNIST by Poisson rate encoding the pixels. -
data/pcm_crossbar_diff_10_run
: Contains the relevant train/test dataset since we do not have access to CAD tools for the PCM Crossbar with diff gain of 10 -
data/pcm_crossbar_diff_30_run
: Contains the relevant train/test dataset since we do not have access to CAD tools for the PCM Crossbar with diff gain of 30 -
data/pcm_crossbar_diff10_spice_files
: Contains the relevant raw SPICE file templates, libraries, and metadata files required to generate the PCM crossbar with gain of 10 runs. -
data/pcm_crossbar_diff30_spice_files
: Contains the relevant raw SPICE file templates, libraries, and metadata files required to generate the PCM crossbar with gain of 30 runs. -
data/pcm_crossbar_mac_mnist_spice_files
: Contains the relevant raw SPICE files that are used byspice_crossbar_mnist
to run the Crossbar MNIST golden reference. It is not explicitly used in this artifact, but we are providing the source for reproducibility sake. -
data/spiking_20000_runs
: This folder contains 20,000 randomized runs that have been generated and parsed to create a relevant test .CSV that is unseen to the training dataset. This is specifically used for the error propagation studies, as well as the runtime analysis of the spiking neuron. -
data/spiking_mnist_golden_results
: Contains the golden results of the first 500 test images from Spiking neural network runs in SPICE. -
data/spiking_neuron_run
: Contains the relevant train/test dataset since we do not have access to CAD tools for the Spiking Neuron. -
data/crossbar_mnist_golden_acc_data.csv
: This is the high-level output file used by IMAC-Sim to provide accuracy data and energy data from each inference of MNIST. -
data/spiking_mnist_model.pt
: Trained 3-layer SNN in SNNTorch, used for Spiking MNIST.
- The script should be configured to automatically run everything from the main script in the code repository,
run_lasana.py
. - While intermediate results are created and not available in Code Ocean, the most important results are moved to the
/results/
directory, where they can be viewed.
-
The results provide the trained models that can be used as surrogate models along with the ml_inference_wrapper to replace the PCM Crossbar / Spiking neuron models in any kind of simulation
-
We can change the LASANA MNIST scripts to run the entire 10k image set. We refrain from doing this because of the lack of space in Code Ocean (Produces about 50 GB of logs.)
-
With access to CAD tools, we have provided all the scripts to generate the SV-RNM and SPICE runs.
In each of the training configs, there is a "DETERMINISTIC" flag, that can be set to False in order to enable random ML weights, and training. We note that this does not disable all randomness, as there are seeds that have been set all throughout the project that need to be commented out to have true randomness in the runs.
In run_lasana.py
, lines 13 and 14 can be uncommented, along with 23 and 24 can be uncommented, to enable CAD tool runs which perform independent testbench generation and circuit dataset creation. This will replace the old .CSVs that have been put in place.
Additionally, near the end of the script, we can uncomment line 160, and line 163, which runs the actual SPICE Crossbar MNIST and SPICE Spiking MNIST. Though, we note that the actual runs take forever (We got 2404 hour runs for the whole Spiking MNIST and 11 hours for the Crossbar MNIST).
- Note: This requires access to both spectre, hspice, and psf (Cadence utility) in the environment path and accessible in the terminal as keywords.
Our runs, the Code Ocean runs, etc. have all been run in Python 3.8.*. We have also provided the essential dependencies in requirements.txt
, if one wants to recreate the same results locally.
If you use this work, please cite our paper:
J. Ho, J. A. Boyle, L. Liu, and A. Gerstlauer, “LASANA: Large‑Scale Surrogate Modeling for Analog Neuromorphic Architecture Exploration,” arXiv preprint arXiv:2507.10748, 2025, accepted at MLCAD 2025.
BibTeX
@article{Ho2025LASANA,
author = {Ho, Jason and Boyle, James A. and Liu, Linshen and Gerstlauer, Andreas},
title = {LASANA: Large-Scale Surrogate Modeling for Analog Neuromorphic Architecture Exploration},
journal = {arXiv preprint arXiv:2507.10748},
year = {2025},
note = {Accepted to MLCAD 2025},
doi = {10.48550/arXiv.2507.10748}
}