PennyLaneAI / PennyLaneAI/catalyst
AutoGraph errors if there are control/adjoint functions used on operator objects
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 234
- Forks
- 84
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 66
Description
The following program fails with an AssertionError when using AutoGraph:
dev = qml.device("lightning.qubit", wires=2)
@qml.qjit(autograph=True)
@qml.qnode(dev)
def circuit():
qml.ctrl(qml.PauliX(0), control=1)
return qml.probs(wires=0)
However, it works fine when qml.ctrl is passed a callable instead:
@qml.qjit(autograph=True)
@qml.qnode(dev)
def circuit():
qml.ctrl(qml.PauliX, control=1)(0)
return qml.probs(wires=0)
>>> circuit()
Array([1., 0.], dtype=float64)
This is likely because the hotfix defined here,
does not take this form of ctrl/adjoint into account.
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 reading frontend/catalyst/autograph/ag_primitives.py around lines 537-552, then run the operator-object reproducer from the issue with AutoGraph enabled. Compare it with the callable form and inspect existing tests for ctrl and adjoint handling. Done means operator-object control and adjoint calls no longer raise AssertionError while the existing callable behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100