Skip to content

Commit

Permalink
remove utils function for getting qubit order
Browse files Browse the repository at this point in the history
  • Loading branch information
ewinston committed Oct 4, 2022
1 parent 56029b1 commit d74b6ee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
10 changes: 5 additions & 5 deletions qiskit/transpiler/passes/routing/stochastic_swap.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from qiskit.transpiler.passes.routing.utils import (
route_cf_multiblock,
route_cf_looping,
get_ordered_virtual_qubits,
combine_permutations,
)
from qiskit.circuit import IfElseOp, WhileLoopOp, ForLoopOp, ControlFlowOp
Expand Down Expand Up @@ -254,10 +253,11 @@ def _layer_update(self, dag, layer, best_layout, best_depth, best_circuit):
logger.debug("layer_update: there are no swaps in this layer")
# Output this layer
layer_circuit = layer["graph"]
order = combine_permutations(
get_ordered_virtual_qubits(self.initial_layout, dag.qregs),
get_ordered_virtual_qubits(layout, dag.qregs),
)
initial_v2p = self.initial_layout.get_virtual_bits()
new_v2p = layout.get_virtual_bits()
initial_order = [initial_v2p[qubit] for qubit in dag.qubits]
new_order = [new_v2p[qubit] for qubit in dag.qubits]
order = combine_permutations(initial_order, new_order)
dag.compose(layer_circuit, qubits=order)

def _mapper(self, circuit_graph, coupling_graph, trials=20):
Expand Down
15 changes: 0 additions & 15 deletions qiskit/transpiler/passes/routing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,21 +165,6 @@ def route_cf_looping(tpass, cf_opnode, current_layout, root_dag, seed=None):
return cf_op.replace_blocks([updated_circ_block]), current_layout, idle_qubits


def get_ordered_virtual_qubits(layout, qregs):
"""Get list of virtual qubits associated with ordered list
of physical qubits.
Args:
layout (Layout): circuit layout
qregs (list(QuantumRegister)): list of registers for circuit
Returns:
list(int): list of virtual qubit indices
"""
p2v = layout.get_virtual_bits()
return [p2v[qubit] for qreg in qregs.values() for qubit in qreg]


def combine_permutations(*permutations):
"""
Chain a series of permutations.
Expand Down

0 comments on commit d74b6ee

Please sign in to comment.