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

[Data] Allow specifying insertion index when registering custom plan optimization Rules #48039

Merged
merged 2 commits into from
Oct 16, 2024

Conversation

scottjlee
Copy link
Contributor

@scottjlee scottjlee commented Oct 16, 2024

Why are these changes needed?

Currently, when registering custom LogicalPlan or PhysicalPlan optimization Rules, the only option is to append to the end of the registered rules. The optimization rules will then be executed in order. This is limiting because there are some cases where we want to specify the order of newly registered rules. For example, we may want to add our own custom rule prior to operator fusion taking place.

This PR adds the ability to specify an insertion index when registering a custom logical/physical rule. The existing behavior of methods are unchanged.

Related issue number

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

Signed-off-by: Scott Lee <sjl@anyscale.com>
Signed-off-by: Scott Lee <sjl@anyscale.com>
@scottjlee scottjlee changed the title [Data] Allow specifying insertion index when registering custom Logical/Physical Rules [Data] Allow specifying insertion index when registering custom plan optimization Rules Oct 16, 2024
@scottjlee scottjlee marked this pull request as ready for review October 16, 2024 02:31
Copy link
Member

@bveeramani bveeramani left a comment

Choose a reason for hiding this comment

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

Not in scope for this PR, but I've been wondering how we can mitigate the issue where the correctness of optimizer rules depends on it's ordering. Not sure what the best long term solution would be

@scottjlee scottjlee enabled auto-merge (squash) October 16, 2024 17:13
@github-actions github-actions bot added the go add ONLY when ready to merge, run all tests label Oct 16, 2024
@scottjlee scottjlee merged commit bfed0aa into ray-project:master Oct 16, 2024
6 checks passed
def register_logical_rule(cls: Type[Rule]):
_LOGICAL_RULES.append(cls)
def register_logical_rule(cls: Type[Rule], insert_index: Optional[int] = None):
if not insert_index:
Copy link
Member

Choose a reason for hiding this comment

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

Should this be if insert_index is not None? If insert_index == 0, this'd append the rule rather than making it the first item, right?

scottjlee added a commit that referenced this pull request Oct 16, 2024
…8051)

## Why are these changes needed?
Fix the bug reported
#48039 (comment)

## Related issue number

## Checks

- [x] I've signed off every commit(by using the -s flag, i.e., `git
commit -s`) in this PR.
- [x] I've run `scripts/format.sh` to lint the changes in this PR.
- [ ] I've included any doc changes needed for
https://docs.ray.io/en/master/.
- [ ] I've added any new APIs to the API Reference. For example, if I
added a
method in Tune, I've added it in `doc/source/tune/api/` under the
           corresponding `.rst` file.
- [ ] I've made sure the tests are passing. Note that there might be a
few flaky tests, see the recent failures at https://flakey-tests.ray.io/
- Testing Strategy
   - [x] Unit tests
   - [ ] Release tests
   - [ ] This PR is not tested :(

Signed-off-by: Scott Lee <sjl@anyscale.com>
Jay-ju pushed a commit to Jay-ju/ray that referenced this pull request Nov 5, 2024
…optimization `Rule`s (ray-project#48039)

## Why are these changes needed?

Currently, when registering custom `LogicalPlan` or `PhysicalPlan`
optimization `Rule`s, the only option is to append to the end of the
registered rules. The optimization rules will then be executed in order.
This is limiting because there are some cases where we want to specify
the order of newly registered rules. For example, we may want to add our
own custom rule prior to operator fusion taking place.

This PR adds the ability to specify an insertion index when registering
a custom logical/physical rule. The existing behavior of methods are
unchanged.

## Related issue number

## Checks

- [x] I've signed off every commit(by using the -s flag, i.e., `git
commit -s`) in this PR.
- [x] I've run `scripts/format.sh` to lint the changes in this PR.
- [ ] I've included any doc changes needed for
https://docs.ray.io/en/master/.
- [ ] I've added any new APIs to the API Reference. For example, if I
added a
method in Tune, I've added it in `doc/source/tune/api/` under the
           corresponding `.rst` file.
- [x] I've made sure the tests are passing. Note that there might be a
few flaky tests, see the recent failures at https://flakey-tests.ray.io/
- Testing Strategy
   - [x] Unit tests
   - [ ] Release tests
   - [ ] This PR is not tested :(

---------

Signed-off-by: Scott Lee <sjl@anyscale.com>
Jay-ju pushed a commit to Jay-ju/ray that referenced this pull request Nov 5, 2024
…y-project#48051)

## Why are these changes needed?
Fix the bug reported
ray-project#48039 (comment)

## Related issue number

## Checks

- [x] I've signed off every commit(by using the -s flag, i.e., `git
commit -s`) in this PR.
- [x] I've run `scripts/format.sh` to lint the changes in this PR.
- [ ] I've included any doc changes needed for
https://docs.ray.io/en/master/.
- [ ] I've added any new APIs to the API Reference. For example, if I
added a
method in Tune, I've added it in `doc/source/tune/api/` under the
           corresponding `.rst` file.
- [ ] I've made sure the tests are passing. Note that there might be a
few flaky tests, see the recent failures at https://flakey-tests.ray.io/
- Testing Strategy
   - [x] Unit tests
   - [ ] Release tests
   - [ ] This PR is not tested :(

Signed-off-by: Scott Lee <sjl@anyscale.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go add ONLY when ready to merge, run all tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants