Where's the backpropagation code?

I’m working on a project which requires me to rewrite the implementation of backpropagation, so I’d like to modify the current implementation of pytorch backprop. I took a look at the source code and found that it uses:

 Variable._execution_engine.run_backward(  # Calls into the C++ engine to run the backward pass...

However I’m stuck here as I can’t seem to find where this function is defined. Anyone know where the code for backprop is?

Also, is this recommended? Would modifying backprop cause a lot of issues for regular gpu training (doesn’t need to work for distributed cases)?

run_backward is defined here for the C++ backend and here for the Python frontend.

Yes, modifying internals could cause a lot of issues, but it depends on your actual use case in the end and what you are trying to achieve.