def test_heavy_hex_factory(self): coupling = CouplingMap.from_heavy_hex(3, bidirectional=False) edges = coupling.get_edges() expected = [ (0, 9), (0, 13), (1, 13), (1, 14), (2, 14), (3, 9), (3, 15), (4, 15), (4, 16), (5, 12), (5, 16), (6, 17), (7, 17), (7, 18), (8, 12), (8, 18), (10, 14), (10, 16), (11, 15), (11, 17), ] self.assertEqual(set(edges), set(expected))
def setUp(self): super().setUp() self.cmap20 = FakeTokyo().configuration().coupling_map self.target_19 = Target() rng = np.random.default_rng(12345) instruction_props = { edge: InstructionProperties(duration=rng.uniform(1e-7, 1e-6), error=rng.uniform(1e-4, 1e-3)) for edge in CouplingMap.from_heavy_hex(3).get_edges() } self.target_19.add_instruction(CXGate(), instruction_props)
def test_heavy_hex_factory_bidirectional(self): coupling = CouplingMap.from_heavy_hex(3, bidirectional=True) edges = coupling.get_edges() expected = [ (0, 9), (0, 13), (1, 13), (1, 14), (2, 14), (3, 9), (3, 15), (4, 15), (4, 16), (5, 12), (5, 16), (6, 17), (7, 17), (7, 18), (8, 12), (8, 18), (9, 0), (9, 3), (10, 14), (10, 16), (11, 15), (11, 17), (12, 5), (12, 8), (13, 0), (13, 1), (14, 1), (14, 2), (14, 10), (15, 3), (15, 4), (15, 11), (16, 4), (16, 5), (16, 10), (17, 6), (17, 7), (17, 11), (18, 7), (18, 8), ] self.assertEqual(set(edges), set(expected))
def test_5q_circuit_19q_target_without_noise(self): """Test layout works finds a dense 5q subgraph in a 19q heavy hex target with no noise.""" qr = QuantumRegister(5, "q") circuit = QuantumCircuit(qr) circuit.cx(qr[0], qr[3]) circuit.cx(qr[3], qr[4]) circuit.cx(qr[3], qr[1]) circuit.cx(qr[0], qr[2]) dag = circuit_to_dag(circuit) instruction_props = { edge: None for edge in CouplingMap.from_heavy_hex(3).get_edges() } noiseless_target = Target() noiseless_target.add_instruction(CXGate, instruction_props) pass_ = DenseLayout(target=noiseless_target) pass_.run(dag) layout = pass_.property_set["layout"] self.assertEqual(layout[qr[0]], 1) self.assertEqual(layout[qr[1]], 13) self.assertEqual(layout[qr[2]], 0) self.assertEqual(layout[qr[3]], 9) self.assertEqual(layout[qr[4]], 3)