PennyLaneAI / PennyLaneAI/catalyst

Duplicate gates with higher-order gate functions in structured programs

Open
#1,908 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug frontend
Dominant language
Python
Stars
234
Forks
84
Avg merge
2d 15h
Merged PRs (30d)
66

Description

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]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the example with qml.qjit, qml.cond, and qml.adjoint, then trace how Catalyst handles gates captured in separate program scopes or tapes. Compare the resulting state with the expected behavior and add coverage for the cross-control-flow case; done means the original and modified gates are not duplicated.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.