2
2
3
3
<h3 >New features since last release</h3 >
4
4
5
- * Catalyst can now load local MLIR plugins from python. Including support for ` entry_points ` .
5
+ * Catalyst can now load and apply local MLIR plugins from the PennyLane frontend .
6
6
[ (#1317 )] ( https://github.com/PennyLaneAI/catalyst/pull/1317 )
7
7
[ (#1361 )] ( https://github.com/PennyLaneAI/catalyst/pull/1361 )
8
8
[ (#1370 )] ( https://github.com/PennyLaneAI/catalyst/pull/1370 )
9
9
10
+ Custom compilation passes and dialects in MLIR can be specified for use in Catalyst via a shared
11
+ object (` *.so ` or ` *.dylib ` on MacOS) that implements the pass. Details on creating your own
12
+ plugin can be found in our
13
+ [ compiler plugin documentation] ( https://docs.pennylane.ai/projects/catalyst/en/stable/dev/plugins.html ) .
14
+ At a high level, there are three ways to utilize a plugin once it's properly specified:
15
+
16
+ * :func:` ~.passes.apply_pass ` can be used on QNodes when there is a
17
+ [ Python entry point] ( https://packaging.python.org/en/latest/specifications/entry-points/ )
18
+ defined for the plugin.
19
+
20
+ ``` python
21
+ @catalyst.passes.apply_pass (pass_name)
22
+ @qml.qnode (qml.device(" lightning.qubit" , wires = 1 ))
23
+ def qnode ():
24
+ return qml.state()
25
+
26
+ @qml.qjit
27
+ def module ():
28
+ return qnode()
29
+ ```
30
+
31
+ * :func:`~ .passes.apply_pass_plugin` can be used on QNodes when there is not an entry point
32
+ defined for the plugin.
33
+
34
+ ```python
35
+ @ catalyst.passes.apply_pass_plugin(path_to_plugin, pass_name)
36
+ @ qml.qnode(qml.device(" lightning.qubit" , wires = 1 ))
37
+ def qnode():
38
+ return qml.state()
39
+
40
+ @ qml.qjit
41
+ def module():
42
+ return qnode()
43
+ ```
44
+
45
+ * Specifying multiple compilation pass plugins or dialect plugins directly in :func:`~ .qjit` via
46
+ the `pass_plugins` and `dialect_plugins` keyword arguments, which must be lists of plugin paths.
47
+
48
+ ```python
49
+ from pathlib import Path
50
+
51
+ plugin = Path(" shared_object_file.so" )
52
+
53
+ @qml.qnode (qml.device(" lightning.qubit" , wires = 0 ))
54
+ def qnode ():
55
+ qml.Hadamard(wires = 0 )
56
+ return qml.state()
57
+
58
+ @qml.qjit (pass_plugins = [plugin], dialect_plugins = [plugin])
59
+ def module ():
60
+ return catalyst.passes.apply_pass(qnode, " pass_name" )()
61
+ ```
62
+
63
+ For more information on usage,
64
+ visit our [compiler plugin documentation](https:// docs.pennylane.ai/ projects/ catalyst/ en/ stable/ dev/ plugins.html).
65
+
10
66
< h3> Improvements 🛠< / h3>
11
67
12
- * Lightning runtime shot-measurement support for Hermitian observables .
68
+ * The lightning runtime now supports finite shots with measuring expectation values of `qml.Hermitian` .
13
69
[(# 451)](https://github.com/PennyLaneAI/catalyst/pull/451)
14
70
15
- * Replace pybind11 with nanobind for C++/Python bindings in the frontend and in the runtime.
71
+ * Pybind11 has been replaced with nanobind for C++ / Python bindings in the frontend and in the runtime.
16
72
[(# 1173)](https://github.com/PennyLaneAI/catalyst/pull/1173)
17
73
[(# 1293)](https://github.com/PennyLaneAI/catalyst/pull/1293)
18
74
[(# 1391)](https://github.com/PennyLaneAI/catalyst/pull/1391)
19
75
20
76
Nanobind has been developed as a natural successor to the pybind11 library and offers a number of
21
- [ advantages] ( https://nanobind.readthedocs.io/en/latest/why.html#major-additions ) , in particular,
22
- its ability to target Python's [ stable ABI interface] ( https://docs.python.org/3/c-api/stable.html )
23
- starting with Python 3.12.
77
+ [advantages](https:// nanobind.readthedocs.io/ en/ latest/ why.html# major-additions) like its ability
78
+ to target Python' s [stable ABI interface](https://docs.python.org/3/c-api/stable.html) starting
79
+ with Python 3.12 .
24
80
25
- * Catalyst now uses the new compiler API to compile quantum code from the python frontend.
26
- Frontend no longer uses pybind11 to connect to the compiler. Instead, it uses subprocess instead.
81
+ * Catalyst now uses the new compiler API ( `catalyst - cli` ) to compile quantum code from the Python
82
+ frontend instead of using pybind11 as an interface between the compiler and the frontend.
27
83
[(# 1285)](https://github.com/PennyLaneAI/catalyst/pull/1285)
28
84
29
- * Add a MLIR decomposition for the gate set {"T", "S", "Z", "Hadamard", "RZ", "PhaseShift", "CNOT"}
30
- to the gate set {RX, RY, MS}. It is useful for trapped ion devices. It can be used thanks to
31
- ` quantum-opt --ions-decomposition ` .
85
+ * Gates in the gate set `{T, S, Z, Hadamard, RZ , PhaseShift, CNOT }` now have MLIR decompositions to
86
+ the gate set `{RX , RY , MS }` , which are useful for trapped ion devices.
32
87
[(# 1226)](https://github.com/PennyLaneAI/catalyst/pull/1226)
33
88
34
- * qml.CosineWindow is now compatible with QJIT.
89
+ * ` qml.CosineWindow` is now compatible with QJIT .
35
90
[(# 1166)](https://github.com/PennyLaneAI/catalyst/pull/1166)
36
91
37
92
* All PennyLane templates are tested for QJIT compatibility.
38
93
[(# 1161)](https://github.com/PennyLaneAI/catalyst/pull/1161)
39
94
40
- * Decouple Python from the Runtime by using the Python Global Interpreter Lock (GIL) instead of
41
- custom mutexes.
95
+ * Python is now decoupled from the Runtime by using the Python Global Interpreter Lock (GIL ) instead
96
+ of custom mutexes.
42
97
[(# 624)](https://github.com/PennyLaneAI/catalyst/pull/624)
43
98
44
99
In addition, executables created using :func:`~ .debug.compile_executable` no longer require
45
100
linking against Python shared libraries after decoupling Python from the Runtime C- API .
46
101
[(# 1305)](https://github.com/PennyLaneAI/catalyst/pull/1305)
47
102
48
- * Improves the readability of conditional passes in pipelines
103
+ * The readability of conditional passes in `catalyst. pipelines` has been improved.
49
104
[(# 1194)](https://github.com/PennyLaneAI/catalyst/pull/1194)
50
105
51
- * Cleans up the output of compiler instrumentation.
106
+ * The output of compiler instrumentation has been cleaned up by only printing stats after a `pipeline` .
107
+ It is still possible to get the more detailed output with `qjit(verbose = True )` .
52
108
[(# 1343)](https://github.com/PennyLaneAI/catalyst/pull/1343)
53
109
54
- * Generate stable ABI wheels for Python 3.12 and up.
110
+ * Stable ABI wheels for Python 3.12 and up are now generated .
55
111
[(# 1357)](https://github.com/PennyLaneAI/catalyst/pull/1357)
56
112
[(# 1385)](https://github.com/PennyLaneAI/catalyst/pull/1385)
57
113
58
- * A new circuit optimization pass , ` --disentangle-CNOT ` , is available.
114
+ * Two new circuit optimization passes , `-- disentangle- CNOT ` and ` -- disentangle - SWAP ` , are available.
59
115
[(# 1154)](https://github.com/PennyLaneAI/catalyst/pull/1154)
60
116
61
- The pass disentangles CNOT gates whenever possible, e.g. when the control bit
62
- is known to be in |0>, the pass removes the CNOT. The pass uses a finite state
63
- machine to propagate simple one-qubit states, in order to determine
64
- the input states to the CNOT.
65
-
66
- The algorithm is taken from [ Relaxed Peephole Optimization: A Novel Compiler Optimization for Quantum Circuits, by Ji Liu, Luciano Bello, and Huiyang Zhou] ( https://arxiv.org/abs/2012.07711 ) .
67
-
68
- * A new circuit optimization pass, ` --disentangle-SWAP ` , is available.
69
- [ (#1297 )] ( https://github.com/PennyLaneAI/catalyst/pull/1297 )
117
+ The CNOT pass disentangles CNOT gates whenever possible, e.g., when the control bit is known to be
118
+ in the `| 0 > ` state, the pass removes the CNOT . The pass uses a finite state machine to propagate
119
+ simple one- qubit states, in order to determine the input states to the CNOT .
120
+
121
+ Similarly, the SWAP pass disentangles SWAP gates whenever possible by using a finite state machine
122
+ to propagate simple one- qubit states, similar to the `-- disentangle- CNOT ` pass .
70
123
71
- The pass disentangles SWAP gates whenever possible by using a finite state
72
- machine to propagate simple one-qubit states, similar to the ` --disentangle-CNOT ` pass.
73
-
74
- The algorithm is taken from [ Relaxed Peephole Optimization: A Novel Compiler Optimization for Quantum Circuits, by Ji Liu, Luciano Bello, and Huiyang Zhou] ( https://arxiv.org/abs/2012.07711 ) .
124
+ Both passes are implemented in accordance with the algorithm from
125
+ J. Liu, L. Bello, and H. Zhou, _Relaxed Peephole Optimization: A Novel Compiler Optimization for Quantum Circuits_, 2020 , [arXiv:2012.07711 ](https:// arxiv.org/ abs / 2012.07711 ) [quant- ph].
75
126
76
127
* Allow specifying a branch to switch to when setting up a dev environment from the wheels.
77
128
[(# 1406)](https://github.com/PennyLaneAI/catalyst/pull/1406)
78
129
79
130
< h3> Breaking changes 💔< / h3>
80
131
81
- * The ` sample ` and ` counts ` measurement primitives now support dynamic shot values across catalyst, although at the PennyLane side, the device shots still is constrained to a static integer literal.
132
+ * The `sample` and `counts` measurement primitives now support dynamic shot values across Catalyst,
133
+ although, on the PennyLane side, the device' s shots is still constrained to a static integer
134
+ literal.
135
+ [(# 1310)](https://github.com/PennyLaneAI/catalyst/pull/1310)
82
136
83
- To support this, ` SampleOp ` and ` CountsOp ` in mlir no longer carry the shots attribute, since integer attributes are tied to literal values and must be static.
137
+ To support this, `SampleOp` and `CountsOp` in MLIR no longer carry the shots attribute, since
138
+ integer attributes are tied to literal values and must be static.
84
139
85
- ` DeviceInitOp ` now takes in an optional SSA argument for shots, and the device init runtime CAPI will take in this SSA shots value as an argument and set it as the device shots.
86
- The sample and counts runtime CAPI functions no longer take in the shots argument and will retrieve shots from the device.
140
+ `DeviceInitOp` now takes in an optional SSA argument for shots, and the device init runtime CAPI
141
+ will take in this SSA shots value as an argument and set it as the device shots. The sample and
142
+ counts runtime CAPI functions no longer take in the shots argument and will retrieve shots from
143
+ the device.
87
144
88
- Correspondingly, the device C++ interface should no longer parse the ` DeviceInitOp ` 's attributes dictionary for the shots.
89
- For now we still keep the shots as an attribute so device implementors can have time to migrate, but we will remove shots from the attribute dictionary in the next release.
90
-
91
- [ (#1170 )] ( https://github.com/PennyLaneAI/catalyst/pull/1170 )
92
- [ (#1310 )] ( https://github.com/PennyLaneAI/catalyst/pull/1310 )
145
+ Correspondingly, the device C++ interface should no longer parse the `DeviceInitOp` ' s attributes
146
+ dictionary for the shots. For now, we still keep the shots as an attribute so device implementors
147
+ can have time to migrate, but we will remove shots from the attribute dictionary in the next
148
+ release (`v0.11` )
93
149
94
150
* The `toml` module has been migrated to PennyLane with an updated schema for declaring device
95
151
capabilities. Devices with TOML files using `schema = 2 ` will not be compatible with the latest
96
- Catalyst. See [ Custom Devices] ( https://docs.pennylane.ai/projects/catalyst/en/stable/dev/custom_devices.html )
97
- for updated instructions on integrating your device with Catalyst and PennyLane
152
+ Catalyst. See the [Custom Devices documentation page ](https:// docs.pennylane.ai/ projects/ catalyst/ en/ stable/ dev/ custom_devices.html)
153
+ for updated instructions on integrating your device with Catalyst and PennyLane.
98
154
[(# 1275)](https://github.com/PennyLaneAI/catalyst/pull/1275)
99
155
100
156
* Handling for the legacy operator arithmetic (the `Hamiltonian` and `Tensor` classes in PennyLane)
101
- is removed.
157
+ has been removed.
102
158
[(# 1308)](https://github.com/PennyLaneAI/catalyst/pull/1308)
103
159
104
160
< h3> Bug fixes 🐛< / h3>
105
161
106
- * Fix bug introduced in 0.8 that breaks nested invocations of ` qml.adjoint ` and ` qml.ctrl ` .
162
+ * Fixed a bug introduced in 0.8 that breaks nested invocations of `qml.adjoint` and `qml.ctrl` (e.g.,
163
+ `qml.adjoint(qml.adjoint(qml.H(0 )))` ).
107
164
[(# 1301)](https://github.com/PennyLaneAI/catalyst/issues/1301)
108
165
109
- * Fix a bug in ` debug.compile_executable ` which would generate incorrect stride information for
166
+ * Fixed a bug in :func: ` ~ . debug.compile_executable` that would generate incorrect stride information for
110
167
array arguments of the function, in particular when non- 64bit datatypes are used.
111
168
[(# 1338)](https://github.com/PennyLaneAI/catalyst/pull/1338)
112
169
113
- <h3 >Deprecations 👋</h3 >
114
-
115
170
< h3> Internal changes ⚙️< / h3>
116
171
117
- * Catalyst no longer depends on or pins the ` scipy ` package, instead OpenBLAS is sourced directly
118
- from [ ` scipy-openblas32 ` ] ( https://pypi.org/project/scipy-openblas32/ ) or Accelerate is used.
172
+ * Catalyst no longer depends on or pins the `scipy` package. Instead, OpenBLAS is sourced directly
173
+ from [`scipy- openblas32` ](https:// pypi.org/ project/ scipy- openblas32/ ) or
174
+ [Accelerate](https:// developer.apple.com/ accelerate/ ) is used.
119
175
[(# 1322)](https://github.com/PennyLaneAI/catalyst/pull/1322)
120
176
[(# 1328)](https://github.com/PennyLaneAI/catalyst/pull/1328)
121
177
122
- * The ` QuantumExtension ` module ( previously implemented with pybind11) has been removed. This module
178
+ * The `QuantumExtension` module— previously implemented with pybind11— has been removed. This module
123
179
was not included in the distributed wheels and has been deprecated to align with our adoption of
124
180
Python' s stable ABI, which pybind11 does not support.
125
181
[(# 1187)](https://github.com/PennyLaneAI/catalyst/pull/1187)
126
182
127
- * Remove Lightning Qubit Dynamic plugin from Catalyst.
183
+ * Code for using `lightning.qubit` with Catalyst has been moved from the Catalyst repository to
184
+ the [Lightning repository](https:// github.com/ PennyLaneAI/ pennylane- lightning) so that Catalyst
185
+ wheels will build faster.
128
186
[(# 1227)](https://github.com/PennyLaneAI/catalyst/pull/1227)
129
187
[(# 1307)](https://github.com/PennyLaneAI/catalyst/pull/1307)
130
188
[(# 1312)](https://github.com/PennyLaneAI/catalyst/pull/1312)
131
189
132
- * ` catalyst-cli ` and ` quantum-opt ` are compiled with ` default ` visibility, which allows for MLIR plugins to work.
190
+ * `catalyst- cli` and `quantum- opt` are now compiled with `default` visibility, which allows for MLIR
191
+ plugins to work.
133
192
[(# 1287)](https://github.com/PennyLaneAI/catalyst/pull/1287)
134
193
135
- * Sink patching of autograph's allowlist.
194
+ * The patching mechanism of autograph' s `allowlist` has been streamlined to only be used in places
195
+ where it' s required.
136
196
[(# 1332)](https://github.com/PennyLaneAI/catalyst/pull/1332)
137
197
[(# 1337)](https://github.com/PennyLaneAI/catalyst/pull/1337)
138
198
139
- * Each qnode now has its own transformation schedule.
140
- Instead of relying on the name of the qnode, each qnode now has a transformation module,
141
- which denotes the transformation schedule, embedded in its MLIR representation.
199
+ * Each qnode now has its own transformation schedule. Instead of relying on the name of the qnode,
200
+ each qnode now has a transformation module, which denotes the transformation schedule, embedded in
201
+ its MLIR representation.
142
202
[(# 1323)](https://github.com/PennyLaneAI/catalyst/pull/1323)
143
203
144
- * The ` apply_registered_pass_p ` primitive is removed. The API for scheduling passes
145
- to run using the transform dialect has been refactored. In particular,
146
- passes are appended to a tuple as they are being registered and they will
147
- be run in order. If there are no local passes, the global ` pass_pipeline ` is
148
- scheduled. Furthermore, this commit also reworks the caching mechanism for
149
- primitives, which is important as qnodes and functions are primitives and
150
- now that we can apply passes to them, they are distinct based on which
151
- passes have been scheduled to run on them.
204
+ * The `apply_registered_pass_p` primitive has been removed and the API for scheduling passes to run
205
+ using the transform dialect has been refactored. In particular, passes are appended to a tuple as
206
+ they are being registered and they will be run in order. If there are no local passes, the global
207
+ `pass_pipeline` is scheduled. Furthermore, this commit also reworks the caching mechanism for
208
+ primitives, which is important as qnodes and functions are primitives and now that we can apply
209
+ passes to them, they are distinct based on which passes have been scheduled to run on them.
152
210
[(# 1317)](https://github.com/PennyLaneAI/catalyst/pull/1317)
153
211
154
- * Replace Python C-API calls with Stable ABI calls.
212
+ * Python C- API calls have been replaced with Stable ABI calls.
155
213
[(# 1354)](https://github.com/PennyLaneAI/catalyst/pull/1354)
156
214
157
215
* A framework for loading and interacting with databases containing hardware information and
176
234
Support for OQD devices is still under development, therefore the OQD modules are currently not
177
235
included in the distributed wheels.
178
236
179
- * ` expval ` and ` var ` operations no longer keep the static shots attribute, as a step towards supporting dynamic shots across catalyst.
237
+ * As a step towards supporting dynamic shots across catalyst, `expval` and `var` operations no
238
+ longer keep the static shots attribute.
180
239
[(# 1360)](https://github.com/PennyLaneAI/catalyst/pull/1360)
181
240
182
241
* A new `ion` dialect has been added for Catalyst programs targeting OQD trapped- ion quantum devices.
189
248
190
249
A new pass , `-- quantum- to- ion` , has also been added to convert logical gate- based circuits in the
191
250
Catalyst `quantum` dialect to laser pulse operations in the `ion` dialect. This pass accepts
192
- logical quantum gates from the set {RX, RY, Mølmer–Sørensen (MS)}. Doing so enables the insertion
193
- of physical device parameters into the IR, which will be necessary when lowering to OQD's backend
194
- calls. The physical parameters are read in from [ TOML] ( https://toml.io/en/ ) files during the
195
- ` --quantum-to-ion ` conversion. The TOML files are assumed to exist by the pass (the paths to the
196
- TOML file locations are taken in as pass options), with the intention that they are generated
197
- immediately before compilation during hardware-calibration runs.
198
-
199
- * IR is now extended to support literal values as opposed to SSA Values for static parameters of
200
- quantum gates by adding a new gate called StaticCustomOp with lowering to regular customOp.
251
+ logical quantum gates from the set `{RX , RY , MS }` , where `MS ` is the Mølmer–Sørensen gate. Doing
252
+ so enables the insertion of physical device parameters into the IR , which will be necessary when
253
+ lowering to OQD ' s backend calls. The physical parameters are read in from
254
+ [TOML ](https:// toml.io/ en/ ) files during the `-- quantum- to- ion` conversion. The TOML files are
255
+ assumed to exist by the pass (the paths to the TOML file locations are taken in as pass options),
256
+ with the intention that they are generated immediately before compilation during
257
+ hardware- calibration runs.
258
+
259
+ * The Catalyst IR has been extended to support literal values as opposed to SSA Values for static
260
+ parameters of quantum gates by adding a new gate called `StaticCustomOp` with lowering to regular
261
+ `CustomOp` .
201
262
[(# 1387)](https://github.com/PennyLaneAI/catalyst/pull/1387)
202
263
203
264
< h3> Documentation 📝< / h3>
204
265
205
266
* A new tutorial going through how to write a new MLIR pass is available. The tutorial writes an
206
- empty pass that prints hello world. The code of the tutorial is at
267
+ empty pass that prints ` hello world` . The code for the tutorial is located in
207
268
[a separate github branch](https:// github.com/ PennyLaneAI/ catalyst/ commit/ ba7b3438667963b307c07440acd6d7082f1960f3).
208
269
[(# 872)](https://github.com/PennyLaneAI/catalyst/pull/872)
209
270
210
- * Updated catalyst-cli documentation to reflect the removal of func-name option for trasnformation passes.
271
+ * The `catalyst- cli` documentation has been updated to reflect the removal of the `func- name` option
272
+ for transformation passes.
211
273
[(# 1368)](https://github.com/PennyLaneAI/catalyst/pull/1368)
212
274
213
275
< h3> Contributors ✍️< / h3>
@@ -219,7 +281,7 @@ Joey Carter,
219
281
David Ittah,
220
282
Erick Ochoa Lopez,
221
283
Mehrdad Malekmohammadi,
222
- William Maxwell
284
+ William Maxwell,
223
285
Romain Moyard,
224
286
Shuli Shu,
225
287
Ritu Thombre,
0 commit comments