Skip to content

Duplicate gates with higher-order gate functions in structured programs #1908

@dime10

Description

@dime10

The normal mechanism in PennyLane that "un-queues" a gate when supplied to a HOF like qml.adjoint does not work when the original and modified gate appear in different program scopes, such as across control flow segments. The reason is that Catalyst using different tapes for each section.

import pennylane as qml

@qml.qjit
@qml.qnode(qml.device("lightning.qubit", wires=1))
def circuit(b: bool):
    g = qml.H(0)

    @qml.cond(b)
    def apply():
        qml.adjoint(g)
    apply()

    return qml.state()

print(circuit(1))  # should not read [1, 0]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfrontendPull requests that update the frontend

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions