PennyLaneAI / PennyLaneAI/catalyst

Add support for rotation gates in `to_ppr` pass

Open
#2,429 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Currently, The to_ppr pass supports PauliRot gate. but not regular rotation gates like RX. Since the latter can be expressed as a PauliRot gate, we can add support for them as well.

Right now, a circuit like below would fail:

qml.capture.enable()
dev = qml.device("null.qubit", wires=1)
pipeline = [("pipe", ["quantum-compilation-stage"])]
@qml.qjit(pipelines=pipeline)
@qml.transforms.to_ppr
@qml.qnode(dev)
def circuit():
    qml.RX(0.1, wires=0)
    return qml.expval(qml.PauliZ(0))

print(circuit.mlir_opt)

with the error message:

catalyst.utils.exceptions.CompileError: catalyst failed with error code 1: Compilation failed:
circuit:24:12: error: Unsupported gate. Supported gates: H, S, T, X, Y, Z, S†, T†, I, and CNOT
      %5 = "quantum.custom"(%4, %3) {gate_name = "RX", operandSegmentSizes = array<i32: 1, 1, 0, 0>, resultSegmentSizes = array<i32: 1, 0>} : (f64, !quantum.bit) -> !quantum.bit
           ^

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 provided qml.RX example with qml.transforms.to_ppr and the shown compilation pipeline. Then inspect the to_ppr pass and its existing PauliRot handling; done means regular rotation gates such as RX compile without the unsupported-gate error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 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.