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

Spyder kernel dies and restarts when trying to use lightning.qubit device #23173

Closed
JacksonPhoong opened this issue Dec 4, 2024 · 4 comments
Closed

Comments

@JacksonPhoong
Copy link

Description

What steps will reproduce the problem?

I'm trying to use lightning.qubit device but the kernel dies and restarts. I've restarted Spyder and the issue persists. I get the issue when running the following code:

import pennylane as qml
dev = qml.device("lightning.qubit", wires=4)

Versions

  • Spyder version: 6.0.2 (standalone)
  • Python version: 3.11.10 64-bit
  • Qt version: 5.15.8
  • PyQt5 version: 5.15.9
  • Operating System: Windows-10-10.0.19045-SP0

Dependencies

# Mandatory:
aiohttp >=3.9.3                  :  3.10.10 (OK)
asyncssh >=2.14.0,<3.0.0         :  2.18.0 (OK)
atomicwrites >=1.2.0             :  1.4.1 (OK)
chardet >=2.0.0                  :  5.2.0 (OK)
cloudpickle >=0.5.0              :  3.1.0 (OK)
cookiecutter >=1.6.0             :  2.6.0 (OK)
diff_match_patch >=20181111      :  20241021 (OK)
github >=2.3.0                   :  2.4.0 (OK)
importlib_metadata >=4.6.0       :  8.5.0 (OK)
intervaltree >=3.0.2             :  3.1.0 (OK)
IPython >=8.13.0,<9.0.0,!=8.17.1 :  8.29.0 (OK)
jedi >=0.17.2,<0.20.0            :  0.19.1 (OK)
jellyfish >=0.7                  :  1.1.0 (OK)
jsonschema >=3.2.0               :  4.23.0 (OK)
keyring >=17.0.0                 :  25.5.0 (OK)
nbconvert >=4.0                  :  7.16.4 (OK)
numpydoc >=0.6.0                 :  1.8.0 (OK)
parso >=0.7.0,<0.9.0             :  0.8.4 (OK)
pexpect >=4.4.0                  :  4.9.0 (OK)
pickleshare >=0.4                :  0.7.5 (OK)
psutil >=5.3                     :  6.1.0 (OK)
pygments >=2.0                   :  2.18.0 (OK)
pylint >=3.1,<4                  :  3.3.1 (OK)
pylint_venv >=3.0.2              :  3.0.4 (OK)
pyls_spyder >=0.4.0              :  0.4.0 (OK)
pylsp >=1.12.0,<1.13.0           :  1.12.0 (OK)
pylsp_black >=2.0.0,<3.0.0       :  2.0.0 (OK)
pyuca >=1.2                      :  1.2 (OK)
qdarkstyle >=3.2.0,<3.3.0        :  3.2.3 (OK)
qstylizer >=0.2.2                :  0.2.3 (OK)
qtawesome >=1.3.1,<1.4.0         :  1.3.1 (OK)
qtconsole >=5.6.1,<5.7.0         :  5.6.1 (OK)
qtpy >=2.4.0                     :  2.4.1 (OK)
rtree >=0.9.7                    :  1.3.0 (OK)
setuptools >=49.6.0              :  75.3.0 (OK)
sphinx >=0.6.6                   :  8.1.3 (OK)
spyder_kernels >=3.0.1,<3.1.0    :  3.0.1 (OK)
superqt >=0.6.2,<1.0.0           :  0.6.7 (OK)
textdistance >=4.2.0             :  4.6.2 (OK)
three_merge >=0.1.1              :  0.1.1 (OK)
watchdog >=0.10.3                :  5.0.3 (OK)
yarl >=1.9.4                     :  1.16.0 (OK)
zmq >=24.0.0                     :  26.2.0 (OK)

# Optional:
cython >=0.21                    :  3.0.11 (OK)
matplotlib >=3.0.0               :  3.9.2 (OK)
numpy >=1.7                      :  2.1.2 (OK)
pandas >=1.1.1                   :  2.2.3 (OK)
scipy >=0.17.0                   :  1.14.1 (OK)
sympy >=0.7.3                    :  1.13.3 (OK)

Environment

Environment
Package                       Version
----------------------------- --------------
aiohappyeyeballs              2.4.3
aiohttp                       3.11.7
aiosignal                     1.3.1
alabaster                     1.0.0
anyio                         4.6.2.post1
appdirs                       1.4.4
argon2-cffi                   23.1.0
argon2-cffi-bindings          21.2.0
arrow                         1.3.0
astroid                       3.3.5
asttokens                     2.4.1
async-lru                     2.0.4
asyncssh                      2.18.0
atomicwrites                  1.4.1
attrs                         24.2.0
autograd                      1.7.0
autopep8                      2.0.4
autoray                       0.7.0
babel                         2.16.0
beautifulsoup4                4.12.3
binaryornot                   0.4.4
black                         24.10.0
bleach                        6.2.0
cachetools                    5.5.0
certifi                       2024.8.30
cffi                          1.17.1
chardet                       5.2.0
charset-normalizer            3.4.0
clarabel                      0.9.0
click                         8.1.7
cloudpickle                   3.1.0
colorama                      0.4.6
comm                          0.2.2
contourpy                     1.3.0
cookiecutter                  2.6.0
cryptography                  43.0.3
cvxpy                         1.6.0
cycler                        0.12.1
Cython                        3.0.11
debugpy                       1.8.7
decorator                     5.1.1
defusedxml                    0.7.1
Deprecated                    1.2.15
diff-match-patch              20241021
dill                          0.3.9
docstring-to-markdown         0.15
docutils                      0.21.2
executing                     2.1.0
fastjsonschema                2.20.0
flake8                        7.1.1
fonttools                     4.54.1
fqdn                          1.5.1
frozenlist                    1.5.0
h11                           0.14.0
httpcore                      1.0.7
httpx                         0.27.2
idna                          3.10
imagesize                     1.4.1
importlib_metadata            8.5.0
inflection                    0.5.1
intervaltree                  3.1.0
ipykernel                     6.29.5
ipython                       8.29.0
isoduration                   20.11.0
isort                         5.13.2
jaraco.classes                3.4.0
jaraco.context                6.0.1
jaraco.functools              4.1.0
jedi                          0.19.1
jellyfish                     1.1.0
Jinja2                        3.1.4
json5                         0.9.28
jsonpointer                   3.0.0
jsonschema                    4.23.0
jsonschema-specifications     2024.10.1
jupyter_client                8.6.3
jupyter_core                  5.7.2
jupyter-events                0.10.0
jupyter-lsp                   2.2.5
jupyter_server                2.14.2
jupyter_server_terminals      0.5.3
jupyterlab                    4.2.6
jupyterlab_pygments           0.3.0
jupyterlab_server             2.27.3
keyring                       25.5.0
kiwisolver                    1.4.7
markdown-it-py                3.0.0
MarkupSafe                    3.0.2
matplotlib                    3.9.2
matplotlib-inline             0.1.7
mccabe                        0.7.0
mdurl                         0.1.2
mistune                       3.0.2
more-itertools                10.5.0
mpmath                        1.3.0
multidict                     6.1.0
mypy-extensions               1.0.0
nbclient                      0.10.0
nbconvert                     7.16.4
nbformat                      5.10.4
nest-asyncio                  1.6.0
networkx                      3.4.2
notebook                      7.2.2
notebook_shim                 0.2.4
numpy                         1.26.4
numpydoc                      1.8.0
osqp                          0.6.7.post3
overrides                     7.7.0
packaging                     24.1
pandas                        2.2.3
pandocfilters                 1.5.1
parso                         0.8.4
pathspec                      0.12.1
PennyLane                     0.38.0
PennyLane_Lightning           0.38.0
pexpect                       4.9.0
pickleshare                   0.7.5
pillow                        11.0.0
pip                           24.3.1
platformdirs                  4.3.6
pluggy                        1.5.0
prometheus_client             0.21.0
prompt_toolkit                3.0.48
propcache                     0.2.0
psutil                        6.1.0
ptyprocess                    0.7.0
pure_eval                     0.2.3
pycodestyle                   2.12.1
pycparser                     2.22
pydocstyle                    6.3.0
pyflakes                      3.2.0
PyGithub                      2.5.0
Pygments                      2.18.0
PyJWT                         2.10.0
pylint                        3.3.1
pylint-venv                   3.0.4
pyls-spyder                   0.4.0
PyNaCl                        1.5.0
pyparsing                     3.2.0
PyQt5                         5.15.11
PyQt5-Qt5                     5.15.2
PyQt5_sip                     12.15.0
PyQtWebEngine                 5.15.7
PyQtWebEngine-Qt5             5.15.2
python-dateutil               2.9.0.post0
python-json-logger            2.0.7
python-lsp-black              2.0.0
python-lsp-jsonrpc            1.1.2
python-lsp-server             1.12.0
python-slugify                8.0.4
pytoolconfig                  1.3.1
pytz                          2024.2
pyuca                         1.2
pywin32                       308
pywin32-ctypes                0.2.3
pywinpty                      2.0.14
PyYAML                        6.0.2
pyzmq                         26.2.0
QDarkStyle                    3.2.3
qdldl                         0.1.7.post4
qstylizer                     0.2.4
QtAwesome                     1.3.1
qtconsole                     5.6.1
QtPy                          2.4.2
referencing                   0.35.1
requests                      2.32.3
rfc3339-validator             0.1.4
rfc3986-validator             0.1.1
rich                          13.9.4
rope                          1.13.0
rpds-py                       0.21.0
Rtree                         1.3.0
rustworkx                     0.15.1
scipy                         1.14.1
scs                           3.2.7
Send2Trash                    1.8.3
setuptools                    75.6.0
six                           1.16.0
sniffio                       1.3.1
snowballstemmer               2.2.0
sortedcontainers              2.4.0
soupsieve                     2.6
Sphinx                        8.1.3
sphinxcontrib-applehelp       2.0.0
sphinxcontrib-devhelp         2.0.0
sphinxcontrib-htmlhelp        2.1.0
sphinxcontrib-jsmath          1.0.1
sphinxcontrib-qthelp          2.0.0
sphinxcontrib-serializinghtml 2.0.0
spyder                        6.0.2
spyder-kernels                3.0.1
spyder-notebook               0.6.1
stack-data                    0.6.3
superqt                       0.6.7
sympy                         1.13.3
tabulate                      0.9.0
terminado                     0.18.1
text-unidecode                1.3
textdistance                  4.6.3
three-merge                   0.1.1
tinycss2                      1.4.0
toml                          0.10.2
tomlkit                       0.13.2
tornado                       6.4.1
traitlets                     5.14.3
types-python-dateutil         2.9.0.20241003
typing_extensions             4.12.2
tzdata                        2024.2
ujson                         5.10.0
uri-template                  1.3.0
urllib3                       2.2.3
watchdog                      6.0.0
wcwidth                       0.2.13
webcolors                     24.11.1
webencodings                  0.5.1
websocket-client              1.8.0
whatthepatch                  1.0.7
wrapt                         1.17.0
yapf                          0.43.0
yarl                          1.18.0
zipp                          3.21.0

@JacksonPhoong
Copy link
Author

Hey, sorry that I kept opening and closing this issue. I wasn't sure it was Spyder or Pennylane's issue and I couldn't pinpoint it at first. At one point, I thought I had fixed the issue on my end but it turned out that wasn't the case. After doing some digging, I think the issue is due to some weird interaction between Spyder and Pennylane that I can't understand. You can correct me if I'm wrong.

So the simplest way to recreate this problem for me is to do the following:

python -m venv venv-test
.\venv-test\Scripts\activate
pip install spyder-kernels
pip install pennylane

With a new virtual environment, the code from my previous comment works. However if I add one extra step:

pip install spyder-notebook

Then I get the error:

 The kernel died, restarting...

I did some debugging and the culprit seems to be the following:

from pennylane_lightning.lightning_qubit_ops import StateVectorC128
StateVectorC128(1)

Running the above snippet will result in the same issue of the kernel dying and restarting. I tried to debug further and it brought me into a file that checks the version of numpy. I don't understand what's causing the issue there so that's where I stopped.

I'm sorry if this issue has nothing to do with Spyder. I can make do with using Spyder and Pennylane without the spyder-notebook plugin as mentioned above. I don't know if you guys can do anything about this but I just thought I should raise the issue anyway. Thank you for reading.

@JacksonPhoong JacksonPhoong reopened this Dec 11, 2024
@ccordoba12
Copy link
Member

Hey @JacksonPhoong, thanks for reporting. You said:

With a new virtual environment, the code from my previous comment works. However if I add one extra step:

pip install spyder-notebook

If things are working fine for you before installing spyder-notebook, then please uninstall it. You won't be able to use it with our standalone installer (the installation method you're using) because right now it's not possible to use external Spyder plugins in our standalone installers.

Let us know if that works for you.

@JacksonPhoong
Copy link
Author

Actually, I am able to use spyder-notebook if I run Spyder using cmd as mentioned in #23111.

But yes, that works for me.

@ccordoba12
Copy link
Member

But yes, that works for me.

Ok, good to know. It's very strange that Spyder-notebook interferes with the pennylane package, but at least you found a way to make it work without it.

@ccordoba12 ccordoba12 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants