I don’t think this is a bug, because in
>>> with torch.no_grad(): 
...     z = x

You are not doing any computation, just referencing an existing object. As soon as you actually use that object, it will correctly set the “requires_grad” attribute to False, so there will never be an issue in practice of falsely computing a gradient in the “with” context.
If your goal is just to get a view of the tensor without gradient, use z = x.detach(). Or if you want to make a copy of it as well, use z = x.clone(). In both cases, .requires_grad will then be False. The with torch.no_grad() is more meant for handling actual computations.