Solved by tom in post #2 
              
              
                I think you want ctx.mark_non_differentiable. 
It does not, however, spare you from taking a second grad_out argument in the backward even if it will be all zero (and indeed fully materialized at the moment): 
class MyFunction(torch.autograd.Function):
    @staticmethod
    def forward(ctx, inp):
  …