-
Notifications
You must be signed in to change notification settings - Fork 568
Support weights="distance"
for KNeighbors*
in cuml.accel
#6554
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
Support weights="distance"
for KNeighbors*
in cuml.accel
#6554
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. |
I ran the scikit-learn test suite against this with the regression testing that I'm currently implementing in #6553. This is what I found:
That's overall very positive! However, it looks like the Traceback
|
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.
Great! We will need to address one regression.
# if using accelerator and doing inference, always use GPU | ||
elif func_name not in ['fit', 'fit_transform', 'fit_predict']: | ||
device_type = DeviceType.device | ||
|
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.
This particular change appears to introduce a regression, see #6554 (comment) .
@dantegd can you comment on the initial motivation for this?
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.
Technically speaking we can run inference in many cases even if training was done on GPU, but I agree with the change done in this PR after analyzing the behavior that @jcrist mentions. The CPU to GPU transfer eats a lot of the time that the inference acceleration gains.
Previously we would fail if the user specified `weights="distance"` to `KNeighborsClassifier`/`KNeighborsRegressor`. This fixes that and adds a test. Part of fixing this required changing the logic in `dispatch_func` to not special-case inference methods. Previously we would always run inference on the GPU, even if `_gpuaccel` was False (meaning the hyperparameters specified weren't supported by cuml). I don't believe this to be the desired logic - if cuml doesn't support the specified hyperparameters, we cannot be sure that we do support them for `predict`. Further, the state is stored on the cpu estimator already, running inference on CPU makes more sense anyway IMO. It also makes understanding where something runs clearer: - If the hyperparameters aren't supported by cuml, then everything runs on CPU - If the arguments provided to a method aren't supported by cuml, then that method will dispatch to CPU - Otherwise we run on GPU
5a8fd83
to
5d5c2c8
Compare
Regression should be fixed. |
# if using accelerator and doing inference, always use GPU | ||
elif func_name not in ['fit', 'fit_transform', 'fit_predict']: | ||
device_type = DeviceType.device | ||
|
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.
Technically speaking we can run inference in many cases even if training was done on GPU, but I agree with the change done in this PR after analyzing the behavior that @jcrist mentions. The CPU to GPU transfer eats a lot of the time that the inference acceleration gains.
/merge |
Previously we would fail if the user specified
weights="distance"
toKNeighborsClassifier
/KNeighborsRegressor
. This fixes that and adds a test.Part of fixing this required changing the logic in
dispatch_func
to not special-case inference methods. Previously we would always run inference on the GPU, even if_gpuaccel
was False (meaning the hyperparameters specified weren't supported by cuml). I don't believe this to be the desired logic - if cuml doesn't support the specified hyperparameters, we cannot be sure that we do support them forpredict
. Further, the state is stored on the cpu estimator already, running inference on CPU makes more sense anyway IMO. It also makes understanding where something runs clearer:Fixes #6545.