Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qpy import of circuit with StatePreparation fails #8297

Closed
christoph-riverlane opened this issue Jul 5, 2022 · 1 comment · Fixed by #9665
Closed

qpy import of circuit with StatePreparation fails #8297

christoph-riverlane opened this issue Jul 5, 2022 · 1 comment · Fixed by #9665
Labels
bug Something isn't working

Comments

@christoph-riverlane
Copy link

Environment

  • Qiskit Terra version: 0.21.0
  • Python version: 3.8.9
  • Operating system: macOS (M1)
  • Qiskit version 0.37.0

What is happening?

When reimporting a simple circuit containing a StatePreparation with qiskit.qpy, one gets the error qiskit.exceptions.QiskitError: 'The num_qubits parameter to StatePreparation should only be used when params is an integer'.

How can we reproduce the issue?

Minimal example:

#!/usr/bin/python3
import qiskit
import qiskit.qpy
print(qiskit.__qiskit_version__)
qc = qiskit.QuantumCircuit(1)
qc.prepare_state([0,1], [0])
with open("tmp.qpy", "wb") as file:
    qiskit.qpy.dump(qc, file)
with open("tmp.qpy", "rb") as file:
    new_qc = qiskit.qpy.load(file)
#qiskit.exceptions.QiskitError: 'The num_qubits parameter to StatePreparation should only be used when params is an integer'

What should happen?

Reimporting a circuit with qiskit.qpy should be possible.

Any suggestions?

No response

@christoph-riverlane christoph-riverlane added the bug Something isn't working label Jul 5, 2022
@jsmallz333
Copy link
Contributor

jsmallz333 commented Aug 8, 2022

This may be akin to issue #7847 wherein the serializer has an issue with a non-standard gate. Fixing this would require specifying the 'StatePreparation' here:

https://github.com/Qiskit/qiskit-terra/blob/2bab09c1aae84e5bf38ba52fa3a272667c1887cc/qiskit/qpy/binary_io/circuits.py#L272

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants