Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

faster transpile (qubit lookup) in rb code #1022

Merged
merged 3 commits into from
Feb 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -387,13 +387,14 @@ def _transpiled_circuits(self) -> List[QuantumCircuit]:
# Compute average basis gate numbers per Clifford operation
# This is probably main source of performance regression.
# This should be integrated into transpile pass in future.
qubit_indices = {bit: index for index, bit in enumerate(transpiled[0].qubits)}
for circ in transpiled:
Comment on lines +390 to 391
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All transpiled circuits has qubits with unique name "q" so no problem in these lines, but a bit slower

for circ in transpiled:
    qubit_indices = {bit: index for index, bit in enumerate(circ.qubits)}

might be safer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but all RB circuits have the same qubits no? otherwise i think a test should have failed

count_ops_result = defaultdict(int)
# This is physical circuits, i.e. qargs is physical index
for inst, qargs, _ in circ.data:
if inst.name in ("measure", "reset", "delay", "barrier", "snapshot"):
continue
qinds = [circ.find_bit(q).index for q in qargs]
qinds = [qubit_indices[q] for q in qargs]
if not set(self.physical_qubits).issuperset(qinds):
continue
# Not aware of multi-qubit gate direction
Expand Down