qilimanjaro-tech / qililab

Qililab is a generic and scalable quantum control library used for fast characterization and calibration of quantum chips. Qililab also offers the ability to execute high-level quantum algorithms with your quantum hardware.
Apache License 2.0
30 stars 2 forks source link

Make execute accept Qiskit, cirq, QASM and more #689

Open GuillermoAbadLopez opened 7 months ago

GuillermoAbadLopez commented 7 months ago

This PR, mainly makes these changes:

We can run a Rabi with a Qiskit circuit:

Screenshot 2024-02-15 at 18 47 36 Screenshot 2024-02-15 at 19 39 26

We can run a Rabi with a direct QASM str representation of the circuit:

Screenshot 2024-02-15 at 19 41 33 Screenshot 2024-02-15 at 19 42 32
codecov[bot] commented 7 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 96.17%. Comparing base (0e46e55) to head (aa17d3d).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #689 +/- ## ======================================= Coverage 96.16% 96.17% ======================================= Files 273 273 Lines 9058 9080 +22 ======================================= + Hits 8711 8733 +22 Misses 347 347 ``` | [Flag](https://app.codecov.io/gh/qilimanjaro-tech/qililab/pull/689/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qilimanjaro-tech) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/qilimanjaro-tech/qililab/pull/689/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qilimanjaro-tech) | `96.17% <100.00%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qilimanjaro-tech#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

GuillermoAbadLopez commented 7 months ago

The only problem it has, is that Barriers in QASM are not recognized by Qibo, when doing .from_qasm(), so if your Qiskit circuit for example has a barrier, it was giving an error...

So I implemented a change for deleting barriers from the QASM's strings, but I dunno if that might cause problems physically of asynchronous stuff...

Screenshot 2024-02-15 at 19 21 42 Screenshot 2024-02-16 at 16 23 11
GuillermoAbadLopez commented 7 months ago

Another thing, is that if you do a measure_all(), the results shape change in inconsistent ways... But the execution works correctly (if you remove the barriers, since it contains barriers)

The user later, would just need to find how to work out with these results with weird shape.

GuillermoAbadLopez commented 7 months ago

Finally we should just decide, if we want to:

GuillermoAbadLopez commented 5 months ago

I tried q2 again, after some time (days), here are the results:

QILILAB (normal, with buffer wait):

circuit = Circuit(qubit + 1)
circuit.add(ql.Drag(qubit, theta=np.pi, phase=0))
circuit.add(ql.Wait(qubit, M_BUFFER_TIME))
circuit.add(gates.M(qubit))
Screenshot 2024-03-20 at 14 32 57

QILILAB (no buffer wait):

circuit = Circuit(qubit + 1)
circuit.add(ql.Drag(qubit, theta=np.pi, phase=0))
# circuit.add(ql.Wait(qubit, M_BUFFER_TIME))
circuit.add(gates.M(qubit))
Screenshot 2024-03-20 at 14 53 05

QASM (no buffer wait):

circuit = 'OPENQASM 2.0;\ninclude "qelib`.inc";\nqreg qtest[5];\ncreg ctest[1];\nrx(pi) qtest[2];\nbarrier
qtest[0],qtest[1],qtest[2],qtest[3],qtest[4];\nmeasure qtest[2] -> ctest[0];\n'
Screenshot 2024-03-20 at 14 32 28

QIBO (no buffer wait)

circuit = Circuit(qubit + 1)
circuit.add(gates.RX(qubit, theta=np.pi))
circuit.add(gates.M(qubit))
Screenshot 2024-03-20 at 14 35 32

QIBO (with qililab buffer wait):

circuit = Circuit(qubit + 1)
circuit.add(gates.RX(qubit, theta=np.pi))
circuit.add(ql.Wait(qubit, M_BUFFER_TIME))
circuit.add(gates.M(qubit))
Screenshot 2024-03-20 at 14 33 35

QISKIT (no buffer wait):

q_register = QuantumRegister(5, "qtest")
c_register = ClassicalRegister(1, "ctest")
circuit = QuantumCircuit(q_register, c_register)

circuit.rx(theta=np.pi, qubit=qubit)
circuit.measure(qubit, c_register)
Screenshot 2024-03-20 at 14 33 59
GuillermoAbadLopez commented 5 months ago

I'll try the same now with q1, which has a higher frequency:

QILILAB (normal, with buffer wait):

circuit = Circuit(qubit + 1)
circuit.add(ql.Drag(qubit, theta=np.pi, phase=0))
circuit.add(ql.Wait(qubit, M_BUFFER_TIME))
circuit.add(gates.M(qubit))
Screenshot 2024-03-20 at 15 04 39

QILILAB (no buffer wait):

circuit = Circuit(qubit + 1)
circuit.add(ql.Drag(qubit, theta=np.pi, phase=0))
# circuit.add(ql.Wait(qubit, M_BUFFER_TIME))
circuit.add(gates.M(qubit))
Screenshot 2024-03-20 at 15 04 29

QASM (no buffer wait):

circuit = 'OPENQASM 2.0;\ninclude "qelib`.inc";\nqreg qtest[5];\ncreg ctest[1];\nrx(pi) qtest[2];\nbarrier
qtest[0],qtest[1],qtest[2],qtest[3],qtest[4];\nmeasure qtest[2] -> ctest[0];\n'`
Screenshot 2024-03-20 at 14 58 22

QIBO (no buffer wait)

circuit = Circuit(qubit + 1)
circuit.add(gates.RX(qubit, theta=np.pi))
circuit.add(gates.M(qubit))
Screenshot 2024-03-20 at 14 55 06

QIBO (with qililab buffer wait):

circuit = Circuit(qubit + 1)
circuit.add(gates.RX(qubit, theta=np.pi))
circuit.add(ql.Wait(qubit, M_BUFFER_TIME))
circuit.add(gates.M(qubit))
Screenshot 2024-03-20 at 14 56 36

QISKIT (no buffer wait):

q_register = QuantumRegister(5, "qtest")
c_register = ClassicalRegister(1, "ctest")
circuit = QuantumCircuit(q_register, c_register)

circuit.rx(theta=np.pi, qubit=qubit)
circuit.measure(qubit, c_register)
Screenshot 2024-03-20 at 14 55 56