Skip to content

[graph_trainer] Add direct full-Inductor compile pass - #4222

Merged
IvanKobzarev merged 1 commit into
mainfrom
rigi-gt-direct-full-inductor
Aug 21, 2026
Merged

IvanKobzarev merged 1 commit into
mainfrom
rigi-gt-direct-full-inductor

Conversation

@IvanKobzarev

Copy link
Copy Markdown
Contributor
  1. Expose full inductor configs to override the inductor configs

  2. extract _get_fake_mode_from_gm to be reusable from regional_inductor_pass

  3. Adding direct_full_inductor_compilation_pass to bypass regional inductor pass to save compilation time (vs dynamo)
    when user needs just inductor compilation.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 19, 2026
@IvanKobzarev
IvanKobzarev marked this pull request as ready for review August 19, 2026 16:52
@IvanKobzarev
IvanKobzarev force-pushed the rigi-gt-direct-full-inductor branch from 80b478a to 7b70db4 Compare August 19, 2026 17:47
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."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain the problems you run into with full regional inductor ?

This pass will make it incompatible with precompile... cc @bobrenjc93

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@IvanKobzarev IvanKobzarev Aug 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
```
@IvanKobzarev
IvanKobzarev force-pushed the rigi-gt-direct-full-inductor branch from 7b70db4 to 51aff79 Compare August 20, 2026 12:06

@SherlockNoMad SherlockNoMad left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's just replace full_inductor_compilation 's old impl with the new one.

@IvanKobzarev
IvanKobzarev merged commit 00de9f6 into main Aug 21, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants