Exemplo n.º 1
0
    def test_all_to_all_topology(self) -> None:
        """
        Checks that Sabre doesn't modify the circuit if the topology is of type ALL_TO_ALL.
        """

        for nbqbit in range(min_nbqbit, max_nbqbit):
            circuit = generate_random_circuit(nbqbit)

            sabre = Sabre()
            batch = Batch(jobs=[circuit.to_job()])
            hardware_specs = HardwareSpecs()
            batch_result = sabre.compile(batch, hardware_specs)
            computed_circuit = batch_result.jobs[0].circuit

            check_circuits_equality(circuit, computed_circuit)
Exemplo n.º 2
0
    def test_already_executable_circuit(self) -> None:
        """
        Tests Sabre on a fully executable circuit which means all gates are applied on qubits which are connected on the
        hardware.
        """

        for nbqbit in range(min_nbqbit, max_nbqbit):
            prog = Program()
            qbits = prog.qalloc(nbqbit)

            for i in range(len(qbits) - 1):
                prog.apply(H, qbits[i])
                prog.apply(Z, qbits[i])
                prog.apply(X.ctrl(), qbits[i + 1], qbits[i])

            circuit = prog.to_circ(inline=True)

            sabre = Sabre()
            batch = Batch(jobs=[circuit.to_job()])
            hardware_specs = HardwareSpecs()
            batch_result = sabre.compile(batch, hardware_specs)
            computed_circuit = batch_result.jobs[0].circuit

            check_circuits_equality(circuit, computed_circuit)