Skip to content

Visualization Error with Kraus Operators #1091

Open
@sesmart

Description

@sesmart

Describe the bug

Gates will commute through a multi-qubit Kraus operator in the circuit visualization.

To reproduce

Provide space in front of Kraus, and then gates will hop through:

from braket.circuits import Circuit
import numpy as np

CX = np.array([[1,0,0,0],[0,1,0,0],[0,0,0,1],[0,0,1,0]])
circ = Circuit().x(0).kraus([1,0], [CX]).h(1).measure([0,1])
print(circ)

from braket.devices import LocalSimulator
qd = LocalSimulator("braket_dm")
res = qd.run(circ, shots=1000).result()
print(res.measurement_counts)

Weird variation also where single qubit Kraus operators prevent gates on other qubits in the same layer.

circ = Circuit().x(0).kraus([0], [np.eye(2)]).h(1).x(1).measure([0,1])

Expected behavior

Gates should not commute through multi-qubit Kraus operators, and single qubit Kraus operators do not need their own layer.

Screenshots

Image

Image

System information
A description of your system. Please provide:

  • Amazon Braket Python SDK version: 1.91.2
  • Amazon Braket Python Schemas version: 1.24.0
  • Amazon Braket Python Default Simulator version: 1.26.5
  • Python version: Tested on 3.10.17, 3.12.10

Additional context
Output and instruction order is correct, just leads to incorrect visualizations.

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