meybe it’s because of this part.



 mv15885:

state[:,self.qubits] = torch.matmul(self.U, state[:,self.qubits])


you are doing some inplace operation.
try re-writing it somehow with torch.cat or other function .