Is it okay if they are not permutation (I can still recover the permutation matix via torch.lu_unpack)? @vishwakftw, do you know if it’s fine? The final result is still correct.
import torch                               
                                           
a = torch.Tensor([                         
  [-1.0357,  1.7709, -0.3924,  0.0632],    
  [-0.0573, -1.9293, -0.7089, -0.8931],    
  [-2.0286,  0.4177, -1.6017,  0.2191],    
  [ 0.9666, -0.7376,  0.6699,  1.1101]]    
)                                                        
q = a.qr().Q                               
LU, P = a.lu()                             
print(P) # tensor([3, 2, 3, 4], dtype=torch.int32)