How to use pennylane to measure the gate time on the real device?

Hello everyone.

I want to measure the gate time on the IONQ devices.
And the code is as follows,

import pennylane as qml
from pennylane_ionq import ops
import time

dev = qml.device("ionq.qpu", backend="harmony", wires=2)

@qml.qnode(dev)
def circuit():
    time_start=time.time()
    qml.CNOT(wires=[0, 1])
    time_end=time.time()
    print('time cost',time_end-time_start,'s')
    return qml.counts()

result = circuit()
print(result)

But I think in this way, I can only get the program excution time. Is there any method that I can get the cnot gate time on the IONQ devices? Any help will be appreciated.

Hi @cheng ,

Thank you for your question. Very good question indeed! I’m checking with the team and will get back to you soon.

Thanks for your question! You are correct in thinking that this isn’t capturing the information you are looking for.

Timing this section of the code will actually record how long it takes PennyLane to execute this particular line, which adds the CNOT to the program that will ultimately be sent to the device. It is completed before any request is sent to the hardware at all, and is unrelated to hardware execution time.

Unfortunately, there’s no way to isolate the execution of the CNOT gate in PennyLane. The python code defines the commands being sent to hardware, but those commands are translated to a format that the IonQ backend understands before being passed along, and the translation doesn’t include timing at specific parts of the circuit - only the gates and measurements to be applied.

On the main IonQ page for Harmony they cite this paper for benchmarking statistics for 2-qubit gates, which should include some level of detail about gate implementation: https://arxiv.org/pdf/2003.12430

Additionally, if you have an API key to access the hardware, you can access their most recent benchmarking data for a given device, including 2-qubit gate durations, on the IonQ website here.

I hope that helps!

2 Likes

Hi @Lillian_Frederiksen

Really thanks for your reply. It helps me a lot. :+1: