Skip to content

Regression: instruction label must now be a string #12581

@garrison

Description

@garrison

Environment

  • Qiskit version: main
  • Python version:
  • Operating system:

What is happening?

I am witnessing a CI failure in the circuit-knitting-toolbox that very likely has something to do with the merging of #12459. (We run CI against Qiskit main on a cron job every day.)

Here is one such error:

    def _split_barriers(circuit: QuantumCircuit):
        """Mutate an input circuit to split barriers into single qubit barriers."""
        for i, inst in enumerate(circuit):
            num_qubits = len(inst.qubits)
            if num_qubits == 1 or inst.operation.name != "barrier":
                continue
            barrier_uuid = uuid4()
    
            # Replace the N-qubit barrier with a single-qubit barrier
>           circuit.data[i] = CircuitInstruction(
                Barrier(1, label=barrier_uuid), qubits=[inst.qubits[0]]
            )
E           TypeError: 'UUID' object cannot be converted to 'PyString'

How can we reproduce the issue?

from uuid import uuid4
from qiskit.circuit import Barrier, CircuitInstruction

CircuitInstruction(Barrier(1, label=uuid4()), (0,))

What should happen?

It should work like before.

Any suggestions?

It is probably sufficient to call str(...) on any object before passing to Rust, and to add a test.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions