What is update_indexed and when should we use it? #548
-
I'm trying to implement new optimization algorithms with aihwkit, but I got a little confused on the original implementation of the native optimizer. I noticed in the if analog_ctx.use_indexed:
for x_input, d_input in zip(
analog_ctx.analog_input, analog_ctx.analog_grad_output
):
analog_tile.update_indexed(x_input, d_input)
else:
x_input = cat(
analog_ctx.analog_input, axis=-1 if analog_tile.in_trans else 0
)
d_input = cat(
analog_ctx.analog_grad_output, axis=-1 if analog_tile.out_trans else 0
)
analog_tile.update(x_input, d_input) I have read the documents and there is no related material to explain the difference between these two methods. I wonder
I would appreciate it if somebody could solve my confusion. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
In general, this is internal code and the user should not worry about that unless you want to implement your own update functionality. Just leave it as it is, typically the That said, the functionality of the indexed update is internal C++ code that is optimized, as it avoids the "unfold" operation for the convolution internally by accessing the input tensor with indices. This uses less memory typically and is faster in certain cases (for 2D convs). However, for smaller DNNs and modern GPUs the difference is not large so either version can be used. However, for 1D and 3D convolutions are not supported by torch's If you want to avoid overriding the indexed version for a custom tile for conv2d, you can set the In general the code you are showing is from the optimizer. I would advise against editing or changing anything there since this makes the non-torch custom update functionality possible, you might just break everything if you do adapt it. Note that for in-memory training the update is changed to using stochastic pulse trains for instance. The |
Beta Was this translation helpful? Give feedback.
In general, this is internal code and the user should not worry about that unless you want to implement your own update functionality. Just leave it as it is, typically the
use_indexed
input argument is just for internal use and debugging.That said, the functionality of the indexed update is internal C++ code that is optimized, as it avoids the "unfold" operation for the convolution internally by accessing the input tensor with indices. This uses less memory typically and is faster in certain cases (for 2D convs). However, for smaller DNNs and modern GPUs the difference is not large so either version can be used. However, for 1D and 3D convolutions are not supported by torch's
unfold
fun…