1
$\begingroup$

Google's quantum computer is not yet available for the public. Is it possible to run Cirq on IBM's quantum computers, instead of Qiskit? And if so, how can I do it?

Thank you!

$\endgroup$
2
$\begingroup$

This task can be accomplished via cirq.QasmOutput. I've attached an example of how to use the aforementioned functionality to run Cirq circuits on Qiskit's backends.

import cirq 
from typing import Tuple
from qiskit import QuantumCircuit, execute, Aer

def main():
    q0 = cirq.LineQubit(1)  
    cirq_circuit = cirq.Circuit(
        cirq.H(q0),  
        cirq.measure(q0)
    )
    results, qasm_circuit = run_cirq_circuit_on_qiskit(cirq_circuit, (q0,), 'qasm_simulator')
    
    # Returns counts
    counts = results.get_counts(qasm_circuit)
    print("Total count for 00 and 11 are:", counts)
    
def run_cirq_circuit_on_qiskit(circuit: 'cirq.Circuit', qubits: Tuple['cirq.Qid', ...], backend: str):
    qasm_file_path = "/tmp/test.qasm"   
    output = cirq.QasmOutput((circuit.all_operations()), qubits)
    output.save(qasm_file_path)    
    qasm_circuit = QuantumCircuit().from_qasm_file(qasm_file_path)
    # Execute the circuit qiskit backend
    job = execute(qasm_circuit, Aer.get_backend(backend), shots=1000)
    # Grab results from the job
    return job.result(), qasm_circuit

if __name__ == '__main__':
    main()

$\endgroup$
3
$\begingroup$

Good question. I tried to figure this out as well since I saw your question without much success.

However, I just wanted to point out that you can use Pennylane since it offers many external plugins so it allows you to run on many external hardware. See here: https://pennylane.ai/plugins.html

You can use Qiskit and aim at multiple external devices outside of IBM's QC. For instance, you can use Qiskit and run your code on Honeywell Trapped-ion backend given that you have an API token. See here: https://github.com/qiskit-community/qiskit-honeywell-provider
There are a few other external backends that you can use through Qiskit.

So even though I wasn't able to find the solution to your question, I hope this helps.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.