Skip to main content

IBM Analog Hardware Acceleration Kit

PyPI test-and-lint Documentation Status PyPI - License arXiv

Looking for fast hardware-aware training?

Try AIHWKit-Lightning: a fast and scalable toolkit for hardware-aware training of large neural networks on Analog In-Memory Computing (AIMC) hardware. It is the go-to option when training speed and scale are what you need.

Description

IBM Analog Hardware Acceleration Kit is an open source Python toolkit for exploring and using the capabilities of in-memory computing devices in the context of artificial intelligence.

⚠️ 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 integration

A series of primitives and features that allow using the toolkit within PyTorch:

  • 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 simulator

A 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 bounds
  • Stochastic update pulse trains for rows and columns with finite weight update size per pulse coincidence
  • Device-to-device systematic variations, cycle-to-cycle noise and adjustable asymmetry during analog update
  • Adjustable device behavior for exploration of material specifications for training and inference
  • State-of-the-art dynamic input scaling, bound management, and update management schemes

Other features

Along 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 the AIHW Composer platform, a no-code web experience that allows executing experiments in the cloud.

How to cite?

In case you are using the IBM Analog Hardware Acceleration Kit for 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)

Usage

Training example

from torch import Tensor
from torch.nn.functional import mse_loss

# Import the aihwkit constructs.
from aihwkit.nn import AnalogLinear
from aihwkit.optim import AnalogSGD

