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

Compute noise_variance_ in PCA implementation #6234

Open
wants to merge 1 commit into
base: branch-25.02
Choose a base branch
from

Conversation

jcrist
Copy link
Member

@jcrist jcrist commented Jan 17, 2025

Previously noise_vars was an output parameter passed to the cuda PCA implementation, but it was unimplemented. This adds support for computing noise_vars in the cuda code, and tests that the results are valid by comparing to the scikit-learn implementation.

The previous code would always have a noise_variance_ of 0, resulting in downstream issues interpreting results after converting a cuml estimator to its sklearn equivalent (e.g. broken score_samples).

@jcrist jcrist requested review from a team as code owners January 17, 2025 16:27
@jcrist jcrist requested review from bdice and wphicks January 17, 2025 16:27
@github-actions github-actions bot added Cython / Python Cython or Python issue CUDA/C++ labels Jan 17, 2025
@jcrist jcrist force-pushed the pca-noise-variance branch from f73ec37 to c4939b6 Compare January 17, 2025 16:28
@jcrist jcrist added non-breaking Non-breaking change bug Something isn't working labels Jan 17, 2025
@@ -128,9 +128,6 @@ void fit_impl(raft::handle_t& handle,
streams,
n_streams,
verbose);
for (std::uint32_t i = 0; i < n_streams; i++) {
handle.sync_stream(streams[i]);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This sync point was unneeded, it was already handled after exiting this branch below.

true,
stream);
} else {
raft::matrix::setValue(noise_vars, noise_vars, math_t{0}, 1, stream);
Copy link
Member Author

Choose a reason for hiding this comment

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

noise_vars is a len-1 device array that I want to set to 0. This seems to work (and is used at least one other place in cuml already), but I'm honestly not sure if it's the best spelling of that. In particular, I don't understand why a method for filling an output array with a single value also takes in an input array (which is the same as the output array in all calling locations I can find).

Previously `noise_vars` was an output parameter passed to the cuda PCA
implementation, but it was unimplemented. This adds support for
computing `noise_vars` in the cuda code, and tests that the results
are valid by comparing to the scikit-learn implementation.

The previous code would always have a `noise_variance_` of 0, resulting
in downstream issues interpreting results after converting a cuml
estimator to its sklearn equivalent (e.g. broken `score_samples`).
@jcrist jcrist force-pushed the pca-noise-variance branch from c4939b6 to 4a927b3 Compare January 17, 2025 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working CUDA/C++ Cython / Python Cython or Python issue non-breaking Non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant