KEMBAR78
Horizontally fuse input concatenation by mlazos · Pull Request #108115 · pytorch/pytorch · GitHub
Skip to content

Conversation

@mlazos
Copy link
Contributor

@mlazos mlazos commented Aug 29, 2023

@mlazos mlazos requested review from jansel and yanboliang August 29, 2023 01:05
@pytorch-bot pytorch-bot bot added the release notes: foreach_frontend release notes category label Aug 29, 2023
@pytorch-bot
Copy link

pytorch-bot bot commented Aug 29, 2023

🔗 Helpful Links

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

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

❗ 1 Merge Blocking SEVs

There is 1 active merge blocking SEVs. Please view them below:

If you must merge, use @pytorchbot merge -f.

✅ No Failures

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

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

@mlazos mlazos added the ciflow/trunk Trigger trunk jobs on your pull request label Aug 29, 2023
@mlazos mlazos requested a review from jansel August 29, 2023 21:13
@mlazos
Copy link
Contributor Author

mlazos commented Aug 29, 2023

@pytorchbot merge

@pytorchmergebot
Copy link
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

@mlazos
Copy link
Contributor Author

mlazos commented Aug 29, 2023

@pytorchbot merge

@pytorchmergebot
Copy link
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
Collaborator

Merge failed

Reason: 1 mandatory check(s) failed. The first few are:

Dig deeper by viewing the failures on hud

Details for Dev Infra team Raised by workflow job

Failing merge rule: Core Maintainers

@mlazos
Copy link
Contributor Author

mlazos commented Aug 30, 2023

@pytorchbot merge

@pytorchmergebot
Copy link
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
Collaborator

Merge failed

Reason: 1 mandatory check(s) failed. The first few are:

Dig deeper by viewing the failures on hud

Details for Dev Infra team Raised by workflow job

Failing merge rule: Core Maintainers

@mlazos
Copy link
Contributor Author

mlazos commented Sep 2, 2023

@pytorchbot merge

@pytorchmergebot
Copy link
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
Collaborator

Merge failed

Reason: 1 jobs have failed, first few of them are: inductor / cuda12.1-py3.10-gcc9-sm86 / test (inductor_torchbench_dynamic, 1, 1, linux.g5.4xlarge.nvidia.gpu)

Details for Dev Infra team Raised by workflow job

@aakhundov
Copy link
Contributor

@mlazos seems that this PR currently contains only the new is_dynamic function in _inductor/utils.py. I'm wondering if the changes utilizing the new function got lost while merging with main (I see _inductor/ir.py was mentioned in the review above)? Thanks!

input_unwrapped = inputs[i].data

if (
input_unwrapped.is_input_buffer()
Copy link
Contributor

Choose a reason for hiding this comment

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

Do I get it right that the horizontal fusion of separate concat kernels into foreach is enabled only when the concat arguments are graph inputs? I'm wondering if this could be extended to the cases when the arguments are intermediate (realized) buffers in the graph. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah this is true, I'm curious about your use case because I think in most cases of intermediates the concat kernel rewrites the storage of the upstream ops to point to the concat buffer rather than launching a copy kernel. Let me know if there are cases where we copy anyway and I can remove this constraint.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the explanation. In my use case, concat takes (many) arguments which are outputs of the torch.ops.aten.slice.Tensor ops. So my understanding is that the latter are already views (reading from a particular offset of the input to the slice ops). At the same time, the slices / views are not graph inputs. So the ConcatKernel actually ends up generating a bunch of copy kernels: one per each slice input.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, yeah I'll experiment with removing this constraint in a separate PR since this has had a lot of edge cases and I want the MRS folks to test this. It should just work ootb I think

@mlazos
Copy link
Contributor Author

mlazos commented Sep 5, 2023

@pytorchbot merge

@pytorchmergebot
Copy link
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

mlazos added a commit to mlazos/pytorch that referenced this pull request Sep 7, 2023
Summary:
Original commit changeset: f15956d96311

Original Phabricator Diff: D48996091

Test Plan: Reverting to Unbreak test

Differential Revision: D49065517
pytorchmergebot pushed a commit that referenced this pull request Sep 8, 2023
Summary:
Original commit changeset: f15956d96311

Original Phabricator Diff: D48996091

Test Plan: Reverting to Unbreak test

Differential Revision: D49065517

Pull Request resolved: #108793
Approved by: https://github.com/Chillee
@facebook-github-bot
Copy link
Contributor

This pull request has been reverted by 6c72604. To re-land this change, please open another pull request, assignthe same reviewers, fix the CI failures that caused the revert and make sure that the failing CI runs on the PR by applying the proper ciflow label (e.g., ciflow/trunk).

pytorchmergebot pushed a commit that referenced this pull request Oct 18, 2023
Reland #108115

The main fix is to disallow nop nodes to be included in foreach scheduler nodes

Pull Request resolved: #111437
Approved by: https://github.com/yanboliang
@github-actions github-actions bot deleted the mlazos/fuse-cat branch March 6, 2025 02:07
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.

Inductor generates more kernels than we expected when cat/stack inputs

7 participants