qiboteam / qibojit-benchmarks

Benchmark code for qibojit performance accessment
Apache License 2.0
2 stars 3 forks source link

Fix qiskit-gpu when precision is set #36

Closed stavros11 closed 2 years ago

stavros11 commented 2 years ago

Fixes the issue we have with qiskit-gpu for which performance appears similar to qiskit-cpu in the library comparison bar plots. Apparently our qiskit-gpu falls back to cpu when the precision option is used in the compare.py script, due to a typo in the simulator option definition.

scarrazza commented 2 years ago

Thanks, but here you have simply renamed self.options with self.sim_options, no?

stavros11 commented 2 years ago

Thanks, but here you have simply renamed self.options with self.sim_options, no?

Yes, because self.sim_options is used in the Qiskit class, which is inherited by QiskitGpu. It's important to use the same name for this attribute in both classes because otherwise some methods, such as set_precision, do not work as intended. I tested this and it works, but I am re-running the qiskit part of the library plots to be sure.

A quick test is the following:

python compare.py --nqubits 27 --library qiskit-gpu --precision double

will run on CPU if using the libraries branch, but on GPU using this branch. If you drop the --precision setting it will run on GPU with both branches.

scarrazza commented 2 years ago

I see, thanks for spotting this issue, I am curious to see its performance.

stavros11 commented 2 years ago

Here are the fixed plots, with the numbers for other libraries kept the same:

Single precision ![image](https://user-images.githubusercontent.com/35475381/155495613-25399b17-0593-46cb-ab78-6f28c042f6ea.png) ![image](https://user-images.githubusercontent.com/35475381/155495630-0320f92b-3725-46cf-a295-b50bfcbdc23a.png)
Double precision ![image](https://user-images.githubusercontent.com/35475381/155495728-e9644f2b-35b6-4532-ac62-d7e44804ee57.png) ![image](https://user-images.githubusercontent.com/35475381/155495735-2a69cd58-61f7-4bd1-b586-a002822c028d.png)

Single precision is not very impressive but I remember we also observed this in qiboteam/qibojit#53 for the multi-qubit operator. Double precision looks as expected, so I guess from our side the scripts are correct and properly running on GPU now.

It's nice to see that the CPU/GPU ratios are consistent for all libraries both on 20 qubits (CPU faster) and 30 qubits (GPU faster), especially in double precision. Qibojit GPU is surprisingly fast which I hope is true and not due to a bug or something!

scarrazza commented 2 years ago

Thanks!

I hope is true and not due to a bug or something!

Well, you know, this is very unlikely. If the simulation numbers are ok, then we are fine, given that we can reproduce this setup on multiple devices.