0
$\begingroup$

I have a question concerning the placement of quantum circuits on Google devices. Consider the following code:

import cirq
q           = [cirq.LineQubit(x) for x in range(5)]
circuit     = cirq.Circuit(cirq.CNOT.on(q[0],q[3]), cirq.CNOT.on(q[1],q[4]))
line        = cirq.google.line_on_device(cirq.google.Bristlecone, length=5)
circuit_opt = cirq.google.optimized_for_xmon(circuit=circuit, new_device=cirq.google.Bristlecone, qubit_map=lambda i: line[i.x])
simulator   = cirq.Simulator()
result = simulator.run(circuit, repetitions=1024)

This ad comparable codes yields the error

ValueError: Non-local interaction: cirq.CZ.on(cirq.GridQubit(0, 5), cirq.GridQubit(1, 7)).

Does Cirq provide a mechanism to automatically place (and route) a generic algorithm in the qubits 0..5 onto a concrete lattice structure?

Thanks in advance, Matthias

$\endgroup$
1
$\begingroup$

There is currently no code in cirq that attempts to rewrite connectivity-violating operations into a series of connectivity-satisfying operations. The reasoning for not including this functionality is basically that it is expected that any such rewriting step will produce a circuit that is longer than any realistic noise budget.

There are tools that work with cirq that do what you want, such as pytket.

| improve this answer | |
$\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.