I am using the method from this SE answer to calculate the expectation value using qiskit aqua operator logic which works well for a single circuit. Here is a simplified code snippet to demonstrate how it works.
import qiskit from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, Aer import numpy as np from qiskit.aqua import QuantumInstance from qiskit.aqua.operators import PauliExpectation, CircuitSampler, StateFn, CircuitOp, CircuitStateFn qctl = QuantumRegister(1) psi = QuantumCircuit(qctl) psi = CircuitStateFn(psi) qctl = QuantumRegister(2) op = QuantumCircuit(qctl) op.z(0) op.ry(np.pi/4,0) op = CircuitOp(op) backend = Aer.get_backend('qasm_simulator') q_instance = QuantumInstance(backend, shots=1024) measurable_expression = StateFn(op, is_measurement=True).compose(psi) expectation = PauliExpectation().convert(measurable_expression) sampler = CircuitSampler(q_instance).convert(expectation) print('Expectation Value = ', sampler.eval())
However, I am applying it to a VQE application and for each iteration I have $x>1$ circuits. There is no issue when I run on my local machine because there is no queue time, but on the IBMQ machines I would like to submit a batch of the aqua expectation value circuits for each iteration to reduce queue times. For a list of circuits I can submit a batch using the
IBMQJobManager() function, however, the method I am using does not store circuits as a list. My question is, can I use the jobmanager with the aqua expectation value to submit a batch of jobs to IBMQ? If not, is there a different way to submit a batch of the aqua expectation value circuits?