示例#1
0
def decompose_arbitrary_into_syc_analytic(qubit_a: cirq.Qid, qubit_b: cirq.Qid,
                                          op: cirq.Operation) -> cirq.OP_TREE:
    """Synthesize an arbitrary 2 qubit operation to a sycamore operation using
    the given Tabulation.

     Args:
            qubit_a: first qubit of the operation
            qubit_b: second qubit of the operation
            op: operation to decompose
            tabulation: A tabulation for the Sycamore gate.
        Returns:
            New operations iterable object
    """
    new_ops = cirq.two_qubit_matrix_to_operations(qubit_a,
                                                  qubit_b,
                                                  op,
                                                  allow_partial_czs=True)
    for new_op in new_ops:
        num_qubits = len(new_op.qubits)
        if num_qubits == 1:
            (a, ) = new_op.qubits
            yield from _phased_x_z_ops(cirq.unitary(new_op), a)
        elif num_qubits == 2:
            a, b = op.qubits
            yield from cirq.flatten_to_ops(
                known_two_q_operations_to_sycamore_operations(a, b, new_op))
示例#2
0
def decompose_arbitrary_into_syc_analytic(qubit_a: cirq.Qid, qubit_b: cirq.Qid,
                                          op: cirq.Operation) -> cirq.OP_TREE:
    """Synthesize an arbitrary 2 qubit operation to a Sycamore operation using the given Tabulation.

    Args:
        qubit_a: First qubit of the operation.
        qubit_b: Second qubit of the operation.
        op: Operation to decompose.
        tabulation: A tabulation for the Sycamore gate.
    Yields:
        A `cirq.OP_TREE` which produces the given operation using Sycamores.
    """
    new_ops = cirq.two_qubit_matrix_to_operations(qubit_a,
                                                  qubit_b,
                                                  op,
                                                  allow_partial_czs=True)
    for new_op in new_ops:
        num_qubits = len(new_op.qubits)
        if num_qubits == 1:
            (a, ) = new_op.qubits
            yield from _phased_x_z_ops(cirq.unitary(new_op), a)
        elif num_qubits == 2:
            a, b = op.qubits
            yield from cirq.flatten_to_ops(
                known_two_q_operations_to_sycamore_operations(a, b, new_op))
示例#3
0
 def assert_validate_and_contains_consistent(gateset, op_tree, result):
     assert all(op in gateset for op in cirq.flatten_to_ops(op_tree)) is result
     for item in optree_and_circuit(op_tree):
         assert gateset.validate(item) is result
示例#4
0
 def is_supported(self, op_tree: cirq.OP_TREE) -> bool:
     """Whether the given object contains only supported operations."""
     return all(
         self.is_supported_operation(op)
         for op in cirq.flatten_to_ops(op_tree))