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', 
    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):

    vqe = VQE(form, optimizer, callback=store_intermediate_result,
    print("Running VQE algorithm on real hardware with device: ", device)
    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?



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.