I haven’t tested it, but manipulating the .data attribute might have weird side effects and is not recommended.
Could you instead warp the pruning into a torch.no_grad() block and reassign the pruned parameters?