November 05, 2024
PennyLane v0.39 and Catalyst v0.9 released
Fall in love with PennyLane v0.39 and Catalyst v0.9 ππ!
Contents
- Spin Hamiltonians π
- The Lightning-tensor device β‘οΈ
- Lightning-GPU is qjit-compatible π¦Ύ
- Catalyst peephole compilation passes π
- Improvements π οΈ
- Deprecations and breaking changes π
- Contributors βοΈ
Spin Hamiltonians π
Quantum computing + spin Hamiltonians = easy as pie π₯§
Custom Hamiltonians beyond the available boiler-plate ones in the
qml.spin
module can be created with the
addition of three new functions:
qml.spin.Lattice
: a new object for instantiating customized lattices via primitive translation vectors and unit cell parameters,qml.spin.generate_lattice
: a utility function for creating standardLattice
objects, including'chain'
,'square'
,'rectangle'
,'triangle'
,'honeycomb'
,'kagome'
,'lieb'
,'cubic'
,'bcc'
,'fcc'
, and'diamond'
,qml.spin.spin_hamiltonian
: generates a spinHamiltonian
object given aLattice
object with custom edges/nodes.
For example, consider a 3 \times 3 triangular lattice with open boundary conditions:
lattice = qml.spin.Lattice( n_cells=[3, 3], vectors=[[1, 0], [np.cos(np.pi/3), np.sin(np.pi/3)]], positions=[[0, 0]], boundary_condition=False )
We can validate this lattice
against qml.spin.generate_lattice('triangle', ...)
by checking the
lattice_points
(the (x, y) coordinates of all sites in the lattice):
>>> lp = lattice.lattice_points >>> triangular_lattice = qml.spin.generate_lattice('triangle', n_cells=[3, 3]) >>> np.allclose(lp, triangular_lattice.lattice_points) True
The edges
of the Lattice
object are nearest-neighbour by default, where we can add edges by using
its add_edge
method.
Additionally, three new industry-standard spin Hamiltonians are now available with PennyLane v0.39:
qml.spin.emery
: the Emery modelqml.spin.haldane
: the Haldane modelqml.spin.kitaev
: the Kitaev model
These additions accompany qml.spin.heisenberg
, qml.spin.transverse_ising
, and qml.spin.fermi_hubbard
,
which were introduced in v0.38.
Stay tuned for a how-to demonstration on these new features in the days after the release!
The Lightning-tensor device β‘οΈ
A powerhouse simulator ready for hefty computations π¦Ύ
PennyLane v0.37
saw the addition of default.tensor
, which is our simple simulator device meant for performing
tensor network (TN) and matrix product state (MPS) simulations of wide quantum circuits.
With PennyLane v0.39, we've brought MPS-backend simulations to lightning, our performance suite of simulator
devices π, allowing you to perform simulations of circuits with hundreds of qubits π±!
The lightning.tensor
device is built on top of cuTensorNet,
enabling GPU-accelerated simulation of quantum tensor network evolution. Lightning-tensor can be used like any other
device in PennyLane:
dev = qml.device("lightning.tensor", wires=100, method="mps", max_bond_dim=64, cutoff=1e-10)
For a full list of features, consult the Lightning-tensor device documentation. To get started, install Lightning-tensor with
pip install cutensornet-cu12 pip install pennylane-lightning[tensor]
or check out the Lightning-tensor installation guide
Lightning-GPU is qjit-compatible π¦Ύ
Bring the power of qjit to lightning.gpu
π€©
Lightning-GPU is the latest device to now work with Catalyst, joining a
growing list of simulators
and hardware devices! Simply create the device with qml.device("lightning.gpu", wires=n_wires)
and
you're off to the races.
@qml.qjit @qml.qnode(qml.device("lightning.gpu", wires=2)) def circuit(theta): qml.Hadamard(wires=0) qml.RX(theta, wires=1) qml.CNOT(wires=[0,1]) return qml.expval(qml.PauliZ(wires=1))
>>> circuit(0.7) Array(0., dtype=float64)
To get started, make sure to install Lightning-GPU and visit the Lightning-GPU documentation for usage details.
Catalyst peephole compilation passes π
Peep this new Catalyst feature π
A "peephole optimization" involves replacing parts of compiler instructions with logically equivalent ones that have better performance. In this instance, a merge-rotations pass (which acts similarly to PennyLane's merge rotations transform), is now available at the MLIR level and can be applied to QNodes within a qjit-compiled function.
The merge_rotations
pass
can be provided to the catalyst.pipeline
decorator:
from catalyst import pipeline, qjit my_passes = { "merge_rotations": {} } dev = qml.device("lightning.qubit", wires=1) @qjit @pipeline(my_passes) @qml.qnode(dev) def g(x: float): qml.RX(x, wires=0) qml.RX(x, wires=0) qml.Hadamard(wires=0) return qml.expval(qml.PauliX(0))
Improvements π οΈ
In addition to the new features listed above, this release contains a wide array of improvements and optimizations:
-
A new transform called
qml.transforms.decompose
has been added to better facilitate the custom decomposition of operators in PennyLane circuits.from functools import partial dev = qml.device('default.qubit') allowed_gates = {qml.Toffoli, qml.RX, qml.RZ} @partial(qml.transforms.decompose, gate_set=allowed_gates) @qml.qnode(dev) def circuit(): qml.Hadamard(wires=[0]) qml.Toffoli(wires=[0, 1, 2]) return qml.expval(qml.Z(0))
>>> print(qml.draw(circuit)()) 0: ββRZ(1.57)ββRX(1.57)ββRZ(1.57)βββββ€ <Z> 1: βββββββββββββββββββββββββββββββββββ€ 2: ββββββββββββββββββββββββββββββββ°Xββ€
For more details, visit the documentation for
qml.transforms.decompose
. -
Readout/measurement errors can now be included in
qml.NoiseModel
andqml.add_noise
with the newqml.noise.meas_eq
function. Readout errors can be specified in a similar fashion to regular gate noise in PennyLane: useqml.noise.meas_eq
to specify a measurement function (e.g.,qml.expval
,qml.sample
, or any other function that can be returned from a QNode) such that, when present in the QNode, a noisy operation is inserted. Readout noise in PennyLane also follows the insertion convention, where the specified noise is inserted before the measurement. -
Polynomial functions can now be easily encoded into quantum circuits with
qml.OutPoly
. -
PennyLane is now compatible with
numpy==2.0
andjax==0.4.28
.
Deprecations and breaking changes π
As new things are added, outdated features are removed. To keep track of things in the deprecation pipeline, check out the deprecations page.
Here's a summary of what has changed in this release:
-
Python 3.9 is no longer supported. Please update to 3.10 or newer.
-
The
qml.qinfo
module has been deprecated. Please see the respective functions in theqml.math
andqml.measurements
modules instead. -
default.qubit.tf
,default.qubit.torch
,default.qubit.jax
, anddefault.qubit.autograd
have been removed. Please usedefault.qubit
for all interfaces.
These highlights are just scratching the surface β check out the full release notes for PennyLane and Catalyst for more details.
Contributors βοΈ
As always, this release would not have been possible without the hard work of our development team and contributors:
Guillermo Alonso, Ali Asadi, Utkarsh Azad, Oleksandr Borysenko, Astral Cai, Joey Carter, Yushao Chen, Spencer Comin, Isaac De Vlugt, Diksha Dhawan, Amintor Dusko, Tarik El-Khateeb, Lillian M. A. Frederiksen, Pietropaolo Frisoni, Emiliano Godinez, Diego Guala, Anthony Hayes, Sengthai Heng, Austin Huang, Ivana KureΔiΔ, Anton Naim Ibrahim, David Ittah, Josh Izaac, Soran Jahangiri, Jacob Kitchen, Korbinian Kottmann, Christina Lee, Mehrdad Malekmohammadi, William Maxwell, Luis Alfredo NuΓ±ez Meneses, Vincent Michaud-Rioux, Romain Moyard, Erick Ochoa Lopez, Lee J. O'Riordan, Mudit Pandey, Andrija Paurevic, Alex Preciado, Shuli Shu, Ashish Kanwar Singh, Daniel Strano, Raul Torres, Paul Haochen Wang, David Wierichs
About the authors
Isaac De Vlugt
My job is to help manage the PennyLane and Catalyst feature roadmap... and spam lots of emojis in the chat π€
Josh Izaac
Josh is a theoretical physicist, software tinkerer, and occasional baker. At Xanadu, he contributes to the development and growth of Xanaduβs open-source quantum software products.
Diego Guala
Diego is a quantum scientist at Xanadu. His work is focused on supporting the development of the datasets service and PennyLane features.