# The amount of clbit arguments 0 does not match the instruction expectation (16)

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?

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.

• 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.
– user21029
Commented May 25, 2023 at 12:07
• 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). Commented May 25, 2023 at 15:57
• Let me know if this fixes it. If this is the case, there should be a more meaningful error message in the class. Commented May 25, 2023 at 15:58
• 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.
– user21029
Commented May 26, 2023 at 5:53

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

Your qcirc is the State preparation circuit here.