1
$\begingroup$

Is there any way to create a for loop that would send a few jobs to run on a quantum computer simultaneously? I tried:

for i, entanglementor in enumerate(entanglement):
    print('\rentanglement: {}        '.format(entanglement[i]), end='')
    algorithm_globals.random_seed = 50
#ansatz = TwoLocal(rotation_blocks='ry', 
    entanglement_blocks='cz',entanglement=entanglement[i])
    form = EfficientSU2(num_qubits=2, entanglement=entanglement[i])
    #ansatz = RealAmplitudes(2, entanglement[i], reps=2, insert_barriers=True)
    optimizer = COBYLA(maxiter=5)
    counts = []
    values = []
    def store_intermediate_result(eval_count, parameters, mean, std):
    counts.append(eval_count)
    values.append(mean)

    vqe = VQE(form, optimizer, callback=store_intermediate_result,
          quantum_instance=QuantumInstance(backend=device))
    print("Running VQE algorithm on real hardware with device: ", device)
    vqe.ansatz.draw()
    result = vqe.compute_minimum_eigenvalue(operator=H2_op)
    converge_cnts[i] = np.asarray(counts)
    converge_vals[i] = np.asarray(values)
    print('\rentanglement complete      ');

The problem is that this sends one job to the QC, and then waits until it gets a result before continuing the loop, which can obviously take quite a while. Is there a method to get the loop to continue while a job is queued?

$\endgroup$
5

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.