Inductor file structure explanation

Could someone please explain the file structure and/or the classes involved in the Inductor module at the inductor codebase?

I have gathered the general idea of what inductor does, now I need to understand how it does that!

Found a relevant post: What should we do about developer documentation?

Also, my question is on the similar lines as How to read the autograd codebase, albeit I was hoping for a source code deep dive!

So here is my preliminary attempt to use a codebase mapper to understand Inductor:

In that, I can focus on how the codebase is connected for (perhaps) C++ codegen like this:

So, this is in no way conclusive, but, I am still exploring. If only I could request @jansel to help with the source code understanding!

I think the best way to understand this codebase (or any, for the matter) is to drop a few breakpoints, run a program, and look at the backtrace when they are hit. Rinse and repeat.

1 Like

The PyTorch 2 paper has some more details about how inductor works. Contributions are also very welcome to help improve documentation.

1 Like

@jansel thank you for sharing the paper. I will try to continue preparing a record of my understanding and share it here.

@Lezcano I am currently following the approach (debug mode step through) that you have suggested, it is just that it is a bit tedious while not entirely revealing the implementation decisions.

It is true that the dev docs are very much lacking. As @jansel mentioned, we would very much accept some contributions, for example in the form of README.mds in the relevant folders.

When it comes to design decisions, it’s always useful to dig up the history of the relevant lines via git blame and have a look at the PRs that led to those lines.

1 Like

@Lezcano where as I am working on developing an understanding of the source code, I think, there is a contradiction - developer docs are to be created by the developer, for other (potential newcomer) developers!

Note to self:

“Code is more often read than written.”
— Guido van Rossum