예제 #1
0
def _decompose_swap_into_syc(a: cirq.Qid, b: cirq.Qid):
    """Decomposes `cirq.SWAP` into sycamore gates using precomputed coefficients.

    This should only be called when exponent of `cirq.SwapPowGate` is 1. Other cases are currently
    not supported.

    Args:
        a: First qubit to operate on.
        b: Second qubit to operate on.

    Yields:
        A `cirq.OP_TREE` implementing the `cirq.SWAP` gate using Sycamore gates.
    """
    yield cirq.PhasedXPowGate(phase_exponent=0.44650378384076217,
                              exponent=0.8817921214052824).on(a)
    yield cirq.PhasedXPowGate(phase_exponent=-0.7656774060816165,
                              exponent=0.6628666504604785).on(b)
    yield ops.SYC(a, b)
    yield cirq.PhasedXPowGate(phase_exponent=-0.6277589946716742,
                              exponent=0.5659160932099687).on(a)
    yield ops.SYC(a, b)
    yield cirq.PhasedXPowGate(phase_exponent=0.28890767199499257,
                              exponent=0.4340839067900317).on(b)
    yield cirq.PhasedXPowGate(phase_exponent=-0.22592784059288928).on(a)
    yield ops.SYC(a, b)
    yield cirq.PhasedXPowGate(phase_exponent=-0.4691261557936808,
                              exponent=0.7728525693920243).on(a)
    yield cirq.PhasedXPowGate(phase_exponent=-0.8150261316932077,
                              exponent=0.11820787859471782).on(b)
    yield (cirq.Z**-0.7384700844660306).on(b)
    yield (cirq.Z**-0.7034535141382525).on(a)
예제 #2
0
def _decompose_iswap_into_syc(a: cirq.Qid, b: cirq.Qid):
    """Decomposes `cirq.ISWAP` into sycamore gates using precomputed coefficients.

    This should only be called when exponent of `cirq.ISwapPowGate` is 1. Other cases are currently
    not supported.

    Args:
        a: First qubit to operate on.
        b: Second qubit to operate on.

    Yields:
        A `cirq.OP_TREE` implementing the `cirq.ISWAP` gate using Sycamore gates.
    """
    yield cirq.PhasedXPowGate(phase_exponent=-0.27250925776964596,
                              exponent=0.2893438375555899).on(a)
    yield ops.SYC(a, b)
    yield cirq.PhasedXPowGate(phase_exponent=0.8487591858680898,
                              exponent=0.9749387200813147).on(b),
    yield cirq.PhasedXPowGate(phase_exponent=-0.3582574564210601).on(a),
    yield ops.SYC(a, b)
    yield cirq.PhasedXPowGate(phase_exponent=0.9675022326694225,
                              exponent=0.6908986856555526).on(a),
    yield ops.SYC(a, b),
    yield cirq.PhasedXPowGate(phase_exponent=0.9161706861686068,
                              exponent=0.14818318325264102).on(b),
    yield cirq.PhasedXPowGate(phase_exponent=0.9408341606787907).on(a),
    yield (cirq.Z**-1.1551880579397293).on(b),
    yield (cirq.Z**0.31848343246696365).on(a),
예제 #3
0
def _decompose_cz_into_syc(a: cirq.Qid, b: cirq.Qid):
    """Decomposes `cirq.CZ` into sycamore gates using precomputed coefficients.

    This should only be called when exponent of `cirq.CZPowGate` is 1. Otherwise,
    `_decompose_cphase_into_syc` should be called.

    Args:
        a: First qubit to operate on.
        b: Second qubit to operate on.

    Yields:
        A `cirq.OP_TREE` implementing the `cirq.CZ` gate using Sycamore gates.
    """
    yield cirq.PhasedXPowGate(phase_exponent=0.5678998743900456,
                              exponent=0.5863459345743176).on(a)
    yield cirq.PhasedXPowGate(phase_exponent=0.3549946157441739).on(b)
    yield ops.SYC(a, b)
    yield cirq.PhasedXPowGate(phase_exponent=-0.5154334589432878,
                              exponent=0.5228733015013345).on(b)
    yield cirq.PhasedXPowGate(phase_exponent=0.06774925307475355).on(a)
    yield ops.SYC(a, b),
    yield cirq.PhasedXPowGate(phase_exponent=-0.5987667922766213,
                              exponent=0.4136540654256824).on(a),
    yield (cirq.Z**-0.9255092746611595).on(b),
    yield (cirq.Z**-1.333333333333333).on(a),
예제 #4
0
def _decompose_phased_iswap_into_syc_precomputed(theta: float, a: cirq.Qid,
                                                 b: cirq.Qid) -> cirq.OP_TREE:
    """Decomposes `cirq.PhasedISwapPowGate` into Sycamore gates using precomputed coefficients.

    This should only be called if the Gate has a phase_exponent of .25. If the gate has an
    exponent of 1, _decompose_phased_iswap_into_syc should be used instead. Converting PhasedISwap
    gates to Sycamore is not supported if neither of these constraints are satisfied.

    This synthesize a PhasedISwap in terms of four sycamore gates.  This compilation converts the
    gate into a circuit involving two CZ gates, which themselves are each represented as two
    Sycamore gates and single-qubit rotations

    Args:
        theta: Rotation parameter for the phased ISWAP.
        a: First qubit to operate on.
        b: Second qubit to operate on.

    Yields:
        A `cirq.OP_TREE` implementing the `cirq.PhasedISwapPowGate` gate using Sycamore gates.
    """

    yield cirq.PhasedXPowGate(phase_exponent=0.41175161497166024,
                              exponent=0.5653807577895922).on(a)
    yield cirq.PhasedXPowGate(phase_exponent=1.0, exponent=0.5).on(b),
    yield (cirq.Z**0.7099892314883478).on(b),
    yield (cirq.Z**0.6746023442550453).on(a),
    yield ops.SYC(a, b)
    yield cirq.PhasedXPowGate(phase_exponent=-0.5154334589432878,
                              exponent=0.5228733015013345).on(b)
    yield cirq.PhasedXPowGate(phase_exponent=0.06774925307475355).on(a)
    yield ops.SYC(a, b),
    yield cirq.PhasedXPowGate(phase_exponent=-0.5987667922766213,
                              exponent=0.4136540654256824).on(a)
    yield (cirq.Z**-0.9255092746611595).on(b)
    yield (cirq.Z**-1.333333333333333).on(a)
    yield cirq.rx(-theta).on(a)
    yield cirq.rx(-theta).on(b)

    yield cirq.PhasedXPowGate(phase_exponent=0.5678998743900456,
                              exponent=0.5863459345743176).on(a)
    yield cirq.PhasedXPowGate(phase_exponent=0.3549946157441739).on(b)
    yield ops.SYC(a, b)
    yield cirq.PhasedXPowGate(phase_exponent=-0.5154334589432878,
                              exponent=0.5228733015013345).on(b)
    yield cirq.PhasedXPowGate(phase_exponent=0.06774925307475355).on(a)
    yield ops.SYC(a, b)
    yield cirq.PhasedXPowGate(phase_exponent=-0.8151665352515929,
                              exponent=0.8906746535691492).on(a)
    yield cirq.PhasedXPowGate(phase_exponent=-0.07449072533884049,
                              exponent=0.5).on(b)
    yield (cirq.Z**-0.9255092746611595).on(b)
    yield (cirq.Z**-0.9777346353961884).on(a)
예제 #5
0
def _swap_rzz(theta: float, q0: cirq.Qid, q1: cirq.Qid) -> cirq.OP_TREE:
    """An implementation of SWAP * exp(-1j * theta * ZZ) using three sycamore gates.

    This builds off of the _rzz method.

    Args:
        theta: The rotation parameter of Rzz Ising coupling gate.
        q0: First qubit to operate on.
        q1: Second qubit to operate on.

    Yields:
        The `cirq.OP_TREE`` that implements ZZ followed by a swap.
    """

    # Set interaction part.
    angle_offset = np.pi / 24 - np.pi / 4
    circuit = cirq.Circuit(ops.SYC(q0, q1), _rzz(theta - angle_offset, q0, q1))

    # Get the intended circuit.
    intended_circuit = cirq.Circuit(
        cirq.SWAP(q0, q1),
        cirq.ZZPowGate(exponent=2 * theta / np.pi,
                       global_shift=-0.5).on(q0, q1))

    yield _create_corrected_circuit(cirq.unitary(intended_circuit), circuit,
                                    q0, q1)
예제 #6
0
def _rzz(theta: float, q0: cirq.Qid, q1: cirq.Qid) -> cirq.OP_TREE:
    """Implements the Rzz Ising coupling gate (i.e. exp(-1j * theta * zz)) using Sycamore gates.

    Args:
        theta: The rotation parameter of Rzz Ising coupling gate.
        q0: First qubit to operate on
        q1: Second qubit to operate on

    Yields:
        The `cirq.OP_TREE` that implements the Rzz Ising coupling gate using Sycamore gates.
    """
    phi = -np.pi / 24
    c_phi = np.cos(2 * phi)
    target_unitary = cirq.unitary(cirq.ZZPowGate(exponent=2 * theta / np.pi, global_shift=-0.5))
    c2 = abs(np.sin(theta) if abs(np.cos(theta)) > c_phi else np.cos(theta)) / c_phi

    # Prepare program that has same Schmidt coefficients as exp(-1j theta ZZ)
    program = cirq.Circuit(ops.SYC(q0, q1), cirq.rx(2 * np.arccos(c2)).on(q1), ops.SYC(q0, q1))

    yield _create_corrected_circuit(target_unitary, program, q0, q1)