Skip to content

Use exact solver for cuML t-SNE to avoid Barnes-Hut collapse#45

Merged
NetZissou merged 1 commit into
mainfrom
fix/cuml-tsne-degenerate-guard
Jun 29, 2026
Merged

Use exact solver for cuML t-SNE to avoid Barnes-Hut collapse#45
NetZissou merged 1 commit into
mainfrom
fix/cuml-tsne-degenerate-guard

Conversation

@NetZissou

Copy link
Copy Markdown
Collaborator

cuML's default Barnes-Hut t-SNE collapses to a ~1D diagonal line on near-homogeneous embeddings, we're able to reproduce this on the Darwin's finches BioCLIP 2 embeddings. The "exact" solver fix this easily.

Force method="exact" for the cuML t-SNE path. It's O(N^2) but fine at the interactive scale this app runs; a faster Barnes-Hut-with-degeneracy-guard can be revisited later.

Closes #40

cuML's default Barnes-Hut t-SNE collapses to a ~1D diagonal line on
near-homogeneous embeddings, we're able to reproduce this on the
Darwin's finches BioCLIP 2 embeddings. The "exact" solver fix this
easily.

Force method="exact" for the cuML t-SNE path. It's O(N^2) but fine at the interactive scale this app runs; a faster Barnes-Hut-with-degeneracy-guard can be revisited later.
@NetZissou NetZissou requested a review from egrace479 June 18, 2026 13:03
@NetZissou NetZissou self-assigned this Jun 18, 2026
@NetZissou NetZissou added the bug Something isn't working label Jun 18, 2026
@NetZissou

Copy link
Copy Markdown
Collaborator Author

@egrace479 this fix won't affect non-cuda accelerated sessions.

I've validated the changes on pitzer GPU.

[2026-06-18 08:56:36] INFO [shared.utils.backend.check_cuda_available:52] CUDA        
  available via PyTorch: Tesla V100-PCIE-16GB
  [2026-06-18 08:56:42] INFO [shared.utils.backend.resolve_backend:105] Auto-resolved   
  reduction backend to cuML (GPU: Tesla V100-PCIE-16GB)                                 
  [2026-06-18 08:56:42] INFO                                                            
  [apps.precalculated.components.sidebar._run_projection:620]
  ============================================================
  [2026-06-18 08:56:42] INFO
  [apps.precalculated.components.sidebar._run_projection:621] PROJECTION START
  [2026-06-18 08:56:42] INFO
  [apps.precalculated.components.sidebar._run_projection:622] Device: Tesla
  V100-PCIE-16GB (CUDA: Yes)
  [2026-06-18 08:56:42] INFO
  [apps.precalculated.components.sidebar._run_projection:623] Backend: cuml (requested:
  auto)
  [2026-06-18 08:56:42] INFO
  [apps.precalculated.components.sidebar.extract_embeddings_safe:517] Extracting
  embeddings from DataFrame: 677 rows
  [2026-06-18 08:56:42] INFO
  [apps.precalculated.components.sidebar.extract_embeddings_safe:526] Extracted
  embeddings: shape=(677, 768), dtype=float32
  [2026-06-18 08:56:42] INFO
  [apps.precalculated.components.sidebar._run_projection:631] Records: 677 | Dim: 768 |
  Extracted in 0.00s
  [2026-06-18 08:56:42] INFO [shared.services.clustering_service.run_dim_reduction:104]
  Dim reduction: samples=677, features=768, method=TSNE, backend=cuml, seed=614
  [2026-06-18 08:56:42] INFO [shared.utils.clustering.reduce_dim:165] Dimensionality
  reduction: method=TSNE, samples=677, features=768, backend=cuml
  [2026-06-18 08:56:42] INFO [shared.utils.clustering._prepare_embeddings:141]
  [reduce_dim] Prepared embeddings: 677 samples, 768 features, dtype=float32,           
  L2-normalized (input norms: min=40.57, max=54.16, mean=44.74)
  [2026-06-18 08:56:42] INFO [shared.utils.clustering.reduce_dim:181] Using cuML
  backend for TSNE
  [2026-06-18 08:56:43] INFO [shared.utils.clustering.reduce_dim:188] Dimensionality
  reduction completed in 0.72s
  [2026-06-18 08:56:43] INFO [shared.services.clustering_service.run_dim_reduction:112]
  Dim reduction complete: (677, 2) in 0.75s

@egrace479 egrace479 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. We can revisit and explore other speed-up options if needed.

@NetZissou NetZissou merged commit 0df1846 into main Jun 29, 2026
12 checks passed
@NetZissou NetZissou deleted the fix/cuml-tsne-degenerate-guard branch June 29, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cuML Barnes-Hut t-SNE collapses to a straight line on homogeneous embeddings

2 participants