albanD:

The current results on google colab are:



Have you tried commenting return None, None, None in backward? If I comment it, nn.Linear is always faster than MyLinear on my machine and on Colab as well.
I tried to run the script multiple times with n=10000, the figures change from time to time, but the result of comparison is always the same.