Example #1
0
def test_multiqubit_decay_bellstate():
    program = Program(RY(np.pi / 3, 0), CNOT(0, 1))

    # commence manually dotting the above program
    initial_density = np.zeros((4, 4), dtype=complex)
    initial_density[0, 0] = 1.0

    gate_time_1q = 50e-9
    T1 = 30e-6
    T2 = 15e-6
    p1 = 1 - np.exp(-gate_time_1q / T1)
    p2 = 1 - np.exp(-gate_time_1q / T2)

    # RY
    gate_1 = np.kron(np.eye(2), qmats.RY(np.pi / 3))
    state = gate_1.dot(initial_density).dot(np.conj(gate_1).T)

    for ii in range(2):
        new_density = np.zeros_like(state)
        for kop in qmats.relaxation_operators(p1):
            operator = lifted_gate_matrix(matrix=kop,
                                          qubit_inds=[ii],
                                          n_qubits=2)
            new_density += operator.dot(state).dot(np.conj(operator).T)
        state = new_density

    for ii in range(2):
        new_density = np.zeros_like(state)
        for kop in qmats.dephasing_operators(p2):
            operator = lifted_gate_matrix(matrix=kop,
                                          qubit_inds=[ii],
                                          n_qubits=2)
            new_density += operator.dot(state).dot(np.conj(operator).T)
        state = new_density

    # CNOT
    # TODO: different 1q, 2q noise probabilities
    cnot_01 = np.kron(qmats.I, qmats.P0) + np.kron(qmats.X, qmats.P1)
    state = cnot_01.dot(state).dot(cnot_01.T)
    gate_time_2q = 150e-9
    p1 = 1 - np.exp(-gate_time_2q / T1)
    p2 = 1 - np.exp(-gate_time_2q / T2)

    for ii in range(2):
        new_density = np.zeros_like(state)
        for kop in qmats.relaxation_operators(p1):
            operator = lifted_gate_matrix(matrix=kop,
                                          qubit_inds=[ii],
                                          n_qubits=2)
            new_density += operator.dot(state).dot(np.conj(operator).T)
        state = new_density

    for ii in range(2):
        new_density = np.zeros_like(state)
        for kop in qmats.dephasing_operators(p2):
            operator = lifted_gate_matrix(matrix=kop,
                                          qubit_inds=[ii],
                                          n_qubits=2)
            new_density += operator.dot(state).dot(np.conj(operator).T)
        state = new_density

    qam = PyQVM(n_qubits=2,
                quantum_simulator_type=ReferenceDensitySimulator,
                post_gate_noise_probabilities={
                    'relaxation': p1,
                    'dephasing': p2
                })
    qam.execute(program)

    assert np.allclose(qam.wf_simulator.density, state)
Example #2
0
def test_kraus_t1_normalization():
    kraus_ops = relaxation_operators(0.75)
    total = np.zeros((2, 2), dtype=complex)
    for kop in kraus_ops:
        total += np.conj(kop.T).dot(kop)
    assert np.allclose(total, np.eye(2))