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

Circuit decoding error #11446

Closed
samanthavbarron opened this issue Dec 20, 2023 · 1 comment · Fixed by #11447
Closed

Circuit decoding error #11446

samanthavbarron opened this issue Dec 20, 2023 · 1 comment · Fixed by #11447
Labels
bug Something isn't working
Milestone

Comments

@samanthavbarron
Copy link
Contributor

samanthavbarron commented Dec 20, 2023

Environment

  • Qiskit Terra version: 0.45.1
  • Python version: 3.10.12
  • Operating system: macOS 13.6 (22G120)

What is happening?

Serialization decoding of a circuit with qpy fails when qargs for a delay are passed in as a set and len(qargs) > 1. The error raised here is

ValueError: b'\x00' is not a valid Value

and when running the circuit on a device, the job will fail with something like:

Failed - UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa0 in position 87: invalid start byte

How can we reproduce the issue?

from qiskit import QuantumCircuit, qpy

# This case fails when the delay is present
num_qubits = 2
qubits = {0, 1}

# This case always runs
#num_qubits = 1
#qubits = {0}

qc = QuantumCircuit(num_qubits)
qc.delay(duration=160, qarg=qubits)
qc.x(qubits)

with open("test.qpy", "wb") as f:
    qpy.dump(qc, f)

with open("test.qpy", "rb") as f:
    qpy.load(f)

What should happen?

This should run regardless of the cases described.

Any suggestions?

No response

@samanthavbarron samanthavbarron added the bug Something isn't working label Dec 20, 2023
@jakelishman
Copy link
Member

This is a bug with QuantumCircuit.delay rather than QPY - it's the same thing as #11208 going on, where the initial QuantumCircuit is in a totally invalid state that's somehow not noticed. It's because of our old "friend" broadcasted arguments.

As an immediate work-around, turn the set into a list and the circuit will be valid (and roundtrip through QPY, etc).

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