Skip to content

[AOTI] Support mixed-device constants - #169504

Closed
desertfire wants to merge 2 commits into
gh/desertfire/616/basefrom
gh/desertfire/616/head
Closed

desertfire wants to merge 2 commits into
gh/desertfire/616/basefrom
gh/desertfire/616/head

Conversation

@desertfire

@desertfire desertfire commented Dec 3, 2025 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Summary: CUDA models can also contain constants (e.g. buffers) as CPU tensors. Currently AOTI doesn't consider this use case and blindly loads all weights to a single device. This PR adds the support by allowing loading constants to either the model device or CPU depending on the device type emitted at the compile time. This will become handy if we want to keep torch.cond's predicate on CPU.

Weight update is not touched in this PR. It will come next.

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

Summary: CUDA models can also contain constants (e.g. buffers) as CPU tensors. Currently AOTI doesn't consider this use case and blindly loads all weights to a single device. This PR adds the support by allowing loading constants to either the model device or CPU depending on the device type emitted at the compile time. This will become handy if we want to keep torch.cond's predicate on CPU.

Weight update is not touched in this PR. It will come next.

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Dec 3, 2025 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

⏳ No Failures, 3 Pending

As of commit 244f33f with merge base 76b8fda (image):
💚 Looks good so far! There are no failures yet. 💚

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

desertfire added a commit that referenced this pull request Dec 3, 2025
Summary: CUDA models can also contain constants (e.g. buffers) as CPU tensors. Currently AOTI doesn't consider this use case and blindly loads all weights to a single device. This PR adds the support by allowing loading constants to either the model device or CPU depending on the device type emitted at the compile time. This will become handy if we want to keep torch.cond's predicate on CPU.

Weight update is not touched in this PR. It will come next.

ghstack-source-id: 628b447
Pull Request resolved: #169504
@desertfire
desertfire requested a review from muchulee8 December 5, 2025 01:09
Summary: CUDA models can also contain constants (e.g. buffers) as CPU tensors. Currently AOTI doesn't consider this use case and blindly loads all weights to a single device. This PR adds the support by allowing loading constants to either the model device or CPU depending on the device type emitted at the compile time. This will become handy if we want to keep torch.cond's predicate on CPU.

Weight update is not touched in this PR. It will come next.

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

[ghstack-poisoned]
desertfire added a commit that referenced this pull request Dec 10, 2025
Summary: CUDA models can also contain constants (e.g. buffers) as CPU tensors. Currently AOTI doesn't consider this use case and blindly loads all weights to a single device. This PR adds the support by allowing loading constants to either the model device or CPU depending on the device type emitted at the compile time. This will become handy if we want to keep torch.cond's predicate on CPU.

Weight update is not touched in this PR. It will come next.

ghstack-source-id: 544f504
Pull Request resolved: #169504
@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 Dec 10, 2025
@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

The merge job was canceled or timed out. This most often happen if two merge requests were issued for the same PR, or if merge job was waiting for more than 6 hours for tests to finish. In later case, please do not hesitate to reissue the merge command
For more information see pytorch-bot wiki.

@desertfire

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge -f "skip stuck rocm CI jobs"

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants