Skip to content

t-SNE Kernel Crash #29127

Closed
Closed

Description

@JohT

Describe the bug

TSNE fit_transform leads in rare cases to a Kernel crash. I was able to reproduce it locally on my Mac, on Google Colab as well as in a GitHub Actions pipeline (Ubuntu).

The error message doesn't mention a specific reason:
[error] Disposing session as kernel process died ExitCode: undefined, Reason:

I came across this while working on this pull request: JohT/code-graph-analysis-pipeline#148

Steps/Code to Reproduce

Link to Google Colab with a detailed reproducer: https://drive.google.com/file/d/1l7sLOkE8vkfNcY57iVJ7YdpbQk1x0cTT/view?usp=drive_link

import pandas as pd
import numpy as np
from sklearn.manifold import TSNE

import sklearn
sklearn.show_versions()

# HashGNN embeddings (dict, 64 dimensions) of a very small Graph with only 4 nodes
# Something about this data will cause the t-SNE algorithm to crash the Kernel
hashGNN_embeddings = {'projectName': {0: 'react-router', 1: 'react-router-dom', 2: 'react-router-native', 3: 'react-router-dom', 4: 'router'}, 'embedding': {0: [0.0, -0.4330126941204071, -0.4330126941204071, 0.21650634706020355, -0.21650634706020355, -0.4330126941204071, 0.4330126941204071, 0.0, -1.0825317353010178, -0.21650634706020355, -0.21650634706020355, 0.6495190411806107, 0.8660253882408142, 0.21650634706020355, -0.21650634706020355, -0.4330126941204071, 0.21650634706020355, -0.4330126941204071, -0.8660253882408142, 0.4330126941204071, 0.21650634706020355, 0.8660253882408142, 0.0, 0.4330126941204071, 0.21650634706020355, 0.21650634706020355, -0.21650634706020355, 0.0, 0.0, 0.0, -0.21650634706020355, 0.4330126941204071, 1.0825317353010178, -0.4330126941204071, 0.21650634706020355, 1.0825317353010178, -0.4330126941204071, 1.0825317353010178, 0.0, -0.8660253882408142, 0.21650634706020355, 0.8660253882408142, 0.0, 0.21650634706020355, 0.21650634706020355, 0.0, 0.21650634706020355, 0.6495190411806107, 0.6495190411806107, 0.0, -0.6495190411806107, 0.21650634706020355, -0.4330126941204071, 0.4330126941204071, 0.21650634706020355, 0.6495190411806107, -0.6495190411806107, 0.4330126941204071, 0.6495190411806107, 0.0, 0.4330126941204071, 0.0, 0.21650634706020355, 0.4330126941204071], 1: [0.0, -0.4330126941204071, -0.4330126941204071, 0.21650634706020355, -0.21650634706020355, -0.4330126941204071, 0.4330126941204071, 0.0, -1.0825317353010178, -0.21650634706020355, -0.21650634706020355, 0.6495190411806107, 0.8660253882408142, 0.21650634706020355, -0.21650634706020355, -0.4330126941204071, 0.21650634706020355, -0.4330126941204071, -0.8660253882408142, 0.4330126941204071, 0.21650634706020355, 0.8660253882408142, 0.0, 0.4330126941204071, 0.21650634706020355, 0.21650634706020355, -0.21650634706020355, 0.0, 0.0, 0.0, -0.21650634706020355, 0.4330126941204071, 1.0825317353010178, -0.4330126941204071, 0.21650634706020355, 1.0825317353010178, -0.4330126941204071, 1.0825317353010178, 0.0, -0.8660253882408142, 0.21650634706020355, 0.8660253882408142, 0.0, 0.21650634706020355, 0.21650634706020355, 0.0, 0.21650634706020355, 0.6495190411806107, 0.6495190411806107, 0.0, -0.6495190411806107, 0.21650634706020355, -0.4330126941204071, 0.4330126941204071, 0.21650634706020355, 0.6495190411806107, -0.6495190411806107, 0.4330126941204071, 0.6495190411806107, 0.0, 0.4330126941204071, 0.0, 0.21650634706020355, 0.4330126941204071], 2: [0.0, -0.4330126941204071, -0.4330126941204071, 0.21650634706020355, -0.21650634706020355, -0.4330126941204071, 0.4330126941204071, 0.0, -1.0825317353010178, -0.21650634706020355, -0.21650634706020355, 0.6495190411806107, 0.8660253882408142, 0.21650634706020355, -0.21650634706020355, -0.4330126941204071, 0.21650634706020355, -0.4330126941204071, -0.8660253882408142, 0.4330126941204071, 0.21650634706020355, 0.8660253882408142, 0.0, 0.4330126941204071, 0.21650634706020355, 0.21650634706020355, -0.21650634706020355, 0.0, 0.0, 0.0, -0.21650634706020355, 0.4330126941204071, 1.0825317353010178, -0.4330126941204071, 0.21650634706020355, 1.0825317353010178, -0.4330126941204071, 1.0825317353010178, 0.0, -0.8660253882408142, 0.21650634706020355, 0.8660253882408142, 0.0, 0.21650634706020355, 0.21650634706020355, 0.0, 0.21650634706020355, 0.6495190411806107, 0.6495190411806107, 0.0, -0.6495190411806107, 0.21650634706020355, -0.4330126941204071, 0.4330126941204071, 0.21650634706020355, 0.6495190411806107, -0.6495190411806107, 0.4330126941204071, 0.6495190411806107, 0.0, 0.4330126941204071, 0.0, 0.21650634706020355, 0.4330126941204071], 3: [0.0, -0.4330126941204071, -0.4330126941204071, 0.21650634706020355, -0.21650634706020355, -0.4330126941204071, 0.4330126941204071, 0.0, -1.0825317353010178, -0.21650634706020355, -0.21650634706020355, 0.6495190411806107, 0.8660253882408142, 0.21650634706020355, -0.21650634706020355, -0.4330126941204071, 0.21650634706020355, -0.4330126941204071, -0.8660253882408142, 0.4330126941204071, 0.21650634706020355, 0.8660253882408142, 0.0, 0.4330126941204071, 0.21650634706020355, 0.21650634706020355, -0.21650634706020355, 0.0, 0.0, 0.0, -0.21650634706020355, 0.4330126941204071, 1.0825317353010178, -0.4330126941204071, 0.21650634706020355, 1.0825317353010178, -0.4330126941204071, 1.0825317353010178, 0.0, -0.8660253882408142, 0.21650634706020355, 0.8660253882408142, 0.0, 0.21650634706020355, 0.21650634706020355, 0.0, 0.21650634706020355, 0.6495190411806107, 0.6495190411806107, 0.0, -0.6495190411806107, 0.21650634706020355, -0.4330126941204071, 0.4330126941204071, 0.21650634706020355, 0.6495190411806107, -0.6495190411806107, 0.4330126941204071, 0.6495190411806107, 0.0, 0.4330126941204071, 0.0, 0.21650634706020355, 0.4330126941204071], 4: [0.0, -0.4330126941204071, -0.4330126941204071, 0.21650634706020355, -0.21650634706020355, -0.4330126941204071, 0.4330126941204071, 0.0, -1.0825317353010178, -0.21650634706020355, -0.21650634706020355, 0.6495190411806107, 0.8660253882408142, 0.21650634706020355, -0.21650634706020355, -0.4330126941204071, 0.21650634706020355, -0.4330126941204071, -0.8660253882408142, 0.4330126941204071, 0.21650634706020355, 0.8660253882408142, 0.0, 0.4330126941204071, 0.21650634706020355, 0.21650634706020355, -0.21650634706020355, 0.0, 0.0, 0.0, -0.21650634706020355, 0.4330126941204071, 1.0825317353010178, -0.4330126941204071, 0.21650634706020355, 1.0825317353010178, -0.4330126941204071, 1.0825317353010178, 0.0, -0.8660253882408142, 0.21650634706020355, 0.8660253882408142, 0.0, 0.21650634706020355, 0.21650634706020355, 0.0, 0.21650634706020355, 0.6495190411806107, 0.6495190411806107, 0.0, -0.6495190411806107, 0.21650634706020355, -0.4330126941204071, 0.4330126941204071, 0.21650634706020355, 0.6495190411806107, -0.6495190411806107, 0.4330126941204071, 0.6495190411806107, 0.0, 0.4330126941204071, 0.0, 0.21650634706020355, 0.4330126941204071]}}
embeddings = pd.DataFrame.from_dict(hashGNN_embeddings)
embeddings_as_numpy_array = np.array(embeddings.embedding.to_list())
tsne = TSNE(n_components=2, perplexity=3.0, verbose=1, random_state=50)

# ----> The next line will cause the Kernel crash with the following message:
#       "[error] Disposing session as kernel process died ExitCode: undefined, Reason:"
two_dimension_node_embeddings = tsne.fit_transform(embeddings_as_numpy_array)

Expected Results

No Kernel crash.

Actual Results

{
	"name": "",
	"message": "",
	"stack": "The Kernel crashed while executing code in the current cell or a previous cell. 
Please review the code in the cell(s) to identify a possible cause of the failure. 
Click <a href='https://aka.ms/vscodeJupyterKernelCrash'>here</a> for more info. 
View Jupyter <a href='command:jupyter.viewOutput'>log</a> for further details."
}

Versions

System:
    python: 3.11.9 | packaged by conda-forge | (main, Apr 19 2024, 18:34:54) [Clang 16.0.6 ]
executable: /opt/homebrew/Caskroom/miniforge/base/envs/tsne-bug-reproducer-environment/bin/python
   machine: macOS-14.4.1-arm64-arm-64bit

Python dependencies:
      sklearn: 1.5.0
          pip: 24.0
   setuptools: 70.0.0
        numpy: 1.23.5
        scipy: 1.13.1
       Cython: None
       pandas: 1.5.3
   matplotlib: 3.6.3
       joblib: 1.4.2
threadpoolctl: 3.5.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
    num_threads: 8
         prefix: libopenblas
       filepath: /opt/homebrew/Caskroom/miniforge/base/envs/tsne-bug-reproducer-environment/lib/libopenblas.0.dylib
        version: 0.3.27
threading_layer: openmp
   architecture: VORTEX

       user_api: openmp
   internal_api: openmp
    num_threads: 8
         prefix: libomp
       filepath: /opt/homebrew/Caskroom/miniforge/base/envs/tsne-bug-reproducer-environment/lib/libomp.dylib
        version: None

Activity

  1. added
    Needs Triage
    on May 28, 2024
  2. lesteve commented on May 28, 2024

    @lesteve
    Member

    Thanks for the reproducing snippet, this is a duplicate of #28368, there is a bit more information there, so I am going to close this issue.

    Note for other maintainers: I can reproduce on Linux so this is not OSX specific and this is not a regression in 1.5 since this existed already in 1.4.

  3. JohT commented on May 28, 2024

    @JohT
    Author

    Thanks👍

    If it is of any help for you @lesteve: I can confirm that this isn't a regression of version 1.5 I could also reproduce it with sklearn version 1.2.2. I couldn't try out older versions because of version conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugNeeds Triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions