ProvideQ / toolbox-server

Resources for the server that hosts the toolbox (Backend)
https://provideq.kit.edu
MIT License
1 stars 1 forks source link

Broken pipeline: qiskit maxcut test #58

Closed schweikart closed 9 months ago

schweikart commented 9 months ago

The pipeline currently fails since the Qiskit MaxCut test fails.

...
> Task :test

MaxCutSolversTest > testMaxCutSolver(String, String) > edu.kit.provideq.toolbox.api.MaxCutSolversTest.testMaxCutSolver(String, String)[3] FAILED
    java.lang.AssertionError at MaxCutSolversTest.java:82

17 tests completed, 1 failed
...

(https://github.com/ProvideQ/toolbox-server/actions/runs/6862259458/job/18659599235)

This test case succeeds when testing locally. Maybe it's due to a breaking change in a dependency package?

schweikart commented 9 months ago

The corresponding test report reveals that the max cut test fails with the [3-nodes-3-edges.txt]() test case for the QiskitSolver:

[3] solverId=edu.kit.provideq.toolbox.maxcut.solvers.QiskitMaxCutSolver, content=graph [ id 42 node [ id 1 label "1" ] node [ id 2 label "2" ] node [ id 3 label "3" ] edge [ source 1 target 2 ] edge [ source 2 target 3 ] edge [ source 3 target 1 ] ]
java.lang.AssertionError: 
Expected: is <SOLVED>
     but: was <ERROR>
    at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
...

The standard output tab of this test debug-prints the http response which contains the python output of that execution (un-escaped using https://www.freeformatter.com/java-dotnet-escape.html#before-output):

MAX_CUT problem couldn't be solved:
/__w/toolbox-server/toolbox-server/qiskit/max-cut/maxCut_qiskit.py:23: DeprecationWarning: ``qiskit.algorithms`` has been migrated to an independent package: https://github.com/qiskit-community/qiskit-algorithms. The ``qiskit.algorithms`` import path is deprecated as of qiskit-terra 0.25.0 and will be removed no earlier than 3 months after the release date. Please run ``pip install qiskit_algorithms`` and use ``import qiskit_algorithms`` instead.
  from qiskit.algorithms import VQE, NumPyMinimumEigensolver
/__w/toolbox-server/toolbox-server/qiskit/max-cut/maxCut_qiskit.py:72: DeprecationWarning: The class ``qiskit.utils.quantum_instance.QuantumInstance`` is deprecated as of qiskit-terra 0.24.0. It will be removed no earlier than 3 months after the release date. For code migration guidelines, visit https://qisk.it/qi_migration.
  quantum_instance = QuantumInstance(backend, seed_simulator=seed, seed_transpiler=seed)
/__w/toolbox-server/toolbox-server/qiskit/max-cut/maxCut_qiskit.py:77: DeprecationWarning: The class ``qiskit.algorithms.minimum_eigen_solvers.vqe.VQE`` is deprecated as of qiskit-terra 0.24.0. It will be removed no earlier than 3 months after the release date. Instead, use the class ``qiskit.algorithms.minimum_eigensolvers.VQE``. See https://qisk.it/algo_migration for a migration guide.
  vqe = VQE(ry, optimizer=spsa, quantum_instance=quantum_instance)
Traceback (most recent call last):
  File "/__w/toolbox-server/toolbox-server/qiskit/max-cut/maxCut_qiskit.py", line 80, in <module>
    result = vqe.compute_minimum_eigenvalue(qubitOp)
  File "/opt/conda/envs/gams/lib/python3.10/site-packages/qiskit/algorithms/minimum_eigen_solvers/vqe.py", line 535, in compute_minimum_eigenvalue
    energy_evaluation, expectation = self.get_energy_evaluation(
  File "/opt/conda/envs/gams/lib/python3.10/site-packages/qiskit/algorithms/minimum_eigen_solvers/vqe.py", line 612, in get_energy_evaluation
    expect_op, expectation = self.construct_expectation(
  File "/opt/conda/envs/gams/lib/python3.10/site-packages/qiskit/algorithms/minimum_eigen_solvers/vqe.py", line 430, in construct_expectation
    expectation = ExpectationFactory.build(
  File "/opt/conda/envs/gams/lib/python3.10/site-packages/qiskit/utils/deprecation.py", line 95, in wrapper
    return func(*args, **kwargs)
  File "/opt/conda/envs/gams/lib/python3.10/site-packages/qiskit/opflow/expectations/expectation_factory.py", line 72, in build
    primitives = operator.primitive_strings()
AttributeError: 'SparsePauliOp' object has no attribute 'primitive_strings'
schweikart commented 9 months ago

While running the project locally does not raise this error, running it locally inside a docker container does. I think this makes it more likely that this is a dependency issue.

Packages in my local docker container:

Package                  Version
------------------------ ------------
anyio                    4.0.0
asttokens                2.4.1
attrs                    21.4.0
beautifulsoup4           4.12.2
bleach                   6.1.0
cachetools               5.3.2
Cerberus                 1.3.5
certifi                  2023.7.22
charset-normalizer       3.3.2
cirq                     1.2.0
cirq-aqt                 1.2.0
cirq-core                1.2.0
cirq-ft                  1.2.0
cirq-google              1.2.0
cirq-ionq                1.2.0
cirq-pasqal              1.2.0
cirq-rigetti             1.2.0
cirq-web                 1.2.0
comm                     0.2.0
contourpy                1.2.0
cycler                   0.12.1
decorator                5.1.1
defusedxml               0.7.1
dill                     0.3.7
docplex                  2.25.236
duet                     0.2.9
et-xmlfile               1.1.0
exceptiongroup           1.1.3
executing                2.0.1
fastjsonschema           2.18.1
fonttools                4.44.1
GAMS                     42.1.0
google-api-core          2.14.0
google-auth              2.23.4
googleapis-common-protos 1.61.0
greenlet                 3.0.1
grpcio                   1.59.2
grpcio-status            1.59.2
h11                      0.14.0
httpcore                 0.16.3
httpx                    0.23.3
idna                     3.4
ipython                  8.17.2
ipywidgets               8.1.1
iso8601                  1.1.0
jedi                     0.19.1
Jinja2                   3.1.2
jsonschema               4.17.3
jupyter_client           8.6.0
jupyter_core             5.5.0
jupyterlab-pygments      0.2.2
jupyterlab-widgets       3.0.9
kiwisolver               1.4.5
lark                     0.11.3
MarkupSafe               2.1.3
matplotlib               3.8.1
matplotlib-inline        0.1.6
mistune                  3.0.2
mpmath                   1.3.0
msgpack                  1.0.7
nbclient                 0.9.0
nbconvert                7.11.0
nbformat                 5.9.2
networkx                 2.8.8
numpy                    1.26.2
openpyxl                 3.1.2
packaging                23.2
pandas                   2.1.3
pandocfilters            1.5.0
parso                    0.8.3
pbr                      6.0.0
pexpect                  4.8.0
Pillow                   10.1.0
pip                      23.3
platformdirs             4.0.0
ply                      3.11
prompt-toolkit           3.0.41
proto-plus               1.22.3
protobuf                 4.25.0
psutil                   5.9.6
ptyprocess               0.7.0
pure-eval                0.2.2
py                       1.11.0
pyasn1                   0.5.0
pyasn1-modules           0.3.0
pydantic                 1.10.13
Pygments                 2.16.1
pygmlparser              1.0.1
PyJWT                    2.8.0
pyodbc                   5.0.1
pyparsing                3.1.1
pyquil                   3.2.1
pyrsistent               0.20.0
python-dateutil          2.8.2
python-rapidjson         1.13
pytz                     2023.3.post1
PyYAML                   6.0.1
pyzmq                    25.1.1
qcs-api-client           0.21.6
qiskit                   0.44.3
qiskit-aer               0.13.0
qiskit-algorithms        0.2.1
qiskit-optimization      0.6.0
qiskit-terra             0.25.3
requests                 2.31.0
retry                    0.9.2
retrying                 1.3.4
rfc3339                  6.2
rfc3986                  1.5.0
rpcq                     3.11.0
rsa                      4.9
ruamel.yaml              0.18.5
ruamel.yaml.clib         0.2.8
rustworkx                0.13.2
scipy                    1.11.3
setuptools               68.0.0
six                      1.16.0
sniffio                  1.3.0
sortedcontainers         2.4.0
soupsieve                2.5
SQLAlchemy               2.0.23
stack-data               0.6.3
stevedore                5.1.0
symengine                0.9.2
sympy                    1.12
tinycss2                 1.2.1
toml                     0.10.2
tornado                  6.3.3
tqdm                     4.66.1
traitlets                5.13.0
typing_extensions        4.8.0
tzdata                   2023.3
urllib3                  2.1.0
wcwidth                  0.2.10
webencodings             0.5.1
wheel                    0.41.2
widgetsnbextension       4.0.9

Packages on my local machine:

Package                       Version
----------------------------- ---------
anyio                         4.0.0
argcomplete                   3.1.1
asttokens                     2.4.0
attrs                         21.4.0
backcall                      0.2.0
backports.functools-lru-cache 1.6.5
beautifulsoup4                4.12.2
black                         23.9.1
bleach                        6.0.0
cachetools                    5.3.1
Cerberus                      1.3.4
certifi                       2023.7.22
charset-normalizer            3.2.0
cirq                          1.2.0
cirq-aqt                      1.2.0
cirq-core                     1.2.0
cirq-ft                       1.2.0
cirq-google                   1.2.0
cirq-ionq                     1.2.0
cirq-pasqal                   1.2.0
cirq-rigetti                  1.2.0
cirq-web                      1.2.0
click                         8.1.7
comm                          0.1.4
contourpy                     1.1.0
cycler                        0.11.0
debugpy                       1.6.7
decorator                     5.1.1
defusedxml                    0.7.1
dill                          0.3.7
docplex                       2.25.236
duet                          0.2.9
entrypoints                   0.4
et-xmlfile                    1.1.0
exceptiongroup                1.1.3
executing                     1.2.0
fastjsonschema                2.18.0
fonttools                     4.42.1
GAMS                          44.1.0
google-api-core               2.11.1
google-auth                   2.22.0
googleapis-common-protos      1.60.0
greenlet                      2.0.2
grpcio                        1.58.0
grpcio-status                 1.58.0
h11                           0.14.0
httpcore                      0.16.3
httpx                         0.23.3
idna                          3.4
ipykernel                     6.26.0
ipython                       8.15.0
ipywidgets                    8.1.0
iso8601                       1.1.0
jedi                          0.19.0
Jinja2                        3.1.2
jsonschema                    4.17.3
jupyter-client                7.3.4
jupyter_core                  5.3.1
jupyterlab-pygments           0.2.2
jupyterlab-widgets            3.0.8
kiwisolver                    1.4.5
lark                          0.11.3
MarkupSafe                    2.1.3
matplotlib                    3.7.2
matplotlib-inline             0.1.6
mistune                       3.0.1
mkl-fft                       1.3.8
mkl-random                    1.2.4
mkl-service                   2.4.0
mpmath                        1.3.0
msgpack                       1.0.5
mypy-extensions               1.0.0
nbclient                      0.8.0
nbconvert                     7.8.0
nbformat                      5.9.2
nest-asyncio                  1.5.8
networkx                      2.8.8
numpy                         1.25.1
openpyxl                      3.1.2
packaging                     23.1
pandas                        2.0.3
pandocfilters                 1.5.0
parso                         0.8.3
pathspec                      0.11.2
pbr                           5.11.1
pexpect                       4.8.0
pickleshare                   0.7.5
Pillow                        10.0.0
pip                           23.2.1
pipx                          1.2.0
platformdirs                  3.10.0
ply                           3.11
prompt-toolkit                3.0.39
proto-plus                    1.22.3
protobuf                      4.24.3
psutil                        5.9.0
psycopg2-binary               2.9.6
ptyprocess                    0.7.0
pure-eval                     0.2.2
py                            1.11.0
pyasn1                        0.5.0
pyasn1-modules                0.3.0
pydantic                      1.10.12
Pygments                      2.16.1
pygmlparser                   1.0.1
PyJWT                         2.8.0
pymssql                       2.2.7
PyMySQL                       1.1.0
pyodbc                        4.0.39
pyparsing                     3.0.9
pyquil                        3.2.1
pyrsistent                    0.19.3
python-dateutil               2.8.2
python-rapidjson              1.10
pytz                          2023.3
PyYAML                        6.0.1
pyzmq                         25.1.0
qcs-api-client                0.21.6
qiskit                        0.44.0
qiskit-aer                    0.12.2
qiskit-algorithms             0.2.1
qiskit-optimization           0.5.0
qiskit-terra                  0.25.0
requests                      2.31.0
retry                         0.9.2
retrying                      1.3.4
rfc3339                       6.2
rfc3986                       1.5.0
rpcq                          3.11.0
rsa                           4.9
ruamel.yaml                   0.17.32
ruamel.yaml.clib              0.2.7
rustworkx                     0.13.0
scipy                         1.11.1
setuptools                    68.0.0
six                           1.16.0
sniffio                       1.3.0
sortedcontainers              2.4.0
soupsieve                     2.5
SQLAlchemy                    1.4.49
stack-data                    0.6.2
stevedore                     5.1.0
symengine                     0.9.2
sympy                         1.12
tinycss2                      1.2.1
toml                          0.10.2
tomli                         2.0.1
tornado                       6.1
tqdm                          4.66.1
traitlets                     5.13.0
typing_extensions             4.7.1
tzdata                        2023.3
urllib3                       1.26.16
userpath                      1.9.0
wcwidth                       0.2.10
webencodings                  0.5.1
wheel                         0.38.4
widgetsnbextension            4.0.8
schweikart commented 9 months ago

Downgrading qiskit-optimization from 0.6.0 (latest) to 0.5.0 seems to resolve the problem. The release notes for 0.6 mention a re-structuring of the project that resulted in the removal of opflow based algorithms. I've tried to upgrade the code to 0.6 but unfortunately our algorithm doesn't work with that anymore since the eigenstate property, which was used to determine the best result -- was removed from the VQE result. The migration guide unfortunately doesn't cover our use case.