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.
IBMQJobManager.run
does? https://quantumcomputing.stackexchange.com/a/12758 – bisarch Oct 10 '22 at 12:16run_circuits()
function which is used byQuantumInstance
class. – Egretta.Thula Oct 11 '22 at 03:44CircuitSampler
takes an instance ofQuantumInstance
as a parameter (qi
in your code snippet). Which means you can use the exact same idea. – Egretta.Thula Oct 11 '22 at 16:41NoiseAdaptiveLayout
. Do you think this will do the trick?noise_adaptive_layout = NoiseAdaptiveLayout(backend.properties()) pass_manager = PassManager() pass_manager.append(noise_adaptive_layout) qi = QuantumInstance(backend, pass_manager=pass_manager, seed_transpiler=seed, seed_simulator=seed, noise_model=noise_model)
– bisarch Oct 11 '22 at 17:01Error is : The Qobj uses gates (['h', 'sdg', 'rx']) that are not among the basis gates (['id', 'rz', 'sx', 'x', 'cx', 'reset']). Error code: 1106.. Re-submit the circuits.
– bisarch Oct 11 '22 at 17:34layout_method
:pmc = PassManagerConfig.from_backend(backend)
pmc.layout_method = 'noise_adaptive'
pass_manager = level_2_pass_manager(pmc)
– Egretta.Thula Oct 12 '22 at 06:53level_2_pass_manager
there instead of saylevel_3_pass_manager
? I tried using the later in the above code which leads toTypeError: TwoQubitWeylDecomposition.__new__() missing 1 required positional argument: 'unitary_matrix'
– bisarch Oct 12 '22 at 14:42