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

Improve infrastructure for experimental dispatching of non existing methods in cuML #6148

Merged
merged 13 commits into from
Dec 12, 2024

Conversation

dantegd
Copy link
Member

@dantegd dantegd commented Nov 27, 2024

This PR adds methods in UniversalBase, so that cuML estimators that inherit from it can enable better errors, and experimentally dispatch to other libraries (sklearn, umap, hdbscan...) for methods that haven't been implemented in cuML itself.

@github-actions github-actions bot added the Cython / Python Cython or Python issue label Nov 27, 2024
@betatim
Copy link
Member

betatim commented Nov 27, 2024

I think the only bigger picture question for this PR is: should we just implement the missing methods instead of forwarding? It would probably benefit all cuml users, be more straightforward (measure in less dunder usage :D), but it is a lot more work.

We can decide in either direction, but wanted to bring it up so that we briefly talk about it and then decide.

Copy link
Contributor

@viclafargue viclafargue left a comment

Choose a reason for hiding this comment

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

LGTM, I think that the dispatching mechanism should work well :). However, what worries me a bit is that it is not a guarantee that Scikit-Learn functions will all work fine just following attributes transfers. There seems to be a lot of edge cases, and I believe that this would require some more rigorous testing. Ideally, if we want to guarantee functionality we would have to whitelist the functions that work fine for each estimator.

and creates one if necessary.
"""
if not hasattr(self, "_cpu_model"):
self.import_cpu_model()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that the call to the import_cpu_model function is not necessary here as we already checked the presence of the _cpu_model_class attribute earlier.

@betatim
Copy link
Member

betatim commented Nov 27, 2024

Maybe something to add is a test that iterates overall cuml estimators and their scikit-learn equivalent and checks all attrs exist. We could extend it to instantiate each estimator, fit it and then repeat the check.

@betatim
Copy link
Member

betatim commented Nov 28, 2024

For the "iterate over all estimators" part: I wrote something to do that for #6107 and am wanting to re-use it for #4753 (iterate all estimators, then filter those that accept random_state=). Should we make a separate PR that adds this functionality that we can merge before all of these and this PR?

@dantegd
Copy link
Member Author

dantegd commented Dec 2, 2024

@betatim added the pytests, but for now it was easier to manually list the estimators that support interoperability by inheriting from UniversalBase, we probably should revisit that soon for #6107 indeed, but for now I think we can keep the PRs independent.

@dantegd dantegd added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Dec 2, 2024
@betatim
Copy link
Member

betatim commented Dec 2, 2024

Yeah I think we need a separate PR to build the infrastructure for discovering estimators, etc. So fine for me to not do that here.

Why do we need _experimental_dispatching as a way to turn this on? Couldn't it be on by default?

@dantegd
Copy link
Member Author

dantegd commented Dec 3, 2024

@betatim because this could prove to be a change that could break some third party libraries in ways I might not expect or might be unexpected for users, I think it should be opt-in while more extensive testing is done at least for a version cycle.

Copy link

copy-pr-bot bot commented Dec 10, 2024

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@dantegd dantegd changed the base branch from branch-24.12 to branch-25.02 December 10, 2024 04:43
@dantegd
Copy link
Member Author

dantegd commented Dec 10, 2024

/ok to test

@dantegd dantegd marked this pull request as ready for review December 11, 2024 15:43
@dantegd dantegd requested review from a team as code owners December 11, 2024 15:43
@dantegd dantegd requested review from bdice and betatim December 11, 2024 15:43
@github-actions github-actions bot removed the conda conda issue label Dec 11, 2024
@dantegd
Copy link
Member Author

dantegd commented Dec 12, 2024

/merge

@rapids-bot rapids-bot bot merged commit 7580d7c into rapidsai:branch-25.02 Dec 12, 2024
61 of 62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cython / Python Cython or Python issue improvement Improvement / enhancement to an existing function non-breaking Non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants