I am trying to run the following circuit:

from qiskit.circuit import ParameterVector, QuantumCircuit
p = qiskit.circuit.ParameterVector('p', 2)
th = qiskit.circuit.ParameterVector('th', 2)

circuit = qiskit.circuit.QuantumCircuit(2)
circuit.rx(p[0], 0) 
circuit.ry(p[1], 1)
circuit.ry(th[1], 1)
circuit.ry(th[0], 1)

qc = transpile(circuit, backend)

I want to pass parameters from two different lists, inp[0] and theta, each of length 2, like so:

bind_dict = {}
j = 0
for key in qc.parameters:
    while j <= 1: #this is the number of inputs, at the moment we have two inputs
        bind_dict[key] = inp[0][j]
    k = 0
    bind_dict[key] = theta[k]

qobj = assemble(qc, shots = 10)

I get the following error:

Traceback (most recent call last):
  Input In [316] in <cell line: 1>
    qobj = assemble(qc, shots = 10)
  File /opt/conda/lib/python3.8/site-packages/qiskit/compiler/assembler.py:205 in assemble
    bound_experiments, run_config = _expand_parameters(
  File /opt/conda/lib/python3.8/site-packages/qiskit/compiler/assembler.py:596 in _expand_parameters
    raise QiskitError(
QiskitError: 'Mismatch between run_config.parameter_binds and all circuit parameters.
Parameter binds: [] Circuit parameters: [ParameterView([ParameterVectorElement(p[0]),     
ParameterVectorElement(p[1]), ParameterVectorElement(th[0]),   

Use %tb to get the full traceback.

It does not seem to assign the parameters to the circuit?


1 Answer 1


By default, QuantumCircuit.assign_parameters() will return a copy of the circuit with the bound parameters. The circuit instance itself will not be modified. To modify it you will need to call it as follows:

qc.assign_parameters(bind_dict, inplace = True)
  • $\begingroup$ Thank you for the reply, unfortunately even with this modification, I still get the same error. Could it be something else? $\endgroup$ May 27, 2022 at 15:22
  • $\begingroup$ I tested your code on my machine. It works after this modification. $\endgroup$ May 27, 2022 at 15:27
  • $\begingroup$ You're right, I don't know why it didn't work for me at first but after restarting the kernel it works. Thanks a lot!! $\endgroup$ May 27, 2022 at 15:40

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.