PennyLaneAI / PennyLaneAI/catalyst

AutoGraph errors if there are control/adjoint functions used on operator objects

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

Nobody has claimed this yet.

bug
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,

https://github.com/PennyLaneAI/catalyst/blob/845851662af490a45bff92ec32b5d1aaef7e7b10/frontend/catalyst/autograph/ag_primitives.py#L537-L552

does not take this form of ctrl/adjoint into account.

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.