IBM / aihwkit

IBM Analog Hardware Acceleration Kit
https://aihwkit.readthedocs.io
MIT License
364 stars 148 forks source link

Functions to allow user defined hardware and noise parameters #329

Closed ElinorG11 closed 2 years ago

ElinorG11 commented 3 years ago

Hello,

First of all thank you for your great support. We really appreciate your professional and quick responses. We are trying to use the kit in order to simulate different hardware and noise parameters and check how they affect the accuracy of different network architectures we've trained.

For this purpose, we use the trained models and convert them to analog. We want to use the InferenceRPUConfig since we want to model the noise only at the inference stage. We're having trouble understanding what parameters exactly does the kit allows us to change? (noise and hardware) for example, we saw that we can change the DAC and ADC resolution by updating the rpu_config.

After reading very carefully through all your documentation, we are still a bit confused about what can be done apart from changing the parameters that are listed in IOParameter class and InferenceRPUConfig class. could you please refer us to more helpful functions which will allow us to control more hardware and noise features? (we're especially interested in changing a experimenting with the noise parameters)

Thank you.

maljoras commented 3 years ago

Hi @ElinorG11 , Thanks for your question. For analog inference, we have a set of parameters that define the strength of the noise / non-idealities of the each forward pass (the IOParameters as you pointed out). These prameters are freely adjustable to match your HW.

Moreover, to test for inference, our approach is to use statistical noise and drift models that are defined in InferenceRPUConfig.noise_model. This noise model can be selected, and parameters such as expected conductance dependent programming noise or drift variability and strength adjusted. Please take a look here for a PCM noise model.

If you expect different drift or programming noise, you can also implement your own noise model, e.g. we recently added a custom noise model. Here you could define whatever functional form you would expect for your HW by just writing a new python class.

The application of the noise model is simple during inference and has the following steps: 1) convert the DNN to analog (this will enable the cycle-to-cycle non-idealities in the forward pass mat-vec) 2) Use an existing noise model or write your own by inheriting from the base noise model. If you write your own, you can also specifiy a "conductance_converter" that converts the weight values to conductances. E.g. implementing multiple conductances per crosspoint (current is added in before ADC), see here 3) With the function program_analog_weights and drift_analog_weights the noise model / drift will be statically applied to the weights and then inference accuracy can be tested using the noisy weights as shown in the examples
4) Drift compensation can be enabled or you can also implement and invent new drift compensations, by again just inheriting from the base classes.

In this manner you can establish the expected accuracy after programming and waiting time.

So you have the full flexibility.

It would also be interesting to know what you actually trying to do in more detail. If the feature is not available one can always add a feature request if it is a function that is broadly applicable.

ElinorG11 commented 2 years ago

I'm very sorry for the late replay, thank you very much for you detailed answer! what we're trying to do is to use existing DNN (ResNet18, ResNet34, VGG16, Mobilenet) which were trained on CIFAR10\CIFAR100 dataset, and to test them on different harware configurations with different noise parameters so we can see how the accuracies change on the noisy model vs the ideal model basically to see how changing hardware parameters effects the influence the noise has on the accuracy of the networks during inference). That's why we were looking for different functions that will allow us to control hardware\noise params in your kit.