Is it possible to convert a qiskit circuit into a numpy function, such that the resulting function can be used for further analysis with, possibly, implicit parameters?


1 Answer 1


This is currently not possible by using Qiskit directly but I developed the qiskit-symb package (as part of the official Qiskit Ecosystem) on top of qiskit-terra itself to allow something very similar to what you need.

Check out the README file in the qiskit-symb project repository (this section, in particular). Feel free to contact me if you have questions or you need any support.

  • $\begingroup$ Ah! Good to have the developer here. Yes, I saw your question here in the stack, but it seems that it doesn't "accept" controlled unitary gates: TypeError: CUGate.__init__() got multiple values for argument 'ctrl_qubits'. This is kind of strange, as my circuit is fine, even plotting the circuit as circuit.draw('mpl') with Parameters. $\endgroup$ Aug 8, 2023 at 11:00
  • $\begingroup$ This error is for the first part of the package, when I do op = Operator(circuit); op.to_sympy(). If I use statevec = Statevector(circuit).to_lambda() then the kernel keeps running indefinitely. $\endgroup$ Aug 8, 2023 at 11:38
  • 1
    $\begingroup$ Uh ok, I'm sorry about that! The problem here should be related to a well known issue in Qiskit about parameters assignment for the CUGate (see here) and I guess the error is then not handled properly by qiskit-symb. Could you please open an issue on the GitHub repo specifying your Python and qiskit-terra version and showing a minimal piece of code raising the error? I could take a look into it immediately. $\endgroup$ Aug 8, 2023 at 12:25
  • $\begingroup$ Of course, thanks a lot!! $\endgroup$ Aug 9, 2023 at 10:43

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.