Skip to content

Circuit decoding error #11446

@samanthavbarron

Description

@samanthavbarron

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions