# How to understand PyTorch's source code

**URL:** <https://discuss.pytorch.org/t/how-to-understand-pytorchs-source-code/7600>\
**Category:** Uncategorized\
**Created:** [September 19, 2017, 9:16pm UTC](https://discuss.pytorch.org/t/how-to-understand-pytorchs-source-code/7600 "2017-09-19T21:16:32Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![smth](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/smth/32/13_2.png) [@smth](https://discuss.pytorch.org/u/smth)\
**Post date:** [September 20, 2017, 4:27am UTC](https://discuss.pytorch.org/t/how-to-understand-pytorchs-source-code/7600/2 "2017-09-20T04:27:51Z")

</div>

These two posts will help get through the code structure and build system:

[http://pytorch.org/2017/05/11/Internals.html](http://pytorch.org/2017/05/11/Internals.html)

[http://pytorch.org/2017/06/27/Internals2.html](http://pytorch.org/2017/06/27/Internals2.html)

It doesn’t touch the autograd system though.  
The autograd system is moved into C now, and is multi-threaded, so stepping through the python debugger is probably a bit pointless.

Here’s a pointer to very old source code, where all the logic was in Python, in the early days of PyTorch. The logic is largely the same still, but moved into C.

> <https://github.com/pytorch/pytorch/blob/v0.1.1/torch/autograd/engine.py>

  

> <https://github.com/pytorch/pytorch/blob/v0.1.1/torch/autograd/function.py>

---

_[View the full topic](https://discuss.pytorch.org/t/how-to-understand-pytorchs-source-code/7600)._
