Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial top-down presegmentation phase #2224

Open
jacobhinkle opened this issue May 9, 2024 · 2 comments
Open

Initial top-down presegmentation phase #2224

jacobhinkle opened this issue May 9, 2024 · 2 comments
Labels
enhancement New feature or request Segmentation Issues related to nvFuser Segmentation

Comments

@jacobhinkle
Copy link
Collaborator

In this comment, ⁠@wujingyue brought up an interesting idea: #2146 (comment). The proposal is:

to modify segmentation to first attempt to segment only at segment_set and to write a pre-seg pass to add segment_set to the right place for this particular pattern.

This would let us enforce a segmentation by inserting those ops at definition. We could also extend this to ops that currently require their inputs to be segment inputs, namely reshape and resize ops. In those cases we might arrive at an optimal segmentation quicker and it might give us more optimal segmentations (TODO: find an example where reshapes determine a segmentation that would be difficult to find in our current scheme).

To implement this we could replace the current first step in segmentation where we try scheduling the complete fusion. Instead we would:

  1. Tentatively merge groups across edges that are not produced by a LoadStoreOpType::SegmentSet (or other conditions like ViewOp inputs as mentioned above). Note that this might result in the complete fusion in cases where the segment sets do not form a proper graph cut-set.
  2. Try to schedule each resulting group.
  3. For any group that failed to schedule properly, shatter it back into its individual Expr groups.
  4. Proceed with our existing scheduling algorithm. Note that we don't need to try fusing the already-accepted groups since we know they are maximal.
@jacobhinkle jacobhinkle added enhancement New feature or request Segmentation Issues related to nvFuser Segmentation labels May 9, 2024
@naoyam
Copy link
Collaborator

naoyam commented May 9, 2024

We could also extend this to ops that currently require their inputs to be segment inputs, namely reshape and resize ops.

They are requirements of the schedulers. Having the requirements realized as a preseg pass would mean a tight binding of the preseg pass and each scheduler, which may be error-prone to maintain.

@rdspring1
Copy link
Collaborator

What about presegmenting in some way based on the higher-level torch operations? Our schedulers are loosely mapped to a set of torch operations. Thunder could insert these annotations before running nvfuser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Segmentation Issues related to nvFuser Segmentation
Projects
None yet
Development

No branches or pull requests

3 participants