Marcel Seelbach Benkner1, Maximilian Krahn2,3, Edith Tretschk2, Zorah Lähner1, Michael Möller1, and Vladislav Golyanik2
1 University of Siegen , 2Max Planck Institute for Informatics, 3 Aalto University.
This is the official repository for the project "QuAnt: Quantum Annealing with Learnt Couplings". In this work the coupling matrices for a quantum annealer are learnt with a neural network. The preprint can be found at https://arxiv.org/abs/2210.08114 and the project page is at https://4dqv.mpi-inf.mpg.de/QuAnt/. The code can be executed with PyTorch and the D-Wave ocean sdk. To run the code without a quantum annealer on can use D-Wave neal instead of a QPU Sampler or look a the experiments with exhaustive search mostly in point_set_registration and rotation_estimation.
-The repository can be cloned with
git clone https://github.com/MSeelbach/QuAnt/
-We recommend the user to set up a conda environment with
conda create -n QuAnt-env python=3.8
conda activate QuAnt-env
-The D-Wave ocean sdk can be installed with
python -m pip install dwave-ocean-sdk
and following the steps from https://docs.ocean.dwavesys.com/en/stable/overview/install.html. In particular to
get access to the solvers from D-Wave one has to create an account for D-Wave Leap (https://cloud.dwavesys.com/leap/login/?next=/leap/) and
can then use the API Token (https://docs.ocean.dwavesys.com/en/stable/overview/sapi.html). We tested the code for dwave-ocean-sdk versions 4.2 and 6.3.
-Installing PyTorch is another prerequisite. We tested the code with versions 2.0.0 and 1.10.0.
-After this execute
conda install pandas, matplotlib
Execute the PermutationLearningPegasus.py
file to start the training. This can be done in the console without futher arguments as
python PermutationLearningPegasus.py
You can train the smaller network
by setting UseDeeperNetwork to false at line 41 of the PermutationLearningPegasus.py
file. To train on Willow set TrainOnWillow to true.
In the same way you have to set UseQuantumAnnealer to true to use quantum annealing instead of simulated annealing. In GraphMatching/data/WillowGraphmatching/DataPreperation
you can have a closer look at the data preparation. For this pygmtools has to be installed with
pip install pygmtools
.
In both setups it is necessary to download the datasets seperatly. The point set registration dataset can be found here and the ModelNet10 dataset here. In both setups it is necessary to adapt the file paths to the local versions of the datasets and also work-directories.
Install numpy, glob, scipy, icp, the D-Wave ocean sdk and PyTorch.
Then in the first step the data gets generated. This is done by executing the point_set_reg_data_gen.py
file. This file needs to run 16 times as follows:
$python point_set_reg_data_gen.py 1
$python point_set_reg_data_gen.py 2
...
$python point_set_reg_data_gen.py 16
This allows the code to generate 16 different dataframes for training as well as one test dataframe.
Afterwards it is possible to execute the training files without any further inputs. They can be found in the folders diag_baseline
, pure_baseline
and in QuAnt_baseline
. All folders contain 4 files for the 4 network sizes demonstrated in the paper. the file file with the ending _3.py
contains the model setup with 3 layers and the width of 32, the files with the ending of _3_2.py
have the model setup of 3 layers and a width of 78. The 5 files containing the 5 layered models are named analogously with _5.py
and _5_2.py
respectively.
All files will save an histogram about the error rate of the evaluation dataset. In the paper we reported the mean and std over multiple runs of this histogram.
For the rotation estimation experiments there is no data preprocessing in a seperated step needed, as all is included in the main experimental files.
Here we have the three folders, diag_baseline
, pure_baseline
and QuAnt_baseline
, which contain the corresponding setups. Each folder contains 4 folders named 3_1
(setup with 3 layers and width of 32), 3_2
(setup with 3 layers and width of 78), 5_1
(setup with 5 layers and width of 32), 5_2
(setup with 5 layers and width of 78).
As we explained in the paper for the rotation estimation case 3 networks are needed to fully regress the 3D rotation.
Those three can be found in each folder. In order to train the three models all three files (3d_*
) need to be executed. Once the models are trained and the weights are saved the file quantumml3d_mixed_eval.py
will test the model and print the mean error of it.
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.