1
$\begingroup$

I have a quantum circuit of 16 qubits, and I am running Amplitude Estimation on that, my final qubit to measure is 15th, so I do this

problem = EstimationProblem(
state_preparation = qcirc,
objective_qubits = [15],
)

and for Amplitude estimation:

# construct amplitude estimation
ae = IterativeAmplitudeEstimation(
epsilon_target=epsilon,
alpha=alpha,
sampler=Sampler(run_options={"shots": 100})
)

where the values of epsilon and alpha are 0.01 and 0.05

The finally when I run it:

result = ae.estimate(problem)

It is giving me the following error:

CircuitError: 'The amount of clbit arguments 0 does not match the instruction expectation (16).'

My qcirc has 16 qubits and 16 classical registers, I started by qcirc as

qcirc = QuantumCircuit(16,16)

What might be the reason for this error?

$\endgroup$

2 Answers 2

0
$\begingroup$

It's difficult to tell without the code you used to define qcirc, but... Did you add measurements to your circuit? If you haven't, you can try running qcirc.measure_all() before defining your EstimationProblem.

$\endgroup$
4
  • $\begingroup$ Measuring the entire circuit kind of defeats the purpose, since I only want to measure one specific qubit . qcirc is simply a 16 qubit circuit with some adders and rotation on some qubits. $\endgroup$
    – user21029
    May 25, 2023 at 12:07
  • $\begingroup$ Yes, that is true, you would only need to measure specific qubits (my bad), and the AE class adds registers to perform measurements for you (see line 198 and 199 here). Thus, I think that the problem was not lack of classical bits, but excess of them. Can you try to remove the classical bits from your circuit? i.e, do qcirc = QuantumCircuit(16) instead of qcirc = QuantumCircuit(16,16). $\endgroup$
    – ElenaPT
    May 25, 2023 at 15:57
  • $\begingroup$ Let me know if this fixes it. If this is the case, there should be a more meaningful error message in the class. $\endgroup$
    – ElenaPT
    May 25, 2023 at 15:58
  • $\begingroup$ No, it did not fixed the error, but i now know why the error is there, so basically the EstimationProblem and the AE asks for grover operator, even tho i have specified the grover operator to be none, it's running the error from there. $\endgroup$
    – user21029
    May 26, 2023 at 5:53
0
$\begingroup$

There should be no classical registers in your quantum circuit. Just make your quantum circuit

qcirc = QuantumCircuit(16)

then do your operations and then call the IterativeAmplitudeEstimation function by:

# construct amplitude estimation
ae = IterativeAmplitudeEstimation(
epsilon_target=epsilon,
alpha=alpha,
sampler=Sampler(run_options={"shots": 100})
)

If you are getting an error for Grover Operator, you can prepare a Grover operator beforehand and pass it to EstimationProblem

Follow this: https://docs.quantum.ibm.com/api/qiskit/0.29/qiskit.circuit.library.GroverOperator

Your qcirc is the State preparation circuit here.

$\endgroup$

Your Answer

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