Skip to content

Bug/feature: add adjoint Barrier gate #1259

@sesmart

Description

@sesmart

Describe the feature you'd like

Barrier does not have an adjoint.

How would this feature be used? Please describe.

Any circuit.adjoint() call where a barrier instruction is in the circuit.

Describe alternatives you've considered

None.

Additional context

MWE:

from braket.circuits import Circuit
test = Circuit().barrier([0,1])
test.adjoint()

yields:

  File "test.py", line 3, in <module>
    test.adjoint()
    ~~~~~~~~~~~~^^
  File "/.venv313/lib/python3.13/site-packages/braket/circuits/circuit.py", line 1280, in adjoint
    circ.add(instr.adjoint())
             ~~~~~~~~~~~~~^^
  File "/.venv313/lib/python3.13/site-packages/braket/circuits/instruction.py", line 153, in adjoint
    return [Instruction(operator.counterpart(), self._target)]
                        ~~~~~~~~~~~~~~~~~~~~^^
  File "/.venv313/lib/python3.13/site-packages/braket/circuits/compiler_directive.py", line 96, in counterpart
    raise NotImplementedError(
        f"Compiler directive {self.name} does not have counterpart implemented"
    )
NotImplementedError: Compiler directive Barrier does not have counterpart implemented

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions