-
Notifications
You must be signed in to change notification settings - Fork 568
Improve model round-tripping #6342
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
base: branch-25.04
Are you sure you want to change the base?
Conversation
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. |
cuml_param_names = self._get_param_names() | ||
for param, value in self._cpu_model.get_params().items(): | ||
if param in cuml_param_names: | ||
self.set_params(**{param: value}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can make this nicer, left it like this for now to illustrate the point. I think we need some translation mechanism, not just blindly copying things.
In the GPU -> CPU direction attributes are already copied, but probably also needs adjusting?
@@ -81,6 +82,8 @@ def assert_estimator_roundtrip( | |||
# Convert back | |||
roundtrip_model = type(cuml_model).from_sklearn(sklearn_model) | |||
|
|||
assert original_params == roundtrip_model.get_params() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be true. Otherwise calling fit
, which is possible (or should we disallow it? A la FrozenEstimator
), will lead to very weird results.
@@ -115,7 +118,7 @@ def test_kmeans(random_state): | |||
X, _ = make_blobs( | |||
n_samples=50, n_features=2, centers=3, random_state=random_state | |||
) | |||
original = KMeans(n_clusters=3, random_state=random_state) | |||
original = KMeans(n_clusters=13, random_state=random_state) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a random value that isn't the default
This PR is the result of investigating #6142
A short version of the story is that this roundtrip doesn't work:
This PR kinda fixes things, but really we need the hyper-parameter translator from the 0cc accelerator.
cc @dantegd