It is expected that it only affects parameters - things you optimize are considered model parameters. Not sure what’s your exact use case, but as @smth pointed out, you can just iterate over the other Variables and zero the gradients yourself.