Could you post your custom autograd.Function, the input shapes, and the code you’ve used to profile it?
If using model.train() changes the speed of your Function, I assume it’s using different code paths via the internal self.training attribute?