Skip to content

Account for forwards which whose corresponding backwards are not invoked - #98112

Closed
eellison wants to merge 5 commits into
gh/eellison/413/basefrom
gh/eellison/413/head
Closed

eellison wants to merge 5 commits into
gh/eellison/413/basefrom
gh/eellison/413/head

Conversation

@eellison

@eellison eellison commented Apr 1, 2023 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Previously, when we would run a forward graph whose backward we never invoked it would prevent us from switching from warmup to recording. Now, refine the heuristic to allow incrementing the generation as soon as we invoke a backward graph. This still handles the

mod1 = torch.compile(...)

mod2 = torch.compile(...) 

mod2(mod1(x)).sum().backward()

case while accounting for graphs which we may not run backward of.

It also now handles the case where we skip cudagraphify the backward of a forward.

cc @soumith @voznesenskym @penguinwu @anijain2305 @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @Xia-Weiwen @wenzhe-nrv @jiayisunx @peterbell10 @desertfire

@pytorch-bot

pytorch-bot Bot commented Apr 1, 2023 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

✅ No Failures

As of commit ba7cd40:
💚 Looks good so far! There are no failures yet. 💚

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

eellison added a commit that referenced this pull request Apr 1, 2023
@eellison eellison added the topic: not user facing topic category label Apr 1, 2023
@eellison
eellison requested review from ezyang and jansel and removed request for ezyang and jansel April 1, 2023 01:48
@ezyang

ezyang commented Apr 1, 2023

Copy link
Copy Markdown
Contributor

Test?

@ezyang

ezyang commented Apr 1, 2023

Copy link
Copy Markdown
Contributor

i guess you removed review request so imma wait

@eellison

eellison commented Apr 1, 2023 •

Copy link
Copy Markdown
Contributor Author

@ezyang, yea, adding test, will re-request when ready

…re not invoked"


Previously, we would run a forward graph whose backward we never invoked. This would prevent us from switching from warmup to recording. Instead, refine the heuristic to allow incrementing the generation as soon as we invoke a backward graph. This still handles the 
```
mod1 = torch.compile(...)

mod2 = torch.compile(...) 

mod2(mod1(x)).sum().backward()
```
case while accounting for graphs which we may not run backward of.


cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
…re not invoked"


Previously, we would run a forward graph whose backward we never invoked. This would prevent us from switching from warmup to recording. Instead, refine the heuristic to allow incrementing the generation as soon as we invoke a backward graph. This still handles the 
```
mod1 = torch.compile(...)

mod2 = torch.compile(...) 

mod2(mod1(x)).sum().backward()
```
case while accounting for graphs which we may not run backward of.


cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
and not is_inference
and not is_backward
):
boxed_forward_device_index.set(next(iter(graph.device_idxs)))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is it correct to only take the first device index?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

we skip if there are multiple devices

…re not invoked"


Previously, when we would run a forward graph whose backward we never invoked it would prevent us from switching from warmup to recording. Now, refine the heuristic to allow incrementing the generation as soon as we invoke a backward graph. This still handles the 
```
mod1 = torch.compile(...)

mod2 = torch.compile(...) 

mod2(mod1(x)).sum().backward()
```
case while accounting for graphs which we may not run backward of. 

It also now handles the case where we skip cudagraphify the backward of a forward.


cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
eellison added a commit that referenced this pull request Apr 4, 2023
@eellison eellison mentioned this pull request Apr 4, 2023
…re not invoked"


Previously, when we would run a forward graph whose backward we never invoked it would prevent us from switching from warmup to recording. Now, refine the heuristic to allow incrementing the generation as soon as we invoke a backward graph. This still handles the 
```
mod1 = torch.compile(...)

mod2 = torch.compile(...) 

mod2(mod1(x)).sum().backward()
```
case while accounting for graphs which we may not run backward of. 

It also now handles the case where we skip cudagraphify the backward of a forward.


cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
@eellison eellison added the ciflow/trunk Trigger trunk jobs on your pull request label Apr 4, 2023
@eellison

eellison commented Apr 5, 2023

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@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

@eellison

eellison commented Apr 5, 2023

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

The merge job was canceled. If you believe this is a mistake,then you can re trigger it through pytorch-bot.

@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

eellison added a commit to eellison/pytorch that referenced this pull request Mar 7, 2024
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.

4 participants