Issue with Applying Drift During Inference Phase in AIHWKit #672
-
Dear AIHWKit Team, I am currently working on a project where I need to apply a custom drift function during the training phase while avoiding the standard PCM noise model drift function only (while other noise type work normall). However, during the inference phase, I want to use the standard PCM noise model and allow all functions to work as intended. Despite my efforts, the drift does not seem to be applied correctly during the inference phase. Here is a brief overview of my approach and the problem I am encountering: Custom Drift Function During Training: I have implemented a custom drift function in a subclass of PCMLikeNoiseModel that disables drift during training while allowing other PCM noise model functionalities, such as programming and read noise, to work as standard. The relevant code for the custom noise model and RPU configuration is as follows:
Standard PCM Noise Model During Training and Inference: Training RPU Configuration:
standard PCMLikeNoiseModel for Inference RPU Configuration:. The RPU configuration for inference is as follows:
Problem: Inference Phase Code:
Could you please advise on how to ensure that the drift is correctly applied during the inference phase while avoiding it in the training phase? Any guidance or suggestions would be greatly appreciated. Thank you for your assistance. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Note that the drift model is never applied during training, so there is no need to have a flag. It will be only used for inference time. It is not clear from the above how the modified rpu_config is applied after training was done, before the inferfence. Is the model recreated while using the new rpu_config? There is a special flag to change the rpu_config during loading, otherwise the old rpu_config will be taken that is stored in the state_dict. You can also use the Also, there is a simpler form to apply the drift for the while model, simple use In this section, you should call weights_before_drift, _ = layer.get_weights()
print(f'Weights before drift for layer {idx} at t={t_inference}: {weights_before_drift}')
drift_analog_weights(tile, t_inference)
weights_after_drift, _ = layer.get_weights() |
Beta Was this translation helpful? Give feedback.
-
@adnanrana88 are you able to solve your problem/doubts? Do you need any further help or we can close this discussion? Thanks! |
Beta Was this translation helpful? Give feedback.
Note that the drift model is never applied during training, so there is no need to have a flag. It will be only used for inference time.
It is not clear from the above how the modified rpu_config is applied after training was done, before the inferfence. Is the model recreated while using the new rpu_config? There is a special flag to change the rpu_config during loading, otherwise the old rpu_config will be taken that is stored in the state_dict. You can also use the
model.to(new_rpu_config)
to change the model to the new rpu_config. However, it is even easier if you just setinclude_drift=True
always, as drift will never be called during training. In this case, you do not have to change…