I see that the warning is pointing to the exact function I pointed
Warning: Error detected in LogBackward. Traceback of forward call that caused the error:
  File "train.py", line 339, in <module>
    main(args)
  File "train.py", line 133, in main
    train_joint
  File "train.py", line 202, in train
    p, planlogits = graph_model(batch)
  File "~/anaconda3/envs/torch-sci/lib/python3.6/site-packages/torch/nn/modules/module.py", line 550, in __call__
    result = self.forward(*input, **kwargs)
  File "~/torch-sci/GraphWriter/models/newmodel.py", line 167, in forward
    return o.log(),planlogits

However, I tried to remove the faulty log function but I got this instead. Do you think it’s a cascaded error coming somehow from a different module?
RuntimeError: Function 'MulBackward0' returned nan values in its 0th output.

As a note, I printed the min o value before clamping and I see it even received the NaN value even before passing to the log function.