Skip to content

[inductor_collectives] Make reorder_collectives_preserve_peak pass grouping nodes#157706

Closed
IvanKobzarev wants to merge 4 commits intogh/IvanKobzarev/121/basefrom
gh/IvanKobzarev/121/head
Closed

[inductor_collectives] Make reorder_collectives_preserve_peak pass grouping nodes#157706
IvanKobzarev wants to merge 4 commits intogh/IvanKobzarev/121/basefrom
gh/IvanKobzarev/121/head

Conversation

@pytorch-bot
Copy link

pytorch-bot bot commented Jul 7, 2025

🔗 Helpful Links

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

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

✅ No Failures

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

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

@pytorch-bot pytorch-bot bot added ciflow/inductor module: inductor oncall: distributed Add this issue/PR to distributed oncall triage queue labels Jul 7, 2025
…eak pass grouping nodes"

cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3k voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy chenyang78 kadeng muchulee8 amjames chauhang aakhundov

[ghstack-poisoned]
@IvanKobzarev
Copy link
Contributor Author

@IvanKobzarev has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Jul 7, 2025
@IvanKobzarev IvanKobzarev added the topic: not user facing topic category label Jul 7, 2025
…eak pass grouping nodes"

cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3k voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy chenyang78 kadeng muchulee8 amjames chauhang aakhundov

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

[ghstack-poisoned]
@IvanKobzarev
Copy link
Contributor Author

@IvanKobzarev has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

def _temp_group_visit_leaves(snode, fn):
from torch._inductor.scheduler import GroupedSchedulerNode

if isinstance(snode, GroupedSchedulerNode) and snode.temp_grouping:
Copy link
Contributor

Choose a reason for hiding this comment

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

is temp_grouping a new concept you created? Does this imply that some other GroupedSchedulerNodes that are not temporary could exist at this time? If so, is calling 'fn(node)' the right thing to do for them?

Copy link
Contributor Author

@IvanKobzarev IvanKobzarev Jul 7, 2025

Choose a reason for hiding this comment

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

Yes, need to deduplicate this.

compute_time += runtimes[snode]
if isinstance(snode, GroupedSchedulerNode) and snode.temp_grouping:

def _fn(_snode):
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, move this fn def to above next to def of compute_time int, and rename it to def accumulate_time then call it in both branches (temp_visit(accumulate)) vs accumulate(snode))

if contains_collective(prev_gsnode):
return False

if contains_ungroupable(prev_gsnode):
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: a bit arbitrary that "contains_collective" is a separate catetory than '"contains_ungroupable". Would it be more readable to rename "contains_ungroupable" to "contains_gemm_like" ?

Copy link
Contributor

@wconstab wconstab left a comment

Choose a reason for hiding this comment

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

LGTM! the grouping method is quite unintrusive.

…eak pass grouping nodes"

cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3k voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy chenyang78 kadeng muchulee8 amjames chauhang aakhundov

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

[ghstack-poisoned]
@IvanKobzarev
Copy link
Contributor Author

@IvanKobzarev has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

1 similar comment
@IvanKobzarev
Copy link
Contributor Author

@IvanKobzarev has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@IvanKobzarev
Copy link
Contributor Author

@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

return self.initial_exposed - self.final_exposed


def is_gemm_like(node: Optional[Union[IRNode, Operation]]) -> bool:
Copy link
Collaborator

Choose a reason for hiding this comment

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

is "gemm-like" here a proxy for "has meaningful flops?" (which would include other fallback ops like e.g. custom matmul triton kernels from users).

I wonder if there are any other inductor utils to tell us this info with higher fidelity... Maybe @eellison will have ideas when he's back

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, yes. At the moment this is super basic "heuristic" to not group collectives with ops with which we want to reorder. Agree, that will be good to have something based on "flops".

pytorchmergebot pushed a commit that referenced this pull request Jul 8, 2025
@github-actions github-actions bot deleted the gh/IvanKobzarev/121/head branch August 8, 2025 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/inductor ciflow/trunk Trigger trunk jobs on your pull request Merged module: inductor oncall: distributed Add this issue/PR to distributed oncall triage queue topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants