In general, it should never  In some limited cases, it might work, but this is not guaranteed.
Also your forward function is missing a call to mark_dirty(). See the doc 3 about extending the autograd.