When you run a qiskit based code on HPC system, do it really matters how many cores you are using? I am running a VQE based code on HPC system on qasm_simulator(which is basically a local simulator using your system resources) using 84 CPUs and 150 GB memory and it is taking huge huge time. I excepted that some how qiskit based code will automatically use system resources and will run fast, but I think I am wrong. Can you suggest something or provide some link by which I can increase the execution speed of my qiskit based python code and use my resources efficiently.

Edit I think, probably I should reduce the number of cores if qiskit donot need so many cores for good execution but I am not sure what number of CPUs I should try? Becaue my jobs are getting unnecessary pending, waiting for so much resources.

Edit2 Just to make my question more clear, suppose I implement a 16 bit circuit on qasm_simulator(using the approach mentioned in: Using qiskit on mutiple cores) using 16 CPUs. Will this circuit get executed faster if I execute using more than 16 CPUs? (I am assuming that each qubit will be executed parallely separate CPUs, but not sure whether is correct) Suppose, I use less than 16 CPUs, then will the execution take more time? Can shots be executed parallely by taking large number of CPUs? Not sure what value should I put for max_parallel_shots? Should I put here 16 since I am using CPUs?

    from qiskit.circuit.random import random_circuit
    from qiskit import transpile
    from qiskit_aer import AerSimulator
    from qiskit import QuantumCircuit, execute, Aer, IBMQ
    provider = IBMQ.load_account()
    circuit = QuantumCircuit(16,16)
    for i in range(0,16):
    backend = Aer.get_backend('qasm_simulator')
        max_parallel_threads = 0,
        max_parallel_experiments = 0,
        max_parallel_shots = 1,               
        statevector_parallel_threshold = 16

job = execute(circuit, backend, shots = 10000)
result = job.result()

counts = result.get_counts(circuit)
print("\n Total count for 00 and 11 are:", counts)
# Draw the circuit 

Suppose, I am executing any iterative VQE API like compute_minimum_eigenvalue, is there any benefit if I use more CPUs? I want to use only appropriate number of CPUs on my HPC college cluster. Unnessarily using large number of CPU in the sbatch file put your job in a big queue? Also, is there any benefit if I use GPU?

  • $\begingroup$ Does this answers your question? $\endgroup$ Mar 18 at 7:53
  • $\begingroup$ Thank you @Egretta.Thula for providing me the link. I edited the question according to your code. Please review my updated question. $\endgroup$
    – Manu
    Mar 19 at 4:18

1 Answer 1


Let me answer more generally before coming to VQE. An above comment has a link to configuring Aer simulator for parallel computation and the Aer QasmSimulator API Ref. also lists them. You can use Aer with a Dask cluster - see this article Speed Up Your Multi-Circuit Simulations Using Qiskit Aer with DASK Clusters Then Aer supports GPU operation too. So that's the capabilities in general.

When it comes to VQE it's an iterative algorithm that will run circuits for the current point and evaluate if it has reached a minimum and if not move to next point. So that's more a sequence of things. Your operator will be a sum of paulis, most usually these are grouped into sets which commute so less circuits need to be run, than doing it for each pauli. Of course any grouping depends on the operator. Such circuits can be run in parallel. Then the optimizer itself, the Qiskit Algorithms supports a max_evals_grouped which allows an optimizer to call the objective function with more than one point so things can potentially be parallelized. SPSA for instance computes 2 points for its process. Gradient based optimizers will compute, for the default finite diff in the scipy ones, one point for each dimension where its a small eps delta so as to compute a gradient. There is more opportunity then to do things in parallel, but the sampling noise from the qasm simulator is going to have a great impact here so such an optimizer is not recommended.

  • $\begingroup$ Thank you @Steve Wood for your response. I want to execute only only circuit at a time. If there any benefit If I use more CPU cores? Please review my updated question. $\endgroup$
    – Manu
    Mar 19 at 4:26

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.