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

UMAP fixes #6316

Open
wants to merge 1 commit into
base: branch-25.04
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions cpp/src/umap/simpl_set_embed/optimize_batch_kernel.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,6 @@ CUML_KERNEL void optimize_batch_kernel_reg(T const* head_embedding,
auto grad_d = T(0.0);
if (repulsive_grad_coeff > T(0.0))
grad_d = clip<T>(repulsive_grad_coeff * diff, T(-4.0), T(4.0));
else
grad_d = T(4.0);
grads[d] += grad_d * alpha;
}
}
Expand Down Expand Up @@ -315,8 +313,6 @@ CUML_KERNEL void optimize_batch_kernel(T const* head_embedding,
auto grad_d = T(0.0);
if (repulsive_grad_coeff > T(0.0))
grad_d = clip<T>(repulsive_grad_coeff * (current[d] - negative_sample[d]), T(-4.0), T(4.0));
else
Copy link
Member

Choose a reason for hiding this comment

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

I'm still curious about this change- I want to make sure we're not sacrificing the numerical stability by changing this based on limited evidence. What is the reason for changing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a clear mistake here.
Here is the reference implementation : https://github.com/lmcinnes/umap/blob/a012b9d8751d98b94935ca21f278a54b3c3e1b7f/umap/layouts.py#L181

grad_d = T(4.0);
grad_d *= alpha;
if (use_shared_mem) {
current_buffer[d * TPB_X] += grad_d;
Expand Down
3 changes: 2 additions & 1 deletion python/cuml/cuml/manifold/simpl_set.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@ def simplicial_set_embedding(

cdef UMAPParams* umap_params = new UMAPParams()
umap_params.n_components = <int> n_components
umap_params.initial_alpha = <int> initial_alpha
umap_params.initial_alpha = <float> initial_alpha
umap_params.learning_rate = <float> initial_alpha
umap_params.a = <float> a
umap_params.b = <float> b

Expand Down
1 change: 1 addition & 0 deletions python/cuml/cuml/manifold/umap.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ class UMAP(UniversalBase,
umap_params.n_components = <int> self.n_components
umap_params.n_epochs = <int> self.n_epochs if self.n_epochs else 0
umap_params.learning_rate = <float> self.learning_rate
umap_params.initial_alpha = <float> self.learning_rate
umap_params.min_dist = <float> self.min_dist
umap_params.spread = <float> self.spread
umap_params.set_op_mix_ratio = <float> self.set_op_mix_ratio
Expand Down
Loading