PennyLaneAI / PennyLaneAI/catalyst
Duplicate gates with higher-order gate functions in structured programs
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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