def test_distributed_circuit_execution_special_gate(backend, accelerators): dist_c = DistributedCircuit(6, accelerators) initial_state = random_state(dist_c.nqubits) dist_c.add(gates.Flatten(np.copy(initial_state))) dist_c.add((gates.H(i) for i in range(dist_c.nlocal))) dist_c.global_qubits = range(dist_c.nlocal, dist_c.nqubits) c = Circuit(6) c.add(gates.Flatten(np.copy(initial_state))) c.add((gates.H(i) for i in range(dist_c.nlocal))) np.testing.assert_allclose(dist_c(), c())
def test_distributed_circuit_execution_with_swap(backend, accelerators): dist_c = DistributedCircuit(6, accelerators) dist_c.add((gates.H(i) for i in range(6))) dist_c.add((gates.SWAP(i, i + 1) for i in range(5))) dist_c.global_qubits = [0, 1] c = Circuit(6) c.add((gates.H(i) for i in range(6))) c.add((gates.SWAP(i, i + 1) for i in range(5))) initial_state = random_state(c.nqubits) final_state = dist_c(np.copy(initial_state)) target_state = c(np.copy(initial_state)) np.testing.assert_allclose(target_state, final_state)
def test_distributed_circuit_execution(backend, accelerators, use_global_qubits): dist_c = DistributedCircuit(6, accelerators) c = Circuit(6) if use_global_qubits: dist_c.add((gates.H(i) for i in range(dist_c.nqubits))) c.add((gates.H(i) for i in range(dist_c.nqubits))) else: dist_c.add((gates.H(i) for i in range(dist_c.nlocal))) c.add((gates.H(i) for i in range(dist_c.nlocal))) dist_c.global_qubits = range(dist_c.nlocal, dist_c.nqubits) initial_state = random_state(c.nqubits) final_state = dist_c(np.copy(initial_state)) target_state = c(np.copy(initial_state)) np.testing.assert_allclose(target_state, final_state)