NVIDIA / cuda-quantum

C++ and Python support for the CUDA Quantum programming model for heterogeneous quantum-classical workflows
https://nvidia.github.io/cuda-quantum/
Other
473 stars 172 forks source link

GPU version is slower than CPU version for hybrid_qnns.ipynb #2169

Open qinhui99 opened 2 weeks ago

qinhui99 commented 2 weeks ago

Required prerequisites

Describe the bug

We did the performance test for hybrid_qnns.ipynb between GPU version and CPU version. Then we found GPU version is very slow and slower than CPU version. Why?

We tested both 4090 GPU and T4 GPU, got the same result.

Steps to reproduce the bug

just run the hybrid_qnns.ipynb.

Expected behavior

GPU version is faster than CPU version.

Is this a regression? If it is, put the last known working version (or commit) here.

Not a regression

Environment

Suggestions

No response

zohimchandani commented 2 weeks ago

Since this is a single qubit example, it is expected that the CPU version will be faster.

GPU executing time will be much faster if you run larger circuits with more qubit counts.

qinhui99 commented 2 weeks ago

Since this is a single qubit example, it is expected that the CPU version will be faster.

GPU executing time will be much faster if you run larger circuits with more qubit counts.

No. I tested 4 qubits, the winner still was the CPU version. CPU version: 4.76 iter/s GPU version: 2.95 iter/s

I used other quantum platform such as torch-quantum, deepquantum. There are GPU version faster than CPU version.

zohimchandani commented 1 week ago

Can you please share a minimal working example of the code you are running to benchmark with the section you are timing highlighted.

Thanks.

qinhui99 commented 1 week ago

mnist_torchquantum.zip

Yeah, pls check the mnist_torchquantum.zip.