amazon-braket-sdk-python icon indicating copy to clipboard operation
amazon-braket-sdk-python copied to clipboard

Visualization Error with Kraus Operators

Open sesmart opened this issue 7 months ago • 0 comments

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.

sesmart avatar Jun 06 '25 18:06 sesmart