quri_parts.circuit.topology package#
- class SquareLattice(xsize, ysize, qubit_to_coord=None)#
Bases:
object
Represents qubits connected in a rectangular lattice with no missing pieces, and searches for the shortest path between any two qubits.
- Parameters:
xsize (int) – Size of lattice in x direction.
ysize (int) – Size of lattice in y direction.
coord_to_qubit – Mapping from coordinates to qubit indices. If omitted, it is automatically assigned from the origin with x changing first.
qubit_to_coord (Optional[QubitToCoordMap]) –
- get_qubit(coord)#
Returns qubit index corresponding to the given coordinate.
- Parameters:
coord (circuit.topology.square_lattice.Coordinate) –
- Return type:
int
- get_coord(qubit)#
Returns coordinate corresponding to the given qubit index.
- Parameters:
qubit (int) –
- Return type:
circuit.topology.square_lattice.Coordinate
- is_adjacent(qubit_a, qubit_b)#
Check if the given qubits are directory connected to each other on the lattice.
- Parameters:
qubit_a (int) –
qubit_b (int) –
- Return type:
bool
- qubit_path(qubit_a, qubit_b)#
Returns sequence of qubits on the shortest path between the coordinates of two qubits.
- Parameters:
qubit_a (int) – Qubit index at the starting point.
qubit_b (int) – Qubit index at the end point.
- Return type:
Sequence[int]
- class SquareLatticeSWAPInsertionTranspiler(square_lattice)#
Bases:
GateDecomposer
When the connection of qubits is expressed in
SquareLattice
, insert SWAPs as appropriate before and after for gates applied between two qubits that are not connected to each other.- Parameters:
square_lattice (SquareLattice) –
- is_target_gate(gate)#
Determine if a given gate is subject to decomposition.
- Parameters:
gate (QuantumGate) – Gates in the circuit that are scanned from the front.
- Return type:
bool
- decompose(gate)#
Describe the specific decomposition process. Only the target gates satisfying is_target_gate() method are passed.
- Parameters:
gate (QuantumGate) – The gates to be decomposed.
- Return type:
Sequence[QuantumGate]