Trying to count the number of uses of my circuit $A$ in Grover iterate circuit $Q= -AS_0A^{\dagger}S_x$.

However, Qiskit's amplitude estimation algorithms such as IAE or FAE accept only precision arguments like e.g. confidence of solution, error. I run them like this:

from qiskit.algorithms import IterativeAmplitudeEstimation, EstimationProblem, FasterAmplitudeEstimation

problem = EstimationProblem(state_operation=myqc, objective_qubits=[0])
algorithm = IterativeAmplitudeEstimation(**kwargs)
result = algorithm.estimate(problem)
amplitude = result.estimation

How can I get the number of total iterations along with the result or at least get the circuit? Do I need to create my own implementations of the algorithms?


1 Answer 1


For the number of iterations, you can do

for i,j in enumerate(result_delta._estimate_intervals):

For the circuit result, you can try to do result.circuit_results, it might return a Statevector or counts dictionary.
and algorithm.construct_circuit(problem) to check the problem circuit.

#recommend way to view the problem gate
from qiskit import transpile
transpile(ae_delta.construct_circuit(problem),basis_gates = ['ry', 'cx','ccx','x']).draw()

For any more related coding questions, you can just do something like dir(result) to see its attribute, then check sources code or docs about these attributes for the explanation.

hope it is something you are looking for

  • $\begingroup$ accept answer will help a lot thank you $\endgroup$
    – poig
    Jun 23, 2022 at 4:06
  • $\begingroup$ Thanks a lot for your advice!. Could you elaborate a bit further about the estimate_intervals attribute? How is it supposed to help? And why not use num_oracle_queries? $\endgroup$
    – consthatza
    Jul 5, 2022 at 11:39
  • $\begingroup$ I think you can simply look at the docs and sources code to understand that, num_oracle_queries Return the number of Grover oracle queries. and estimate_intervals Return the confidence intervals for the estimate in each iteration. $\endgroup$
    – poig
    Jul 5, 2022 at 15:07
  • $\begingroup$ Docs helped indeed, but you confused me a bit since I was asking for iterations/queries and you said about estimate_intervals. Nevertheless, you helped a lot so I can give you this answer. $\endgroup$
    – consthatza
    Jul 6, 2022 at 7:36

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.