Hi @ptrblck,
During the process of creating a standalone script, I found the error and it truly is bizarre. The problem emerges from the file Samplers.py. It’s effectively a module that uses a Network to calculate input data in accordance to a given probability by utilizing the Metropolis-Hastings algorithm and a random walk.
In short, and to add some context, it generates input data for my Feed-Forward Neural Network (Which is an R^N → R^1 function) by creating input data which is distributed to the output of the network squared.
input_data, acceptance  = Sampler(10) #10 steps of Metropolis-Hastings (input_data is shape [B,N])
                                      #input_data is distributed according to net(input_data).pow(2)

output = net(input_data) #my R^N -> R^1 function 

The line of code that caused the crash is shown below,
  @torch.no_grad()
  def forward(self, burn_in: int) -> Tuple[Tensor, Tensor]:
    self.acceptance.zero_()
    
    for i in range(burn_in+1): #check +1 here
      self.step()
    #return self.chains.detach_().requires_grad_(), self.acceptance.detach_() #crashes
    return self.chains.detach_(), self.acceptance.detach_() #doesn't crash

I called requires_grad_() on the data that’s returned from the Sampler as I need a gradient for it within my loss function. I do enable requires_grad_() within my loss function to check it’s enabled, so I can remove requires_grad_() within the Sampler and still calculate my loss. But to me it seems weird that this usage causes such a weird error.
Thank you!