Пример #1
0
    def test_pass_manager_none(self):
        """Test passing the default (None) pass manager to the transpiler.

        It should perform the default qiskit flow:
        unroll, swap_mapper, cx_direction, cx_cancellation, optimize_1q_gates
        and should be equivalent to using tools.compile
        """
        qr = QuantumRegister(2, 'qr')
        circuit = QuantumCircuit(qr)
        circuit.h(qr[0])
        circuit.h(qr[0])
        circuit.cx(qr[0], qr[1])
        circuit.cx(qr[0], qr[1])
        circuit.cx(qr[0], qr[1])
        circuit.cx(qr[0], qr[1])

        coupling_map = [[1, 0]]
        basis_gates = ['u1', 'u2', 'u3', 'cx', 'id']

        backend = BasicAer.get_backend('qasm_simulator')
        circuit2 = transpile(circuit, backend, coupling_map=coupling_map, basis_gates=basis_gates,
                             pass_manager=None)

        qobj = compile(circuit, backend=backend, coupling_map=coupling_map, basis_gates=basis_gates)
        run_config = RunConfig(shots=1024, max_credits=10)
        qobj2 = circuits_to_qobj(circuit2, qobj_id=qobj.qobj_id, run_config=run_config)
        self.assertEqual(qobj, qobj2)
Пример #2
0
    def test_pass_manager_none(self):
        """Test passing the default (None) pass manager to the transpiler.

        It should perform the default qiskit flow:
        unroll, swap_mapper, direction_mapper, cx cancellation, optimize_1q_gates
        and should be equivalent to using tools.compile
        """
        qr = QuantumRegister(2, 'qr')
        circuit = QuantumCircuit(qr)
        circuit.h(qr[0])
        circuit.h(qr[0])
        circuit.cx(qr[0], qr[1])
        circuit.cx(qr[0], qr[1])
        circuit.cx(qr[0], qr[1])
        circuit.cx(qr[0], qr[1])

        coupling_map = [[1, 0]]
        basis_gates = 'u1,u2,u3,cx,id'

        backend = Aer.get_backend('qasm_simulator_py')
        circuit2 = transpile(circuit,
                             backend,
                             coupling_map=coupling_map,
                             basis_gates=basis_gates,
                             pass_manager=None)

        qobj = compile(circuit,
                       backend=backend,
                       coupling_map=coupling_map,
                       basis_gates=basis_gates)

        qobj2 = circuits_to_qobj(circuit2,
                                 backend.name(),
                                 basis_gates=basis_gates,
                                 coupling_map=coupling_map,
                                 qobj_id=qobj.qobj_id)

        self.assertEqual(qobj, qobj2)