Add expectation value plot to GH benchmarks pipeline #147
Labels
feature
New feature or request
infrastructure
Non-quantum things to improve the robustness of our package, e.g. CI/CD
Milestone
Problem:
In the Github Actions workflow ucc-benchmarks, currently we run the compile time and gate count benchmarks and then run a couple python scripts to generate benchmark plots:
ucc/.github/workflows/ucc-benchmarks.yml
Lines 23 to 33 in 7c0caf6
run_benchmarks.sh is a shell script which runs different combinations of benchmark circuits and compilers in parallel by passing the QASM file and compiler name as command line args to the python script benchmark_script.py.
We want to add to this set of commands a script that runs the expectation value benchmark for a range of different benchmark circuits. To add these benchmarks to the pipeline will likely require several issues.
Proposed solution:
Here are the steps as I see them:
0. Add a circuit_name column to exp_val_benchmark.py results data
Currently benchmarks/scripts/expval_benchmark.py does not store the circuit_name, since it was only being run on one QASM file. First of all, we'll need to save an additional column to the expectation value data, for circuit_name and possibly other quantities of interest. I would recommend taking a look at the way benchmark_script.py makes use of the save_results function for a guide here.
1. Generating the benchmark circuits to be run
For our gate count and compile time benchmarks, we run the following circuits located in ucc/benchmarks/qasm_circuits
where N is the number of qubits. Notably, we cannot typically simulate the execution of circuits with O(100) qubits, nor likely run them on current hardware without losing all performance to noise. So we need a way to convert these large circuits into smaller feasible instances, say ~N=10.
You may also note that some of these QASM files are in a benchpress/ directory and others in ucc/. The files in the UCC folder (Prepare & Select and QCNN) were generated by us in the course of developing UCC. These can be generated using the generate_qasm.py script by modifying the number of qubits:
ucc/benchmarks/scripts/generate_qasm.py
Lines 13 to 23 in e3c3be6
Most of the QASM circuits in our UCC benchmarks, however, were taken from the benchpress library of QASM files. They have generated a wide range of qubit counts for each of their benchmark circuits, so we may be able to copy the N10 (i.e. 10 qubits) version of the above benchpress QASM files in order to have ones that are simulable for our expectation value benchmark.
2. Modify the expval_benchmark script so you can run it in parallel using a shell script
Currently the expval_benchmark.py script has hard-coded values for the benchmark circuit file and and loops through each compiler in python.
To make best use of the parallelism available to us, we want to be able to pass these parameters as command line arguments, e.g.
ucc/benchmarks/scripts/benchmark_script.py
Lines 10 to 13 in 7c0caf6
3. Add the expval_benchmark.py script to the shell script.
If we want to stick with just a single run_benchmarks.sh script that gets executed by the runner, we can it here in the list of commands that will be executed in parallel:
ucc/benchmarks/scripts/run_benchmarks.sh
Lines 35 to 47 in 7c0caf6
where we would loops through benchmark commands like [gates_and_runtime, expval] which would run the corresponding python scripts (benchmarks/scripts/expval_benchmark.py, benchmarks/scripts/benchmark_script.py). But we would need to make sure the correct benchmark python script gets paired with the right QASM file (i.e. the N=10 qubit files get passed to the expval_benchmark.py script)
Or
Alternatively you could create your own shell script which works analogously to run_benchmarks.sh. This might be easier to keep apart.
3. Plot the expvalue performance.
This part is analogous to
ucc/.github/workflows/ucc-benchmarks.yml
Lines 31 to 32 in 7c0caf6
Just create plots that can show the average performance (something like relative errors compared to ideal) over all benchmarks as well as individual performance for each benchmark.
Hopefully that's everything. Happy hunting!
The text was updated successfully, but these errors were encountered: