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
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 ascircuit.draw('mpl')
withParameters
. $\endgroup$ Aug 8 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 usestatevec = Statevector(circuit).to_lambda()
then the kernel keeps running indefinitely. $\endgroup$ Aug 8 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 byqiskit-symb
. Could you please open an issue on the GitHub repo specifying your Python andqiskit-terra
version and showing a minimal piece of code raising the error? I could take a look into it immediately. $\endgroup$ Aug 8 at 12:25 -