Skip to content

4.2.1

Latest

Choose a tag to compare

@DavidMChan DavidMChan released this 29 Nov 22:50
c6a9f7a

4.2.1 fixes embeddings that broke into small islands (#138), makes random_seed work, and adds the KL divergence of the result. Embeddings with the default settings change, so read the first section before upgrading.

Changes to results

  • Clusters no longer break into islands (#138). Up to 2.x, each pair of neighbors attracted both of its points. Since 3.0, when point i had j among its nearest neighbors but j did not have i, only i was pulled toward j. That dropped 16 to 25% of the attraction on MNIST and digits, and with the default settings clusters split into separate islands. Both points are pulled again, as in 2.x: on MNIST the KL divergence with the default settings goes from 3.71 to 3.62, and the embedding looks like openTSNE's again. It takes about 10% longer; symmetric=False keeps the old behavior for speed.
  • The default perplexity is 30 instead of 50. With the default 32 neighbors, 31 of them other points, a perplexity of 50 could not be reached, so every neighbor got the same weight. 30 is also scikit-learn's default. fit_transform now warns when the perplexity cannot be reached with num_neighbors.

New

  • random_seed works (#44, #129). It used to be ignored. With a seed, the starting layout comes from that seed, and repeated runs give the same embedding on the same GPU model with the same tsnecuda and FAISS builds.
  • strict adds forces up in a fixed order, which is what makes seeded runs repeat exactly. It is on by default when random_seed is set and off otherwise; pass strict=False to keep the faster default kernels with a seed. Strict mode is about 10% slower at 100,000 points and about the same speed at a million.
  • symmetric=False goes back to the one-sided attraction of 3.0 to 4.2 (see #138 above): about 9% faster at 100,000 points and 12% at a million, but clusters can break into islands.
  • kl_divergence_ (#75), as in scikit-learn: the KL divergence of the returned embedding. With verbose=1 it is also printed at each progress line.

Fixes

  • Errors raise RuntimeError instead of ending the Python process (#124, #132). CUDA, cuBLAS, cuFFT and FAISS errors used to exit, abort, or print "terminating!" and carry on; a missing GPU or a wrong device now gives a clear message. #132 was FAISS running out of GPU memory.
  • tsne-cuda no longer uses cuSPARSE (#134), which it initialized and never used. The pip install no longer needs nvidia-cusparse, a 230 MB download.
  • return_style='snapshots' corrupted memory, because it wrote all of the snapshots into an array the size of one embedding. It now returns an array of shape (num_snapshots, n_points, 2).
  • The GPU nearest-neighbor search runs in batches. FAISS allocated temporary memory for every point at once, and large inputs with many neighbors ran out of GPU memory (a million points with 92 neighbors needed 14.7 GB).
  • #121 (cuBLAS failing after importing datashader) does not happen with 4.2.0 or later, including with CuPy using cuBLAS first.
  • #120 (cuBLAS INVALID_VALUE on large inputs), #123 (FAISS invalid configuration argument) and #133 (missing libmkl_intel_lp64.so) don't happen with 4.2.0 and later; when something like them goes wrong, the error now says what.

Validation

  • The Linux wheel passes the test suite (19 tests) on an RTX 4090 (sm_89), a Quadro RTX 6000 (sm_75) and an RTX A4000 (sm_86), in clean Python 3.12 environments without conda.
  • On each of them, two runs with the same random_seed give identical embeddings, with both the GPU and the CPU nearest-neighbor search, and a different seed gives a different embedding.
  • kl_divergence_ is within 0.75% of the exact KL divergence computed with NumPy from the same P after 1,000 iterations, and within 1e-6 after 100.
  • device=99 raises RuntimeError, and a later run in the same process works.
  • On the RTX 4090, a million points with 92 and 152 neighbors take 14.6 s and 20.1 s; 4.2.0 ran out of GPU memory on both.
  • The Windows wheel installs and loads on GitHub's Windows Server 2022 and 2025 runners with Python 3.9, 3.12 and 3.14, which have no GPU.