Repository navigation
Deprecate compile, enable_ac, and numerics_logger from AutoParallel API - #415
Conversation
fa90f00 to
bf6bad8
Compare
a4d4fe1 to
3da4f5f
Compare
fmassa
left a comment
There was a problem hiding this comment.
Thanks for the PR @aditvenk !
Upon reviewing it, I remembered one of the blocker issues I had when working on this in the past, which unfortunately is not handled by this PR.
The problem is around maintaining user-specified AC regions in the second compilation (i.e., the external torch.compile).
In the current setting, AP's partitioner will be taking the user-specified AC regions into account during the fwd/bwd split. But during the second compilation, the joint graph will be the stitching between the fwd and the bwd+fwd recomputations, and the AC tags are not present anymore. Given that the joint graph will have redundant computations, the partitioner could actually decide to simplify the graph, which would remove the recomputation.
Do you agree with the issue?
|
Here is some discussion from Claude, discussing about the lack of AC propagation through the second recompilation. |
|
Actually, it might be that the issue I was mentioning isn't applicable, because even though the duplicate nodes might be CSE, the returned graph from AutoParallel seems to contain the original AC tags, which then get used by the second partitioner. So maybe everything works fine! I'm testing it out |
Pl let me know what you find out! |
3da4f5f to
b3e33a6
Compare
faa2706 to
71161b7
Compare
Make compilation a composable, downstream concern: users call
torch.compile() on the module AP returns, optionally using the new
inductor_config() context manager for AP-optimized passes (activation
checkpointing, overlap scheduling).
The key insight is that AP already partitions the joint graph into
fwd/bwd via aot_compile_joint_with_descriptors. The returned module's
forward() is a normal callable -- torch.compile() traces it with
Dynamo, AOTAutograd creates a fresh joint graph, and Inductor's
min-cut partitioner operates on that new graph (not AP's original).
AC recomputation tags (MUST_RECOMPUTE/MUST_SAVE from FSDP all-gather
tagging) are structural after AP's partitioner runs, so they survive
the torch.compile round-trip.
Changes to api.py:
- Remove compile, enable_ac, ac_stage_size_in_GiB, numerics_logger
parameters from AutoParallel.__init__
- Remove compile parameter from auto_parallel()
- Remove ac_joint_pass call from _apply_placement_common (moved to
inductor_config context manager)
- Run view_to_reshape unconditionally in _apply_placement_common
(previously only ran in the compile path; needed for eager too)
- Simplify _boxed_nop_preserve_node_meta to just an FX Interpreter
wrapper (remove view_to_reshape and overlap scheduling from it)
New file autoparallel/compile.py:
- inductor_config() context manager that sets torch._functorch.config
.joint_custom_pass for AC and torch._inductor.config
.aten_distributed_optimizations.* for overlap scheduling
- Exported from autoparallel.__init__
Examples that previously used compile=True now use:
with inductor_config():
parallel_mod = torch.compile(parallel_mod)
Tests that previously used compile=True are updated similarly.
Three obsolete tests in test_api.py (overlap scheduling under compile,
compile_true smoke test, inference-with-compile) are removed since
they tested the old in-AP compile path.
Depends on pytorch/pytorch#179649 which fixes torch.compile over
pre-partitioned AOTAutograd graphs containing
graphsafe_run_with_rng_state (from selective activation checkpointing).
<!-- ps-id: fb58a4ab-f887-4e79-bea8-56ae48f6f36f -->
71161b7 to
1b7d486
Compare
|
TorchTitan update in pytorch/torchtitan#3114 |
Update autoparallel experiments to match the new API from meta-pytorch/autoparallel#415 which removes the `compile` parameter from AutoParallel and replaces it with an explicit `torch.compile(model, backend=autoparallel_backend())` call. <!-- ps-id: 6002b76c-ab28-4486-be71-2fceec67c4d8 -->
Make compilation a composable, downstream concern: users call torch.compile() on the module AP returns, optionally using the new inductor_config() context manager for AP-optimized passes (activation checkpointing, overlap scheduling).
The key insight is that AP already partitions the joint graph into fwd/bwd via aot_compile_joint_with_descriptors. The returned module's forward() is a normal callable -- torch.compile() traces it with Dynamo, AOTAutograd creates a fresh joint graph, and Inductor's min-cut partitioner operates on that new graph (not AP's original). AC recomputation tags (MUST_RECOMPUTE/MUST_SAVE from FSDP all-gather tagging) are structural after AP's partitioner runs, so they survive the torch.compile round-trip.
Examples that previously used compile=True now use:
with inductor_config():
parallel_mod = torch.compile(parallel_mod)
Tests that previously used compile=True are updated similarly. Three obsolete tests in test_api.py (overlap scheduling under compile, compile_true smoke test, inference-with-compile) are removed since they tested the old in-AP compile path.
Depends on pytorch/pytorch#179649 which fixes torch.compile over pre-partitioned AOTAutograd graphs containing
graphsafe_run_with_rng_state (from selective activation checkpointing).