x = 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.
for epoch in range(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 the examples/ folder of the project, and more information about the library in the documentation. Please note that the examples have some additional dependencies - you can install them via pip install -r requirements-examples.txt. You can find interactive notebooks and tutorials in the notebooks/ directory.

Further reading

We 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 the von 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 as phase-change memory (PCM), resistive random-access memory (RRAM), and Flash memory can 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 and Kirchhoff’s circuits laws. You can learn more about it in our online 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 Mentions

Installation

Installing from PyPI

The preferred way to install this package is by using the Python package index:

pip install aihwkit

Conda-based Installation

There 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.

  • CPU

    conda install -c conda-forge aihwkit
    
  • GPU

    conda install -c conda-forge aihwkit-gpu
    

If you encounter any issues during download or want to compile the package for your environment, please take a look at the advanced installation guide. That section describes the additional libraries and tools required for compiling the sources using a build system based on cmake.

Docker Installation

For GPU support, you can also build a docker container following the CUDA Dockerfile instructions. You can then run a GPU enabled docker container using the follwing command from your peoject dircetory

docker run --rm -it --gpus all -v $(pwd):$HOME --name aihwkit aihwkit:cuda bash

Running on AMD GPUs (ROCm/HIP)

The RPUCuda backend is not limited to NVIDIA hardware: the analog tile simulator can also be built for AMD GPUs through ROCm/HIP. The port adds an optional USE_HIP build that compiles the existing CUDA-spelled device sources against HIP, hipBLAS, hipRAND and hipCUB via a single compatibility header, so the simulator kernels (including the stochastic pulse trains of the analog update) run natively on AMD GPUs. The CUDA path is untouched and both builds are mutually exclusive.

From Python nothing changes: analog tiles are moved to the GPU with the usual .cuda() calls, and aihwkit.simulator.rpu_base.cuda.is_compiled() reports the GPU build as usual.

This work is proposed upstream in aihwkit PR #770 and is maintained by AMD in a separate fork, AMD-Ecosystem/aihwkit, on the moat-port branch:

git clone -b moat-port https://github.com/AMD-Ecosystem/aihwkit.git
cd aihwkit
python setup.py build_ext --inplace -j16 \
    -DUSE_HIP=ON -DUSE_CUDA=OFF \
    -DCMAKE_HIP_ARCHITECTURES=gfx90a \
    -DCMAKE_PREFIX_PATH=$CONDA_PREFIX

Set -DCMAKE_HIP_ARCHITECTURES to the gfx target of your card, which you can look up with:

rocminfo | grep -m1 -o 'gfx[0-9a-f]*'

Depending on the environment you may also need -DCMAKE_HIP_COMPILER=/opt/rocm/llvm/bin/clang++, -DCMAKE_PREFIX_PATH pointing at both the torch cmake directory and /opt/rocm, and -DRPU_CXX_STANDARD=20 for recent PyTorch headers.

The port has been validated against the CPU tiles with the tile, bindings, torch and inference test suites on:

GPU Architecture OS / ROCm
Instinct MI250X gfx90a (CDNA2, wave64) Linux, ROCm 7.2.1
Radeon Pro W7800 gfx1100 (RDNA3, wave32) Linux, ROCm 7.2.1
Radeon RX 9070 XT gfx1201 (RDNA4, wave32) Windows, ROCm 7.14

Wave32 (RDNA) and wave64 (CDNA) devices produce the same pulse stream as the CUDA build, as the warp-level primitives used by the bit line maker are mapped to width-32 logical warp operations.

Authors

IBM 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 many contributors.

You can contact us by opening a new issue in the repository or alternatively at the aihwkit@us.ibm.com email address.

License

This project is licensed under [MIT License].

Metadata

Release files for aihwkit 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aihwkit 1.2.0
File Size Uploaded Provenance Actions
aihwkit-1.2.0.tar.gz 689.6 kB Without provenance Details for aihwkit-1.2.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for aihwkit 1.2.0
File Actions
aihwkit-1.2.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for aihwkit-1.2.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
aihwkit-1.2.0-cp314-cp314-macosx_26_0_arm64.whl CPython 3.14 CPython 3.14 macOS 26.0+ ARM64 Details for aihwkit-1.2.0-cp314-cp314-macosx_26_0_arm64.whl
aihwkit-1.2.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for aihwkit-1.2.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
aihwkit-1.2.0-cp313-cp313-macosx_26_0_arm64.whl CPython 3.13 CPython 3.13 macOS 26.0+ ARM64 Details for aihwkit-1.2.0-cp313-cp313-macosx_26_0_arm64.whl
aihwkit-1.2.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for aihwkit-1.2.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
aihwkit-1.2.0-cp312-cp312-macosx_26_0_arm64.whl CPython 3.12 CPython 3.12 macOS 26.0+ ARM64 Details for aihwkit-1.2.0-cp312-cp312-macosx_26_0_arm64.whl

Total release size: 70.1 MB

Release files / aihwkit-1.2.0.tar.gz

Download URL aihwkit-1.2.0.tar.gz
Size 689.6 kB
Tags Source
SHA-256 checksum
How to use checksums
288b00aed52a99f578a2e7ac46fdbf2a9f07e4780c4307eae5827558f1bf2cba
BLAKE2b-256 checksum
How to use checksums
cf69a2c61897eae27dca5fcb62e55dad93edad1bdebdffd67e0e000e41fd768e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / aihwkit-1.2.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL aihwkit-1.2.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 13.8 MB
Tags CPython 3.14 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
b6577dde8a4cc6f186c145d54c4e99ef5cba02b73cf243e1d1abd66d8c697048
BLAKE2b-256 checksum
How to use checksums
b648210ba3dcc970c718c8d048346c29d43378011b8859795249867dbd5568b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / aihwkit-1.2.0-cp314-cp314-macosx_26_0_arm64.whl

Download URL aihwkit-1.2.0-cp314-cp314-macosx_26_0_arm64.whl
Size 9.4 MB
Tags CPython 3.14 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
0cbe5225cda69de8eb1a87e8b63b2952b086a5833946ab5a5249b6c30e93c8f1
BLAKE2b-256 checksum
How to use checksums
513d01bc6f17f21dff99aeab4ab3548dd67c6e950e1a822b5ca0179995b2cd73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / aihwkit-1.2.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL aihwkit-1.2.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 13.8 MB
Tags CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
a2148a5972edef0685064686a91997494871d60dfe84472a9c058dfa3b9b8bc8
BLAKE2b-256 checksum
How to use checksums
4c6bd329c2fcb72f3c24be9cd3dab197383403d2259033811b4d487744d9f508
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / aihwkit-1.2.0-cp313-cp313-macosx_26_0_arm64.whl

Download URL aihwkit-1.2.0-cp313-cp313-macosx_26_0_arm64.whl
Size 9.4 MB
Tags CPython 3.13 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
7d768436dd2ef1cc6050e5e3f731b42e10937b0b2ab5dea46dc85f7b9eda9ee3
BLAKE2b-256 checksum
How to use checksums
17a3b12264587ece570cf2db612313902c2afc5b1b4b1e035e59e35a9ddcf2e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / aihwkit-1.2.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL aihwkit-1.2.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 13.8 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
69d2088e08dd66625cbc0f307438f205c9bf47320d43d6d44c592ec47c7af340
BLAKE2b-256 checksum
How to use checksums
0dfb479ed289336609bb77a873e4c6a0072c0ad547efb9f41701c76acaf00bea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / aihwkit-1.2.0-cp312-cp312-macosx_26_0_arm64.whl

Download URL aihwkit-1.2.0-cp312-cp312-macosx_26_0_arm64.whl
Size 9.4 MB
Tags CPython 3.12 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
e01ccb786fc33fa09d882733f20b196304ace3a5143ae8ee9f9e6b1ed389a1bb
BLAKE2b-256 checksum
How to use checksums
2987f89dcef8d47930a02336e0ddd909f4a004372c25811dd80a59ed40528173
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Security for aihwkit 1.2.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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page