Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Fix staggered dynamical decoupling for disjoint coupling maps #701

Merged
merged 4 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
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 @@ -251,10 +251,8 @@ def _pre_runhook(self, dag: DAGCircuit) -> None:

if self._coupling_map:
physical_qubits = [dag.qubits.index(q) for q in dag.qubits]
sub_coupling_map = self._coupling_map.reduce(physical_qubits)
self._coupling_coloring = rx.graph_greedy_color(
sub_coupling_map.graph.to_undirected()
)
subgraph = self._coupling_map.graph.subgraph(physical_qubits)
self._coupling_coloring = rx.graph_greedy_color(subgraph.to_undirected())
if any(c > 1 for c in self._coupling_coloring.values()):
raise TranspilerError(
"This circuit topology is not supported for staggered dynamical decoupling."
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
fixes:
- |
Replace coupling_map.reduce(nodes) with coupling_map.graph.subgraph(nodes
to apply DD on a disjoint coupling map. See discussion in
https://github.com/Qiskit/qiskit-terra/pull/9710
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from qiskit.transpiler.passmanager import PassManager
from qiskit.transpiler.exceptions import TranspilerError
from qiskit.transpiler.coupling import CouplingMap
from qiskit.converters import circuit_to_dag

from qiskit_ibm_provider.transpiler.passes.scheduling.dynamical_decoupling import (
PadDynamicalDecoupling,
Expand Down Expand Up @@ -969,3 +970,36 @@ def test_unsupported_coupling_map(self):

with self.assertRaises(TranspilerError):
pm.run(self.ghz4)

def test_disjoint_coupling_map(self):
"""Test staggered DD with disjoint coupling map."""
qc = QuantumCircuit(5)
for q in range(5):
qc.x(q)
qc.barrier()
for q in range(5):
qc.delay(1600, q)
qc.barrier()
dd_sequence = [XGate(), XGate()]
pm = PassManager(
[
ASAPScheduleAnalysis(self.durations),
PadDynamicalDecoupling(
self.durations,
dd_sequence,
coupling_map=CouplingMap([[0, 1], [1, 2], [3, 4]]),
),
]
)
dd_qc = pm.run(qc)

# ensure that delays for nearest neighbors are staggered
dag = circuit_to_dag(dd_qc)
delays = dag.op_nodes(Delay)
delay_dict = {q_ind: [] for q_ind in range(5)}
for delay in delays:
delay_dict[dag.find_bit(delay.qargs[0]).index] += [delay.op.duration]
self.assertNotEqual(delay_dict[0], delay_dict[1])
self.assertNotEqual(delay_dict[1], delay_dict[2])
self.assertNotEqual(delay_dict[3], delay_dict[4])
self.assertEqual(delay_dict[0], delay_dict[2])
Loading