Skip to content

[AOTI] Wire torch.cond and torch.while_loop into AOTI dual-wrapper - #184736

Closed
desertfire wants to merge 13 commits into
gh/desertfire/733/basefrom
gh/desertfire/733/head
Closed

desertfire wants to merge 13 commits into
gh/desertfire/733/basefrom
gh/desertfire/733/head

Conversation

@desertfire

@desertfire desertfire commented May 21, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Emit cond and while_loop as DualWrapperCodeLine entries so the dual-wrapper codegen can route the predicate-guarded body to the AOTI side while running the JIT first pass through both branches (cond) or both subgraphs once (while_loop) for lazy autotune. Introduce _preserve_codegen_state and _preserve_device_guard_state so wrapper bookkeeping is restored between the JIT and AOTI passes over the same subgraphs.

Update test_cond_with_replace_view_ops to use aoti_compile_and_package, and drop the cond/while_loop skips from AOTInductorTestDualWrapper now that the dual-wrapper path supports them.

Authored with Codex.

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

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented May 21, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 1 New Failure, 2 Unrelated Failures

As of commit d22ec00 with merge base dc833a2 (image):

NEW FAILURE - The following job has failed:

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.

[ghstack-poisoned]
desertfire added a commit that referenced this pull request May 21, 2026
Emit cond and while_loop as DualWrapperCodeLine entries so the dual-wrapper codegen can route the predicate-guarded body to the AOTI side while running the JIT first pass through both branches (cond) or both subgraphs once (while_loop) for lazy autotune. Introduce _preserve_codegen_state and _preserve_device_guard_state so wrapper bookkeeping is restored between the JIT and AOTI passes over the same subgraphs.

Update test_cond_with_replace_view_ops to use aoti_compile_and_package, and drop the cond/while_loop skips from AOTInductorTestDualWrapper now that the dual-wrapper path supports them.

Authored with Codex.


ghstack-source-id: c01167c
Pull-Request: #184736
[ghstack-poisoned]
desertfire added a commit that referenced this pull request May 22, 2026
Emit cond and while_loop as DualWrapperCodeLine entries so the dual-wrapper codegen can route the predicate-guarded body to the AOTI side while running the JIT first pass through both branches (cond) or both subgraphs once (while_loop) for lazy autotune. Introduce _preserve_codegen_state and _preserve_device_guard_state so wrapper bookkeeping is restored between the JIT and AOTI passes over the same subgraphs.

Update test_cond_with_replace_view_ops to use aoti_compile_and_package, and drop the cond/while_loop skips from AOTInductorTestDualWrapper now that the dual-wrapper path supports them.

Authored with Codex.


ghstack-source-id: 3d51720
Pull-Request: #184736
[ghstack-poisoned]
desertfire added a commit that referenced this pull request May 27, 2026
Emit cond and while_loop as DualWrapperCodeLine entries so the dual-wrapper codegen can route the predicate-guarded body to the AOTI side while running the JIT first pass through both branches (cond) or both subgraphs once (while_loop) for lazy autotune. Introduce _preserve_codegen_state and _preserve_device_guard_state so wrapper bookkeeping is restored between the JIT and AOTI passes over the same subgraphs.

Update test_cond_with_replace_view_ops to use aoti_compile_and_package, and drop the cond/while_loop skips from AOTInductorTestDualWrapper now that the dual-wrapper path supports them.

Authored with Codex.


ghstack-source-id: 8e27899
Pull-Request: #184736
desertfire added a commit that referenced this pull request May 27, 2026
Emit cond and while_loop as DualWrapperCodeLine entries so the dual-wrapper codegen can route the predicate-guarded body to the AOTI side while running the JIT first pass through both branches (cond) or both subgraphs once (while_loop) for lazy autotune. Introduce _preserve_codegen_state and _preserve_device_guard_state so wrapper bookkeeping is restored between the JIT and AOTI passes over the same subgraphs.

Update test_cond_with_replace_view_ops to use aoti_compile_and_package, and drop the cond/while_loop skips from AOTInductorTestDualWrapper now that the dual-wrapper path supports them.

Authored with Codex.


ghstack-source-id: 8e27899
Pull-Request: #184736
desertfire added a commit that referenced this pull request May 27, 2026
Emit cond and while_loop as DualWrapperCodeLine entries so the dual-wrapper codegen can route the predicate-guarded body to the AOTI side while running the JIT first pass through both branches (cond) or both subgraphs once (while_loop) for lazy autotune. Introduce _preserve_codegen_state and _preserve_device_guard_state so wrapper bookkeeping is restored between the JIT and AOTI passes over the same subgraphs.

Update test_cond_with_replace_view_ops to use aoti_compile_and_package, and drop the cond/while_loop skips from AOTInductorTestDualWrapper now that the dual-wrapper path supports them.

Authored with Codex.


ghstack-source-id: 8e27899
Pull-Request: #184736
[ghstack-poisoned]
desertfire added a commit that referenced this pull request May 27, 2026
Emit cond and while_loop as DualWrapperCodeLine entries so the dual-wrapper codegen can route the predicate-guarded body to the AOTI side while running the JIT first pass through both branches (cond) or both subgraphs once (while_loop) for lazy autotune. Introduce _preserve_codegen_state and _preserve_device_guard_state so wrapper bookkeeping is restored between the JIT and AOTI passes over the same subgraphs.

Update test_cond_with_replace_view_ops to use aoti_compile_and_package, and drop the cond/while_loop skips from AOTInductorTestDualWrapper now that the dual-wrapper path supports them.

Authored with Codex.


ghstack-source-id: 3a612f8
Pull-Request: #184736
[ghstack-poisoned]
desertfire added a commit that referenced this pull request May 27, 2026
Emit cond and while_loop as DualWrapperCodeLine entries so the dual-wrapper codegen can route the predicate-guarded body to the AOTI side while running the JIT first pass through both branches (cond) or both subgraphs once (while_loop) for lazy autotune. Introduce _preserve_codegen_state and _preserve_device_guard_state so wrapper bookkeeping is restored between the JIT and AOTI passes over the same subgraphs.

Update test_cond_with_replace_view_ops to use aoti_compile_and_package, and drop the cond/while_loop skips from AOTInductorTestDualWrapper now that the dual-wrapper path supports them.

Authored with Codex.


ghstack-source-id: 1647e89
Pull-Request: #184736
[ghstack-poisoned]
desertfire added a commit that referenced this pull request May 28, 2026
Emit cond and while_loop as DualWrapperCodeLine entries so the dual-wrapper codegen can route the predicate-guarded body to the AOTI side while running the JIT first pass through both branches (cond) or both subgraphs once (while_loop) for lazy autotune. Introduce _preserve_codegen_state and _preserve_device_guard_state so wrapper bookkeeping is restored between the JIT and AOTI passes over the same subgraphs.

Update test_cond_with_replace_view_ops to use aoti_compile_and_package, and drop the cond/while_loop skips from AOTInductorTestDualWrapper now that the dual-wrapper path supports them.

Authored with Codex.

ghstack-source-id: 57d7146
Pull-Request: #184736
@desertfire
desertfire requested a review from yushangdi May 29, 2026 19:28
[ghstack-poisoned]
desertfire added a commit that referenced this pull request Jun 8, 2026
Emit cond and while_loop as DualWrapperCodeLine entries so the dual-wrapper codegen can route the predicate-guarded body to the AOTI side while running the JIT first pass through both branches (cond) or both subgraphs once (while_loop) for lazy autotune. Introduce _preserve_codegen_state and _preserve_device_guard_state so wrapper bookkeeping is restored between the JIT and AOTI passes over the same subgraphs.

Update test_cond_with_replace_view_ops to use aoti_compile_and_package, and drop the cond/while_loop skips from AOTInductorTestDualWrapper now that the dual-wrapper path supports them.

Authored with Codex.

ghstack-source-id: 41af2f4
Pull-Request: #184736
[ghstack-poisoned]
desertfire added a commit that referenced this pull request Jun 8, 2026
Emit cond and while_loop as DualWrapperCodeLine entries so the dual-wrapper codegen can route the predicate-guarded body to the AOTI side while running the JIT first pass through both branches (cond) or both subgraphs once (while_loop) for lazy autotune. Introduce _preserve_codegen_state and _preserve_device_guard_state so wrapper bookkeeping is restored between the JIT and AOTI passes over the same subgraphs.

Update test_cond_with_replace_view_ops to use aoti_compile_and_package, and drop the cond/while_loop skips from AOTInductorTestDualWrapper now that the dual-wrapper path supports them.

Authored with Codex.

ghstack-source-id: f136b48
Pull-Request: #184736
@desertfire

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Jun 9, 2026
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: 1 jobs have failed, first few of them are: torchtitan-test / torchtitan-x-pytorch-test / test-osdc (torchtitan_features_integration, 1, 1, mt-l-x86aavx2-189-704-a10g-8)

Details for Dev Infra team Raised by workflow job

[ghstack-poisoned]
desertfire added a commit that referenced this pull request Jun 9, 2026
Emit cond and while_loop as DualWrapperCodeLine entries so the dual-wrapper codegen can route the predicate-guarded body to the AOTI side while running the JIT first pass through both branches (cond) or both subgraphs once (while_loop) for lazy autotune. Introduce _preserve_codegen_state and _preserve_device_guard_state so wrapper bookkeeping is restored between the JIT and AOTI passes over the same subgraphs.

Update test_cond_with_replace_view_ops to use aoti_compile_and_package, and drop the cond/while_loop skips from AOTInductorTestDualWrapper now that the dual-wrapper path supports them.

Authored with Codex.

ghstack-source-id: 12172ae
Pull-Request: #184736
[ghstack-poisoned]
desertfire added a commit that referenced this pull request Jun 9, 2026
Emit cond and while_loop as DualWrapperCodeLine entries so the dual-wrapper codegen can route the predicate-guarded body to the AOTI side while running the JIT first pass through both branches (cond) or both subgraphs once (while_loop) for lazy autotune. Introduce _preserve_codegen_state and _preserve_device_guard_state so wrapper bookkeeping is restored between the JIT and AOTI passes over the same subgraphs.

Update test_cond_with_replace_view_ops to use aoti_compile_and_package, and drop the cond/while_loop skips from AOTInductorTestDualWrapper now that the dual-wrapper path supports them.

Authored with Codex.

ghstack-source-id: 9ec7d44
Pull-Request: #184736
[ghstack-poisoned]
desertfire added a commit that referenced this pull request Jun 10, 2026
Emit cond and while_loop as DualWrapperCodeLine entries so the dual-wrapper codegen can route the predicate-guarded body to the AOTI side while running the JIT first pass through both branches (cond) or both subgraphs once (while_loop) for lazy autotune. Introduce _preserve_codegen_state and _preserve_device_guard_state so wrapper bookkeeping is restored between the JIT and AOTI passes over the same subgraphs.

Update test_cond_with_replace_view_ops to use aoti_compile_and_package, and drop the cond/while_loop skips from AOTInductorTestDualWrapper now that the dual-wrapper path supports them.

Authored with Codex.

ghstack-source-id: c3bda86
Pull-Request: #184736
[ghstack-poisoned]
desertfire added a commit that referenced this pull request Jun 10, 2026
Emit cond and while_loop as DualWrapperCodeLine entries so the dual-wrapper codegen can route the predicate-guarded body to the AOTI side while running the JIT first pass through both branches (cond) or both subgraphs once (while_loop) for lazy autotune. Introduce _preserve_codegen_state and _preserve_device_guard_state so wrapper bookkeeping is restored between the JIT and AOTI passes over the same subgraphs.

Update test_cond_with_replace_view_ops to use aoti_compile_and_package, and drop the cond/while_loop skips from AOTInductorTestDualWrapper now that the dual-wrapper path supports them.

Authored with Codex.

ghstack-source-id: 762977e
Pull-Request: #184736
@desertfire

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge -i

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged while ignoring the following 3 checks: torchtitan-test / torchtitan-x-pytorch-test / test-osdc (torchtitan_features_integration, 1, 1, mt-l-x86aavx2-189-704-a10g-8), torchtitan-test / torchtitan-x-pytorch-test / test-osdc (torchtitan_models_integration, 1, 1, mt-l-x86aavx2-189-704-a10g-8), trunk / macos-py3-arm64 / test (mps, 1, 1, macos-m2-15)

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

jemitche1 pushed a commit to jemitche1/pytorch that referenced this pull request Jun 13, 2026
…ytorch#184736)

Emit cond and while_loop as DualWrapperCodeLine entries so the dual-wrapper codegen can route the predicate-guarded body to the AOTI side while running the JIT first pass through both branches (cond) or both subgraphs once (while_loop) for lazy autotune. Introduce _preserve_codegen_state and _preserve_device_guard_state so wrapper bookkeeping is restored between the JIT and AOTI passes over the same subgraphs.

Update test_cond_with_replace_view_ops to use aoti_compile_and_package, and drop the cond/while_loop skips from AOTInductorTestDualWrapper now that the dual-wrapper path supports them.

Authored with Codex.

Pull Request resolved: pytorch#184736
Approved by: https://github.com/yushangdi
ghstack dependencies: pytorch#184735
@github-actions
github-actions Bot deleted the gh/desertfire/733/head branch July 11, 2026 02:24
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
…ytorch#184736)

Emit cond and while_loop as DualWrapperCodeLine entries so the dual-wrapper codegen can route the predicate-guarded body to the AOTI side while running the JIT first pass through both branches (cond) or both subgraphs once (while_loop) for lazy autotune. Introduce _preserve_codegen_state and _preserve_device_guard_state so wrapper bookkeeping is restored between the JIT and AOTI passes over the same subgraphs.

Update test_cond_with_replace_view_ops to use aoti_compile_and_package, and drop the cond/while_loop skips from AOTInductorTestDualWrapper now that the dual-wrapper path supports them.

Authored with Codex.

Pull Request resolved: pytorch#184736
Approved by: https://github.com/yushangdi
ghstack dependencies: pytorch#184735
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…ytorch#184736)

Emit cond and while_loop as DualWrapperCodeLine entries so the dual-wrapper codegen can route the predicate-guarded body to the AOTI side while running the JIT first pass through both branches (cond) or both subgraphs once (while_loop) for lazy autotune. Introduce _preserve_codegen_state and _preserve_device_guard_state so wrapper bookkeeping is restored between the JIT and AOTI passes over the same subgraphs.

Update test_cond_with_replace_view_ops to use aoti_compile_and_package, and drop the cond/while_loop skips from AOTInductorTestDualWrapper now that the dual-wrapper path supports them.

Authored with Codex.

Pull Request resolved: pytorch#184736
Approved by: https://github.com/yushangdi
ghstack dependencies: pytorch#184735
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants