Repository navigation
[graph_trainer] Add direct full-Inductor compile pass - #4222
Conversation
80b478a to
7b70db4
Compare
| def direct_full_inductor_compilation_pass( | ||
| gm: torch.fx.GraphModule, example_inputs: tuple, *, inductor_configs=None | ||
| ) -> torch.fx.GraphModule: | ||
| """Compile the whole graph with Inductor without regional outlining.""" |
There was a problem hiding this comment.
Can you explain the problems you run into with full regional inductor ?
This pass will make it incompatible with precompile... cc @bobrenjc93
There was a problem hiding this comment.
we should have some doc string to explain when to use "direct_full_inductor_compilation_pass" vs. "full_inductor_compilation_pass".
and the limitation of both passes...
but I still don't fully understand the problem of full_inductor_compilation_pass, ideally we should just have one full inductor pass.
There was a problem hiding this comment.
The main problem was the compile time - the regional inductor processing regressed medium sized model full graph processing +50+% in comparison to default torch.compile, which was unacceptable for users of torch.compile to migrate on graph_trainer.
If the user wants just full inductor compilation - we do not need any processing of meta of the regions etc.
This direct similar to just inductor compilation on full graph removed most of overhead.
I tested precompile - everything works. Added test for precompile.
There was a problem hiding this comment.
ok, if precompile works, then we can just remove the original full_inductor_compilation pass.
Full-graph compilation through regional_inductor spends time discovering and processing a region whose boundary is already known. Add a terminal pass that compiles the complete FX graph with one standalone_compile invocation, prunes unused placeholders while preserving the caller signature, and remains serializable by GraphTrainer precompile.
Thread explicit Inductor configs through the full-graph paths while preserving peak-memory reorder behavior.
Authored with assistance from Codex (AI assistant).
Test Plan:
```bash
LD_LIBRARY_PATH=/home/ivankobzarev/local/d/pytorch-env/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} pytest -q torchtitan/experiments/graph_trainer/tests/test_precompile.py torchtitan/experiments/graph_trainer/tests/test_passes.py::TestStandaloneInductorCompilationPass
pre-commit run --all-files
```
7b70db4 to
51aff79
Compare
SherlockNoMad
left a comment
There was a problem hiding this comment.
let's just replace full_inductor_compilation 's old impl with the new one.
Expose full inductor configs to override the inductor configs
extract _get_fake_mode_from_gm to be reusable from regional_inductor_pass
Adding direct_full_inductor_compilation_pass to bypass regional inductor pass to save compilation time (vs dynamo)
when user needs just inductor compilation.