Skip to content

PropagateDevicePass inserts H2D/D2H copy ops at delegate boundaries (#19921)#19921

Open
Gasoonjia wants to merge 1 commit into
mainfrom
export-D99636777
Open

PropagateDevicePass inserts H2D/D2H copy ops at delegate boundaries (#19921)#19921
Gasoonjia wants to merge 1 commit into
mainfrom
export-D99636777

Conversation

@Gasoonjia
Copy link
Copy Markdown
Contributor

@Gasoonjia Gasoonjia commented Jun 1, 2026

Summary:

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

Reviewed By: JacobSzwejbka

Differential Revision: D99636777

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Jun 1, 2026

🔗 Helpful Links

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

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

⏳ No Failures, 1 Pending

As of commit 7743dde with merge base eeb0646 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@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 Jun 1, 2026
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented Jun 1, 2026

@Gasoonjia has exported this pull request. If you are a Meta employee, you can view the originating Diff in D99636777.

Copy link
Copy Markdown
Contributor

@JacobSzwejbka JacobSzwejbka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

Copy link
Copy Markdown
Contributor

@digantdesai digantdesai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 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.

…19921)

Summary:


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

Reviewed By: JacobSzwejbka

Differential Revision: D99636777
@meta-codesync meta-codesync Bot changed the title PropagateDevicePass inserts H2D/D2H copy ops at delegate boundaries PropagateDevicePass inserts H2D/D2H copy ops at delegate boundaries (#19921) Jun 1, 2026
@meta-codesync meta-codesync Bot force-pushed the export-D99636777 branch from 85895ed to 7743dde Compare June 1, 2026 18:28
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.

3 participants