Skip to content

[ET Device Support] PropagateDevicePass inserts H2D/D2H copy ops at delegate boundaries#18730

Open
Gasoonjia wants to merge 2 commits intogh/gasoonjia/160/basefrom
gh/gasoonjia/160/head
Open

[ET Device Support] PropagateDevicePass inserts H2D/D2H copy ops at delegate boundaries#18730
Gasoonjia wants to merge 2 commits intogh/gasoonjia/160/basefrom
gh/gasoonjia/160/head

Conversation

@Gasoonjia
Copy link
Copy Markdown
Contributor

@Gasoonjia Gasoonjia commented Apr 6, 2026

Stack from ghstack (oldest at bottom):

Extend PropagateDevicePass to insert explicit et_copy._h2d_copy and
et_copy._d2h_copy ops at delegate boundaries, making the graph functional
by explicitly transferring data between CPU and device memory.

Key changes:

  • Inserts _h2d_copy before each delegate input, _d2h_copy after each output
  • Original input nodes stay CPU; h2d_copy output tagged as device
  • Getitem nodes inherit device; d2h_copy output tagged as CPU
  • Skip-copy optimizations via skip_h2d_for_method_inputs/skip_d2h_for_method_outputs
  • _parse_device_spec_value: lowercases string, raises ValueError for unknown types
  • _program.py passes config flags to PropagateDevicePass constructor

Differential Revision: D99636777

…elegate boundaries

Extend PropagateDevicePass to insert explicit et_copy._h2d_copy and
et_copy._d2h_copy ops at delegate boundaries, making the graph functional
by explicitly transferring data between CPU and device memory.

Key changes:
- Inserts _h2d_copy before each delegate input, _d2h_copy after each output
- Original input nodes stay CPU; h2d_copy output tagged as device
- Getitem nodes inherit device; d2h_copy output tagged as CPU
- Skip-copy optimizations via skip_h2d_for_method_inputs/skip_d2h_for_method_outputs
- _parse_device_spec_value: lowercases string, raises ValueError for unknown types
- _program.py passes config flags to PropagateDevicePass constructor

Differential Revision: [D99636777](https://our.internmc.facebook.com/intern/diff/D99636777/)

[ghstack-poisoned]
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 6, 2026
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot bot commented Apr 6, 2026

🔗 Helpful Links

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

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

❌ 65 New Failures

As of commit 4b48ed3 with merge base b5ae0b9 (image):

NEW FAILURES - The following jobs have failed:

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

Gasoonjia added a commit that referenced this pull request Apr 6, 2026
…elegate boundaries

Extend PropagateDevicePass to insert explicit et_copy._h2d_copy and
et_copy._d2h_copy ops at delegate boundaries, making the graph functional
by explicitly transferring data between CPU and device memory.

Key changes:
- Inserts _h2d_copy before each delegate input, _d2h_copy after each output
- Original input nodes stay CPU; h2d_copy output tagged as device
- Getitem nodes inherit device; d2h_copy output tagged as CPU
- Skip-copy optimizations via skip_h2d_for_method_inputs/skip_d2h_for_method_outputs
- _parse_device_spec_value: lowercases string, raises ValueError for unknown types
- _program.py passes config flags to PropagateDevicePass constructor

Differential Revision: [D99636777](https://our.internmc.facebook.com/intern/diff/D99636777/)

ghstack-source-id: 363318416
Pull Request resolved: #18730
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 6, 2026

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

…py ops at delegate boundaries"

Extend PropagateDevicePass to insert explicit et_copy._h2d_copy and
et_copy._d2h_copy ops at delegate boundaries, making the graph functional
by explicitly transferring data between CPU and device memory.

Key changes:
- Inserts _h2d_copy before each delegate input, _d2h_copy after each output
- Original input nodes stay CPU; h2d_copy output tagged as device
- Getitem nodes inherit device; d2h_copy output tagged as CPU
- Skip-copy optimizations via skip_h2d_for_method_inputs/skip_d2h_for_method_outputs
- _parse_device_spec_value: lowercases string, raises ValueError for unknown types
- _program.py passes config flags to PropagateDevicePass constructor

Differential Revision: [D99636777](https://our.internmc.facebook.com/intern/diff/D99636777/)

[ghstack-poisoned]
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 Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant