def multi_qubit_decay_bellstate(): """ Test multiqubit decay """ program = Program().inst([RYgate(np.pi / 3)(0), CNOTgate(0, 1)]) noise = NoiseModel(ro_fidelity=1.0) qvm = QVMConnection(type_trans='density', noise_model=noise) initial_density = np.zeros((4, 4), dtype=complex) initial_density[0, 0] = 1.0 cnot_01 = np.kron(I, P0) + np.kron(X, P1) p1 = 1 - np.exp(-noise.gate_time_1q / noise.T1) p2 = 1 - np.exp(-noise.gate_time_1q / noise.T2) kraus_ops_1 = noise_gates['relaxation'](p1) kraus_ops_2 = noise_gates['dephasing'](p2) gate_1 = np.kron(np.eye(2), 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 kraus_ops_1: operator = lifted_gate(ii, kop, 2).todense() 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 kraus_ops_2: operator = lifted_gate(ii, kop, 2).todense() new_density += operator.dot(state).dot(np.conj(operator).T) state = new_density state = cnot_01.dot(state).dot(cnot_01.T) p1 = 1 - np.exp(-noise.gate_time_2q / noise.T1) p2 = 1 - np.exp(-noise.gate_time_2q / noise.T2) kraus_ops_1 = noise_gates['relaxation'](p1) kraus_ops_2 = noise_gates['dephasing'](p2) for ii in range(2): new_density = np.zeros_like(state) for kop in kraus_ops_1: operator = lifted_gate(ii, kop, 2).todense() 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 kraus_ops_2: operator = lifted_gate(ii, kop, 2).todense() new_density += operator.dot(state).dot(np.conj(operator).T) state = new_density density = qvm.density(program) assert np.allclose(density.todense(), state)
def test_kraus_through_qvm_t2(): noise = NoiseModel(T1=INFINITY, ro_fidelity=1.0) qvm = QVMConnection(type_trans='density', noise_model=noise) rho = random_1q_density() identity_program = Program().inst(Igate(0)) qvm._density = sps.csc_matrix(rho) qvm.num_qubits = 1 qvm.load_program(identity_program) qvm.kernel() p = 1 - np.exp(-noise.gate_time_1q / noise.T2) final_density = np.array([[rho[0, 0], (1 - p) * rho[0, 1]], [(1 - p) * rho[1, 0], rho[1, 1]]]) assert np.allclose(final_density, qvm._density.todense())