Beispiel #1
0
def get_supported_channels():
    """A helper to get the channels that are supported in TFQ.

    Returns a dictionary mapping from supported channel types
    to number of qubits.
    """
    # Add new channels here whenever additional support is needed.
    channel_mapping = dict()
    channel_mapping[cirq.DepolarizingChannel(0.01)] = 1
    channel_mapping[cirq.AsymmetricDepolarizingChannel(0.01, 0.02, 0.03)] = 1
    channel_mapping[cirq.GeneralizedAmplitudeDampingChannel(0.01, 0.02)] = 1
    channel_mapping[cirq.AmplitudeDampingChannel(0.01)] = 1
    channel_mapping[cirq.ResetChannel()] = 1
    channel_mapping[cirq.PhaseDampingChannel(0.01)] = 1
    channel_mapping[cirq.PhaseFlipChannel(0.01)] = 1
    channel_mapping[cirq.BitFlipChannel(0.01)] = 1

    return channel_mapping
Beispiel #2
0
def test_phase_flip_channel_repr():
    cirq.testing.assert_equivalent_repr(cirq.PhaseFlipChannel(0.3))
Beispiel #3
0
 'NO_NOISE':
 cirq.NO_NOISE,
 'NamedQubit':
 cirq.NamedQubit('hi mom'),
 'PauliString': [
     cirq.PauliString({
         Q0: cirq.X,
         Q1: cirq.Y,
         Q2: cirq.Z
     }),
     cirq.X(Q0) * cirq.Y(Q1) * 123
 ],
 'PhaseDampingChannel':
 cirq.PhaseDampingChannel(0.5),
 'PhaseFlipChannel':
 cirq.PhaseFlipChannel(0.5),
 'PhaseGradientGate':
 cirq.PhaseGradientGate(num_qubits=3, exponent=0.235),
 'PhasedISwapPowGate':
 cirq.PhasedISwapPowGate(phase_exponent=0.1, exponent=0.2),
 'PhasedXPowGate':
 cirq.PhasedXPowGate(phase_exponent=0.123,
                     exponent=0.456,
                     global_shift=0.789),
 'QuantumFourierTransformGate':
 cirq.QuantumFourierTransformGate(num_qubits=2, without_reverse=True),
 'ResetChannel':
 cirq.ResetChannel(),
 'X':
 cirq.X,
 'Y':
Beispiel #4
0
        cirq.Circuit(cirq.H(a), cirq.CNOT(a, b), cirq.measure(a, b),
                     cirq.reset(a)))
    assert (str(c).strip() == """
H 0
CX 0 1
M 0 1
R 0
    """.strip())


@pytest.mark.parametrize(
    "gate",
    [
        cirq.BitFlipChannel(0.1),
        cirq.BitFlipChannel(0.2),
        cirq.PhaseFlipChannel(0.1),
        cirq.PhaseFlipChannel(0.2),
        cirq.PhaseDampingChannel(0.1),
        cirq.PhaseDampingChannel(0.2),
        cirq.X.with_probability(0.1),
        cirq.X.with_probability(0.2),
        cirq.Y.with_probability(0.1),
        cirq.Y.with_probability(0.2),
        cirq.Z.with_probability(0.1),
        cirq.Z.with_probability(0.2),
        cirq.DepolarizingChannel(0.1),
        cirq.DepolarizingChannel(0.2),
        cirq.DepolarizingChannel(0.1, n_qubits=2),
        cirq.DepolarizingChannel(0.2, n_qubits=2),
    ],
)