Skip to content

[make_fx] Handle torch.Generator in proxy tensor tracing and Inductor - #179649

Closed
aditvenk wants to merge 1 commit into
mainfrom
ps/rr/_make_fx__handle_torch_generator_in_proxy_tensor_tracing_and_inductor
Closed

aditvenk wants to merge 1 commit into
mainfrom
ps/rr/_make_fx__handle_torch_generator_in_proxy_tensor_tracing_and_inductor

Conversation

@aditvenk

@aditvenk aditvenk commented Apr 8, 2026 •

Copy link
Copy Markdown
Contributor

When a pre-partitioned AOT autograd forward graph containing graphsafe_run_with_rng_state is re-traced by make_fx (e.g. when torch.compile wraps an AutoParallel module), the Generator object passed as rng_state could not be serialized into the graph — create_arg raised NotImplementedError for torch._C.Generator.

Fix by hoisting Generator objects as module attributes (get_attr nodes) in PythonKeyTracer.create_arg, and teaching Inductor's get_attr handler to produce an ir.GeneratorState backed by torchbind_constants so the Generator is available as a module-level variable in the compiled code.

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo

@pytorch-bot

pytorch-bot Bot commented Apr 8, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/179649

Note: Links to docs will display an error until the docs builds have been completed.

❌ 4 New Failures, 4 Unrelated Failures

As of commit 0b25db7 with merge base a4a69be (image):

NEW FAILURES - The following jobs have failed:

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot Bot added ciflow/inductor ciflow/torchtitan Run TorchTitan integration tests module: inductor release notes: fx release notes category labels Apr 8, 2026
@aditvenk
aditvenk requested a review from xmfan April 8, 2026 00:22
When a pre-partitioned AOT autograd forward graph containing
graphsafe_run_with_rng_state is re-traced by make_fx (e.g. when
torch.compile wraps an AutoParallel module), the Generator object
passed as rng_state could not be serialized into the graph — create_arg
raised NotImplementedError for torch._C.Generator.

Fix by hoisting Generator objects as module attributes (get_attr nodes)
in PythonKeyTracer.create_arg, and teaching Inductor's get_attr handler
to produce an ir.GeneratorState backed by torchbind_constants so the
Generator is available as a module-level variable in the compiled code.

<!-- ps-id: d542629c-9c69-49bd-ac66-a6569e111771 -->
@aditvenk
aditvenk force-pushed the ps/rr/_make_fx__handle_torch_generator_in_proxy_tensor_tracing_and_inductor branch from d8524cf to 0b25db7 Compare April 8, 2026 00:31
aditvenk added a commit to meta-pytorch/autoparallel that referenced this pull request Apr 8, 2026
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 -->
aditvenk added a commit to meta-pytorch/autoparallel that referenced this pull request Apr 21, 2026
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 -->
aditvenk added a commit to meta-pytorch/autoparallel that referenced this pull request Apr 21, 2026
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 -->
aditvenk added a commit to meta-pytorch/autoparallel that referenced this pull request Apr 21, 2026
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 -->
aditvenk added a commit to meta-pytorch/autoparallel that referenced this pull request Apr 21, 2026
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 -->
aditvenk added a commit to meta-pytorch/autoparallel that referenced this pull request Apr 21, 2026
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 -->
@aditvenk aditvenk closed this Apr 21, 2026
aditvenk added a commit to meta-pytorch/autoparallel that referenced this pull request Apr 22, 2026
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 -->
aditvenk added a commit to meta-pytorch/autoparallel that referenced this pull request Apr 22, 2026
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 -->
aditvenk added a commit to meta-pytorch/autoparallel that referenced this pull request Apr 22, 2026
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 -->
aditvenk added a commit to meta-pytorch/autoparallel that referenced this pull request Apr 23, 2026
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 -->
aditvenk added a commit to meta-pytorch/autoparallel that referenced this pull request Apr 24, 2026
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 -->
aditvenk added a commit to meta-pytorch/autoparallel that referenced this pull request Apr 25, 2026
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 -->
aditvenk added a commit to meta-pytorch/autoparallel that referenced this pull request Apr 27, 2026
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 -->
aditvenk added a commit to meta-pytorch/autoparallel that referenced this pull request Apr 27, 2026
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 -->
aditvenk added a commit to meta-pytorch/autoparallel that referenced this pull request Apr 27, 2026
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 -->
aditvenk added a commit to meta-pytorch/autoparallel that referenced this pull request Apr 27, 2026
…PI (#415)

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 -->
@github-actions
github-actions Bot deleted the ps/rr/_make_fx__handle_torch_generator_in_proxy_tensor_tracing_and_inductor branch May 22, 2026 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/inductor ciflow/torchtitan Run TorchTitan integration tests module: inductor release notes: fx release notes category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant