I’ll have to admit that the bernoulli API is more than a little bit awkward (it should be a factory function just like randn, really), but
mask = torch.bernoulli(torch.randn(1, 1, device='cuda').expand(*weight.shape), 1-drop_prob)

should work.
Best regards
Thomas