eclipse-qrisp / Qrisp

Qrisp - a framework for high-level programming of Quantum computers
https://www.qrisp.eu/
Eclipse Public License 2.0
77 stars 20 forks source link

Quantum Computer Runtime Interface [Feature request/ Library Explanation] #49

Closed LeaBaumann closed 2 weeks ago

LeaBaumann commented 2 months ago

Hi, is there a possibility to get the runtime a quantumcircuit takes on a Quantum Computer? I’ve seen that there is this feature for QAOA, but not for general quantumcircuits. Is there a possibility to get the runtime or qiskit job ID without having to convert the circuit to qiskit and then run it with qiskit code? So far, I’ve used this code to run sth. on an IBM Quantum Computer:

    provider = IBMProvider(<API Token>)
    kolkata_qiskit = provider.get_backend(backend)
    kolkata_qrisp = VirtualQiskitBackend(kolkata_qiskit)
positr0nium commented 2 months ago

Hi, AFAIK the time that IBM gives you after executing a circuit on their backend doesn't really reflect the time the quantum circuit ran. Much rather it specifies the time that the program spent in some low level part of their software stack, which might include some pre/postprocessing steps. With Qrisp it's already possible to get a rough estimate on how long a given quantum circuit would run but for that you have to specify the gate speed. Once you have specified the gate speed it is even possible to optimize the runtime for that particular backend ;) An example on how this can be achieved can be found here: https://www.qrisp.eu/reference/Core/generated/qrisp.QuantumSession.compile.html#gate-speed-aware-comp Let me know if there are still open questions :)

LeaBaumann commented 2 months ago

Hi, thanks for the answer! For my application, it would actually be more useful to get the time with the pre/ postprocessing. Is there a way to get this time?

positr0nium commented 2 months ago

I doubt that this quantity would teach you anything about the quality of your algorithm since this will vary for different QC providers, cloud platforms, software stack version etc. Additionally it would also be unclear to me whether to include the queuing time, which is most likely orders of magnitude bigger than the processing time but is of course also part of the software stack. If you still want to estimate this time, I'd propose the following steps:

  1. Execute a couple of backend calls an measure the time you want to estimate.
  2. Examine the data to see if there is any correlation between the size of your circuit and the measured time
  3. If there is indeed a correlation it would most likely be a linear function t(d) = y + m*d where a) y is the offset produced by the pre/post b) d is the depth of the quantum circuit as estimated by Qrisp in my initial answer c) m is some scaling factor to be determined.
  4. Use some curve fitting tool (for instance np.polyfit) to determine m and d.
LeaBaumann commented 2 months ago

Ok, then the other method using depth is probably better after all.

Do you know if the execution time of a gate corresponds to the frequency of the qubits (resp. 1/qubit frequency)? I could find the qubit frequency for the respective backends, but no information about the execution time of the gates. And do all gates take the same amount of time?