Package: aihwkit
IBM Analog Hardware Acceleration KitDescriptionIBM Analog Hardware Acceleration Kitis an open source Python toolkit for
exploring and using the capabilities of in-memory computing devices in the
context of artificial intelligence.:warning: This library is currently in beta and under active development.
Please be mindful of potential issues and keep an eye for improvements,
new features and bug fixes in upcoming versions.The toolkit consists of two main components:Pytorch integrationA series of primitives and features that allow using the toolkit withinPyTorch:Analog neural network modules (fully connected layer, 1d/2d/3d convolution
layers, LSTM layer, sequential container).Analog training using torch training workflow:Analog torch optimizers (SGD).Analog in-situ training using customizable device models and algorithms
(Tiki-Taka).Analog inference using torch inference workflow:State-of-the-art statistical model of a phase-change memory (PCM) array
calibrated on hardware measurements from a 1 million PCM devices chip.Hardware-aware training with hardware non-idealities and noise
included in the forward pass to make the trained models more
robust during inference on Analog hardware.Analog devices simulatorA high-performant (CUDA-capable) C++ simulator that allows for
simulating a wide range of analog devices and crossbar configurations
by using abstract functional models of material characteristics with
adjustable parameters. Features include:Forward pass output-referred noise and device fluctuations, as well
as adjustable ADC and DAC discretization and boundsStochastic update pulse trains for rows and columns with finite
weight update size per pulse coincidenceDevice-to-device systematic variations, cycle-to-cycle noise and
adjustable asymmetry during analog updateAdjustable device behavior for exploration of material specifications for
training and inferenceState-of-the-art dynamic input scaling, bound management, and update
management schemesOther featuresAlong with the two main components, the toolkit includes other
functionalities such as:A library of device presets that are calibrated to real hardware data and
based on models in the literature, along with a configuration that specifies a particular device and optimizer choice.A module for executing high-level use cases ("experiments"), such as neural
network training with minimal code overhead.A utility to automatically convert a downloaded model (e.g., pre-trained) to its equivalent Analog
model by replacing all linear/conv layers to Analog layers (e.g., for convenient hardware-aware training).Integration with theAIHW Composerplatform, a no-code web experience that allows executing
experiments in the cloud.How to cite?In case you are using theIBM Analog Hardware Acceleration Kitfor
your research, please cite the AICAS21 paper that describes the toolkit:Malte J. Rasch, Diego Moreda, Tayfun Gokmen, Manuel Le Gallo, Fabio Carta,
Cindy Goldberg, Kaoutar El Maghraoui, Abu Sebastian, Vijay Narayanan."A flexible and fast PyTorch toolkit for simulating training and inference on
analog crossbar arrays"(2021 IEEE 3rd International Conference on Artificial Intelligence Circuits and Systems)UsageTraining examplefromtorchimportTensorfromtorch.nn.functionalimportmse_loss# Import the aihwkit constructs.fromaihwkit.nnimportAnalogLinearfromaihwkit.optimimportAnalogSGDx=Tensor([[0.1,0.2,0.4,0.3],[0.2,0.1,0.1,0.3]])y=Tensor([[1.0,0.5],[0.7,0.3]])# Define a network using a single Analog layer.model=AnalogLinear(4,2)# Use the analog-aware stochastic gradient descent optimizer.opt=AnalogSGD(model.parameters(),lr=0.1)opt.regroup_param_groups(model)# Train the network.forepochinrange(10):pred=model(x)loss=mse_loss(pred,y)loss.backward()opt.step()print('Loss error:{:.16f}'.format(loss))You can find more examples in theexamples/folder of the project, and
more information about the library in thedocumentation. Please note that
the examples have some additional dependencies - you can install them viapip install -r requirements-examples.txt.
You can find interactive notebooks and tutorials in thenotebooks/directory.Further readingWe also recommend to take a look at the tutorial article that
describes the usage of the toolkit that can be found here:Manuel Le Gallo, Corey Lammie, Julian Buechel, Fabio Carta, Omobayode Fagbohungbe,
Charles Mackin, Hsinyu Tsai, Vijay Narayanan, Abu Sebastian, Kaoutar El Maghraoui,
Malte J. Rasch."Using the IBM Analog In-Memory Hardware Acceleration Kit for Neural Network Training and Inference"(APL Machine Learning Journal:1(4) 2023)What is Analog AI?In traditional hardware architecture, computation and memory are siloed in
different locations. Information is moved back and forth between computation
and memory units every time an operation is performed, creating a limitation
called thevon Neumann bottleneck.Analog AI delivers radical performance improvements by combining compute and
memory in a single device, eliminating the von Neumann bottleneck. By leveraging
the physical properties of memory devices, computation happens at the same place
where the data is stored. Such in-memory computing hardware increases the speed
and energy efficiency needed for next-generation AI workloads.What is an in-memory computing chip?An in-memory computing chip typically consists of multiple arrays of memory
devices that communicate with each other. Many types of memory devices such asphase-change memory(PCM),resistive random-access memory(RRAM), andFlash memorycan be used for in-memory computing.Memory devices have the ability to store synaptic weights in their analog
charge (Flash) or conductance (PCM, RRAM) state. When these devices are arranged
in a crossbar configuration, it allows to perform an analog matrix-vector
multiplication in a single time step, exploiting the advantages of analog
storage capability andKirchhoff’s circuits laws. You can learn more about
it in ouronline demo.In deep learning, data propagation through multiple layers of a neural network
involves a sequence of matrix multiplications, as each layer can be represented
as a matrix of synaptic weights. The devices are arranged in multiple crossbar
arrays, creating an artificial neural network where all matrix multiplications
are performed in-place in an analog manner. This structure allows to run deep
learning models at reduced energy consumption.Awards and Media MentionsIBM Research blog: [Open-sourcing analog AI simulation]:https://research.ibm.com/blog/analog-ai-for-efficient-computingWe are proud to share that the AIHWKIT and the companion cloud composer received the IEEE OPEN SOURCE SCIENCEawardin 2023.InstallationInstalling from PyPIThe preferred way to install this package is by using thePython package index:pipinstallaihwkitConda-based InstallationThere is a conda package for aihwkit available in conda-forge.   It can be  installed in a conda environment running on a Linux or WSL in a Windows system.CPUcondainstall-cconda-forgeaihwkitGPUcondainstall-cconda-forgeaihwkit-gpuIf you encounter any issues during download or want to compile the package
for your environment, please take a look at theadvanced installationguide.
That section describes the additional libraries and tools required for
compiling the sources using a build system based oncmake.Docker InstallationFor GPU support, you can also build a docker container following theCUDA Dockerfile instructions.
You can then run a GPU enabled docker container using the follwing command from your peoject dircetorydockerrun--rm-it--gpusall-v$(pwd):$HOME--nameaihwkitaihwkit:cudabashAuthorsIBM Research has developed IBM Analog Hardware Acceleration Kit,
with Malte Rasch, Diego Moreda, Fabio Carta, Julian Büchel, Corey Lammie, Charles Mackin, Kim Tran, Tayfun Gokmen, Manuel Le Gallo-Bourdeau, and Kaoutar El Maghraoui
as the initial core authors, along with manycontributors.You can contact us by opening a new issue in the repository or alternatively
at theaihwkit@us.ibm.comemail address.LicenseThis project is licensed underApache License 2.0.