Commit 5e3813a
authored
Add error if transform applied inside a qnode with program capture. (#2256)
**Context:**
We currently don't support applying transforms to a subcircuit. We need
to explicitly error out on this case.
For:
```
@qml.qjit
@qml.qnode(qml.device('lightning.qubit', wires=1))
@qml.transforms.cancel_inverses
def c():
qml.X(0)
qml.X(0)
return qml.probs()
c(), print(c.mlir)
```
we would have gotten:
```
TypeError: No ir_type_handler for aval type: <class 'pennylane.measurements.capture_measurements._get_abstract_measurement.<locals>.AbstractMeasurement'>
```
Now we get:
```
NotImplementedError: transforms cannot currently be applied inside a QNode.
```
Which is much more helpful and informative.
**Description of the Change:**
`QFuncToPlxprInterpreter` now raises an error if it encounters a
transform.
**Benefits:**
Improved usability.
**Possible Drawbacks:**
**Related GitHub Issues:**
[sc-104320]1 parent fd2e4be commit 5e3813a
File tree
3 files changed
+24
-0
lines changed- doc/releases
- frontend
- catalyst/from_plxpr
- test/pytest/from_plxpr
3 files changed
+24
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
73 | 76 | | |
74 | 77 | | |
75 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
807 | 808 | | |
808 | 809 | | |
809 | 810 | | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
810 | 816 | | |
811 | 817 | | |
812 | 818 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
182 | 197 | | |
183 | 198 | | |
184 | 199 | | |
| |||
0 commit comments