Package: pyriemann-qiskit
pyRiemann-qiskitLitterature on quantum computing suggests it may offer an advantage as compared with
classical computing in terms of computational time and outcomes, such as for pattern
recognition or when using limited training sets [1, 2].A ubiquitous library on quantum computing is Qiskit [3]. Qiskit is an IBM library
distributed under Apache 2.0 which provides both quantum algorithms and backends. A
backend can be either your local machine or a remote machine, which one can emulates or be
a quantum machine. Qiskit abstraction over the type of machine you want to use, make
designing quantum algorithm seamless.Qiskit implements a quantum version of support vector -like classifiers, known as
quantum-enhanced support vector classifier (QSVC) and varitional quantum classifier (VQC)
[4]. These classifiers likely offer an advantage over classical SVM in situations where
the classification task is complex. Task complexity is raised by the encoding of the data
into a quantum state, the number of available data and the quality of the data. An initial
study is available in [5], and it can be downloaded fromhere. Although there is no study on this
topic at the time of writting, this could be an interesting research direction to
investigate BCI illiteracy.pyRiemann-qiskit implements a wrapper around QSVC and VQC, to use quantum classification
with Riemannian geometry. A use case would be to use vectorized covariance matrices in the
tangent space as an input for these classifiers, enabling a possible sandbox for
researchers and engineers in the field.The remaining details some of the quantum drawbacks and will guide you through
installation. Full documentation, including API description, is available athttps://pyriemann-qiskit.readthedocs.io/. The repository also includes awikiwhere you can find additional
information.Quantum drawbacksLimitation of the feature dimensionThe number of qubits (and therefore the feature dimension) is limited to:24 on a local quantum simulator, and up to:5000 on a remote quantum simulator;5 on free real quantum computers, and up to:65 on exploratory quantum computers (not available for public use).Time complexityA higher number of trials or dimension increases time to completion of the quantum
algorithm, especially when running on a local machine. This is why the number of trials
is limited in the examples we provided. However, you should avoid such practices in your
own analysis.Although these aspects are less important in a remote backend, it may happen that the
quantum algorithm is queued depending on the number of concurrent users.For all these aspects, the use of pyRiemann-qiskit should be limited to offline analysis
only.References[1] A. Blance and M. Spannowsky, ‘Quantum machine learning for particle physics using a
variational quantum classifier’, J. High Energ. Phys., vol. 2021, no. 2, p. 212, Feb.
2021,https://doi.org/10.1007/JHEP02(2021)212[2] P. Rebentrost, M. Mohseni, and S. Lloyd, ‘Quantum Support Vector Machine for Big Data
Classification’, Phys. Rev. Lett., vol. 113, no. 13, p. 130503, Sep. 2014,https://doi.org/10.1103/PhysRevLett.113.130503[3] H. Abraham et al., Qiskit: An Open-source Framework for Quantum Computing. Zenodo,
2019,https://doi.org/10.5281/zenodo.2562110.[4] V. Havlíček et al., ‘Supervised learning with quantum-enhanced feature spaces’,
Nature, vol. 567, no. 7747, pp. 209–212, Mar. 2019,https://doi.org/10.1038/s41586-019-0980-2[5] G. Cattan, A. Andreev, First steps to the classification of ERPs using quantum
computation, NTB Berlin 2022 - International Forum on Neural Engineering & Brain
Technologies, May 2022, Berlin, Germany,https://hal.archives-ouvertes.fr/hal-03672246/How to cite?Anton Andreev, Grégoire Cattan, Sylvain Chevallier, and Quentin Barthélemy.
‘PyRiemann-Qiskit: A Sandbox for Quantum Classification Experiments with Riemannian
Geometry’. Research Ideas and Outcomes 9 (20 March 2023).https://doi.org/10.3897/rio.9.e101006.InstallationWe recommend the use ofAnacondato manage python
environements.pyRiemann-qiskitcurrently supports Windows, Mac and Linux OS with Python 3.8 and 3.9.You can installpyRiemann-qiskitrelease from PyPI:pip install pyriemann-qiskitThe development version can be installed by cloning this repository and installing the
package on your local machine using thesetup.pyscript:python setup.py developOr directly pip:pip install .Note that the steps above need to be re-executed in your local environment after any
changes inside your local copy of thepyriemann_qiskitfolder, including pulling from
remote.To check the installation, open a python shell and type:import pyriemann_qiskitTo enable Qiskit GPU optimization when using quantum simulation, run:pip install .[optim]Note, Qiskit only provide binaries for Linux. For other platforms, or if you want to
enable specific NVIDIA optimization for quantum, you need to build the binaryyourself.To run a specific example on your local machine, you should install first dependencies for
the documentation:pip install .[docs]Then you can run the python example of your choice like:python examples\ERP\classify_P300_bi.pyInstallation with dockerWe also offer the possibility to set up the dev environment within docker. To this end, we
recommand to usevscodewith theRemote Containersextension from Microsoft.Once the installation is successful, just open the project invscodeand enterF1. In
the search bar that opens, typeRebuild and Reopen Container.Wait for the container to build, and open a python shell within the container. Then ensure
everything went smoothly by typing:import pyriemann_qiskitAlternatively you can from the console (Windows or Linux) build the docker image from our
Dockerfile. Go to the root folder of pyRiemann-qiskit and type:docker build -t pyrq .Next usedocker run --detach pyrqto enter the pyRiemann-qiskit image.If you wish, you can also download docker images directly from github docker registry:https://github.com/pyRiemann/pyRiemann-qiskit/pkgs/container/pyriemann-qiskitThey are pushed to the docker registry on each release.Contributor GuidelinesEveryone is welcome to contribute to this repository. There are two types of
contributions:Raise an issueon the
repository. Issues can be either a bug report or an enhancement proposal. Note that it
is necessary to register on GitHub before. There is no special template that is expected
but, if you raise a defect please provide as many details as possible.Raise a pull request. Fork the
repository and work on your own branch. Then raise a pull request with your branch
against master. As much as possible, we ask you to:avoid merging master into your branch. Always prefer git rebase.always provide full documentation of public methods.Code contribution (pull request) can be either on core functionalities, documentation or
automation.The core functionalities are based onPython,pyRiemann,Qiskit MLand follow the best
practice fromscikit-learn. We useflake8for code formatting.flake8is installed with the testing dependencies (see
below) or can be installed directly frompip:pip install flake8To executeflake8, just typeflake8from the root repository, and correct all errors
related to your changes.The documentation is based onSphinx.Automation is based onGitHub Actionandpytest. It consists in two automated
workflows for running the example and the tests. To run the tests on your local machine,
you should first install the dependencies for testing:pip install .[tests]and then typepytestfrom the root repository. You can also specify a file like:pytest tests/test_classification.pyWorkflows are automatically triggered when you push a commit. However, the workflow for
example execution is only triggered when you modify one of the examples or the
documentation as the execution takes a lot of time. You can enableGithub Actionsin your fork to see the result of the CI pipeline. Results are also indicated at the end
of your pull request when raised. However note, that workflows in the pull request need
approval from the maintainers before being executed.TroubleshootingVersion of pyRiemann not updatedThere is a known issue when you installpyRiemann-qiskitin an environement where there
is alreadypyRiemanninstalled. In such case, thepyRiemannversion is not updated.
Therefore before installing or updatingpyRiemann-qiskit, we recommend to installpyRiemannas it follows:pip uninstall pyriemann
pip install pyriemann@git+https://github.com/pyRiemann/pyRiemann#egg=pyriemannFirebase admin not loadingIn some environment, the firebase admin module is not loaded. There is two reasons:The protobuf package is missing an__init__.pyfile. You can fix this issue by adding
it manually as it is done in the DockerFile:touch /usr/local/lib/python3.8/site-packages/protobuf-4.22.1-py3.8-linux-x86_64.egg/google/__init__.pyThe Firestore service contains unused dependency togoogle.cloud.location. You can
fix this issue by removing the dependencies manually, as it is done in the DockerFile
too:sed -i 's/from google.cloud.location import locations_pb2//g' '/usr/local/lib/python3.8/site-packages/google_cloud_firestore-2.10.1-py3.8.egg/google/cloud/firestore_v1/services/firestore/client.py'
sed -i 's/from google.cloud.location import locations_pb2//g' '/usr/local/lib/python3.8/site-packages/google_cloud_firestore-2.10.1-py3.8.egg/google/cloud/firestore_v1/services/firestore/transports/base.py'
sed -i 's/from google.cloud.location import locations_pb2//g' '/usr/local/lib/python3.8/site-packages/google_cloud_firestore-2.10.1-py3.8.egg/google/cloud/firestore_v1/services/firestore/transports/grpc.py'
sed -i 's/from google.cloud.location import locations_pb2//g' '/usr/local/lib/python3.8/site-packages/google_cloud_firestore-2.10.1-py3.8.egg/google/cloud/firestore_v1/services/firestore/transports/grpc_asyncio.py'
sed -i 's/from google.cloud.location import locations_pb2//g' '/usr/local/lib/python3.8/site-packages/google_cloud_firestore-2.10.1-py3.8.egg/google/cloud/firestore_v1/services/firestore/transports/rest.py'
sed -i 's/from google.cloud.location import locations_pb2//g' '/usr/local/lib/python3.8/site-packages/google_cloud_firestore-2.10.1-py3.8.egg/google/cloud/firestore_v1/services/firestore/async_client.py'