You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Transpilation is a crucial step to map (and potentially optimise) the user's quantum circuit to the qubit topology on the chip. While I was trying to run Qibo circuits on AWS backend devices, each with different native gates (IonQ's, Oxford Quantum Circuits, Rigetti), I found that there might be gates that are disallowed to be native gates in the transpiler.
Qubit topology -- I created a new function called custom_connectivity(coupling_map) that takes in a custom coupling_map. This implementation is successful.
Native gates -- Customise a set of native gates. Let's follow the native gate set of Oxford Quantum Circuits, which are custom_native_gates = [gates.I, gates.RZ, gates.SX, gates.X, gates.ECR]. ('v' is also known as the sqrt-x gate). This implementation is not successful.
I encounter problems with Step 2 when trying to define gates.SX as gates that cannot be used as native. There are other gates such as gates.H, gates.X, gates.Y, gates.T, gates.CNOT, gates.ECR that cannot be used as native also.
Code to reproduce the error
# Qibo transpilerimportnetworkxasnxfromqiboimportgatesfromqibo.modelsimportCircuitfromqibo.transpiler.pipelineimportPasses, assert_transpilingfromqibo.transpiler.optimizerimportPreprocessingfromqibo.transpiler.routerimportShortestPathsfromqibo.transpiler.unrollerimportUnroller, NativeGatesfromqibo.transpiler.placerimportRandom# Define custom connectivity defcustom_connectivity(coupling_map):
graph=nx.Graph()
forconnectionincoupling_map:
q1, q2=connectiongraph.add_edge(q1, q2)
returngraph# Define the circuitcircuit=Circuit(2)
circuit.add(gates.H(0))
circuit.add(gates.CZ(0, 1))
# Define qubit topology and native gatescustom_coupling_map= [[0, 1], [0, 7], [1, 2], [2, 3], [4, 3], [4, 5], [6, 5], [7, 6]]
custom_native_gates= [gates.I, gates.RZ, gates.SX, gates.X, gates.ECR]
# Define custom passes as a listcustom_passes= []
# Preprocessing adds qubits in the original circuit to match the number of qubits in the chipcustom_passes.append(Preprocessing(connectivity=custom_connectivity(custom_coupling_map)))
# Placement stepcustom_passes.append(Random(connectivity=custom_connectivity(custom_coupling_map)))
# Routing stepcustom_passes.append(ShortestPaths(connectivity=custom_connectivity(custom_coupling_map)))
# Gate decomposition stepcustom_passes.append(Unroller(native_gates=NativeGates.from_gatelist(custom_native_gates)))
# Define the general pipelinecustom_pipeline=Passes(custom_passes,
connectivity=custom_connectivity(custom_coupling_map),
native_gates=NativeGates.from_gatelist(custom_native_gates))
# Call the transpiler pipeline on the circuittranspiled_circ, final_layout=custom_pipeline(circuit)
The error message received from running the above code is: ValueError: Gate <class 'qibo.gates.gates.SX'> cannot be used as native.
The text was updated successfully, but these errors were encountered:
For now the transpiler (unroller step) allows to define only GPI2 or U3 as single qubit native gates (plus RZ, Z and I). We are currently thinking of a more general unrolling procedure that would allow to define different sets of single qubit gates. However, the realization of a general unroller is non trivial, we will try to find a good solution in the next months.
Describe the bug
Transpilation is a crucial step to map (and potentially optimise) the user's quantum circuit to the qubit topology on the chip. While I was trying to run Qibo circuits on AWS backend devices, each with different native gates (IonQ's, Oxford Quantum Circuits, Rigetti), I found that there might be gates that are disallowed to be native gates in the transpiler.
To Reproduce
Following the example given here: https://qibo.science/qibo/stable/code-examples/advancedexamples.html#how-to-modify-the-transpiler, there are two important areas of transpilation to fulfil:
custom_connectivity(coupling_map)
that takes in a customcoupling_map
. This implementation is successful.custom_native_gates = [gates.I, gates.RZ, gates.SX, gates.X, gates.ECR]
. ('v' is also known as the sqrt-x gate). This implementation is not successful.I encounter problems with Step 2 when trying to define
gates.SX
as gates that cannot be used as native. There are other gates such asgates.H
,gates.X
,gates.Y
,gates.T
,gates.CNOT
,gates.ECR
that cannot be used as native also.Code to reproduce the error
The error message received from running the above code is:
ValueError: Gate <class 'qibo.gates.gates.SX'> cannot be used as native.
The text was updated successfully, but these errors were encountered: