Hi,
Well it depends where your dispatch key is wrt to the autograd one. If it is below, then the autograd will be taken care of before getting to your code.
Also note that xla is out of tree and doing something similar (shouldn’t) doesn’t require changing core torch. You can use for example PrivateUse1 that is especially design to allow users to have their own backend.