Hi,
Yes all of the factory functions like randn or ones are independent of the nn.Module device.
So in general, you want to provide a device= argument to these functions if you want the Tensor to be created on a special device.
You can get the right device from any param or input of your Module.
Also, if you want Tensor attributes to be moved along with the parameters, you should register them as “buffers” on the Module with self.register_buffer("q_transposed", the_tensor) which you can then access as self.q_transposed.
Side not in your code sample, there is not need to wrap the Tensor into a Parameter here. Parameter are only important when you assign them to a nn.Module.