I need to calculate the expectation values of an operator h for various quantum states ψ on an IBMQ quantum machine. This can be done using the method described in this answer like the following,
for i, inp in enumerate(x):
parameters = {list(a.parameters)[0]: inp}
ψ = CircuitStateFn(a.assign_parameters(parameters))
measurable_expression = StateFn(h, is_measurement=True).compose(ψ)
expectation = PauliExpectation().convert(measurable_expression)
sampler = CircuitSampler(qi).convert(expectation)
y[i] = sampler.eval().real
z[i] = sampler.eval().imag
Now, I've noticed that these jobs sits idle in the queue for a long time before being executed which itself doesn't take too long. So I am thinking of submitting multiple jobs in parallel. I thought of providing a ThreadPoolExecutor to the backend but it seems that it only works with AerSimulator not real quantum hardware.
Is there a way to do this? Thanks.