PennyLane
  • Why PennyLane
  • Getting Started
  • Documentation
  • Ecosystem
Install
Install
  1. Blog/
  2. Releases/
  3. PennyLane v0.40 and Catalyst v0.10 released

January 14, 2025

PennyLane v0.40 and Catalyst v0.10 released

Isaac De Vlugt

Isaac De Vlugt

Josh Izaac

Josh Izaac

Diego Guala

Diego Guala

Anton Naim Ibrahim

Anton Naim Ibrahim

PennyLane v0.40 and Catalyst v0.10 released

Forty-fy your quantum programming with PennyLane v0.40 and Catalyst v0.10 🏰🀠!

Contents

  • Efficient state preparation methods 🦾
  • Better QSVT functionality 🀩
  • Vibrational Hamiltonians βš›οΈ
  • PennyLane Labs πŸ§‘β€πŸ”¬
  • Create custom compiler plugins with qjit πŸ”Œ
  • Improvements πŸ› οΈ
  • Deprecations and breaking changes πŸ’”
  • Contributors ✍️

Efficient state preparation methods 🦾

Prepare yourselves for this feature πŸš€! PennyLane v0.40 includes fast and efficient state preparation techniques for matrix product states (MPS) and superpositions of basis states.

Efficient state preparation methods

State preparation tailored for matrix product states (MPS) is now supported with the qml.MPSPrep operator on the lightning.tensor device. Quantum states represented as an MPS offer a compact, performant, and insightful platform to perform simulations with. With qml.MPSPrep, an MPS can be directly injected into a quantum circuit without any complicated preprocessing, giving you seamless access to the fast and efficient world of matrix product states in PennyLane. Here's how to use it:

Given a list of n tensors that represents an MPS, [A^{(0)}, ..., A^{(n-1)}], qml.MPSPrep lets you insert the MPS into a QNode as the initial state of the circuit. The first and last tensors in the list must be rank-2, while all intermediate tensors should be rank-3.

import pennylane as qml import numpy as np mps = [ np.array([[0.0, 0.107], [0.994, 0.0]]), np.array([[[0.0, 0.0, 0.0, -0.0], [1.0, 0.0, 0.0, -0.0]], [[0.0, 1.0, 0.0, -0.0], [0.0, 0.0, 0.0, -0.0]]]), np.array([[[-1.0, 0.0], [0.0, 0.0]], [[0.0, 0.0], [0.0, 1.0]], [[0.0, -1.0], [0.0, 0.0]], [[0.0, 0.0], [1.0, 0.0]]]), -np.identity(2), ] dev = qml.device("lightning.tensor", wires = 3) @qml.qnode(dev) def circuit(): qml.MPSPrep(mps, wires = [0, 1, 2]) return qml.state()
>>> print(circuit()) [ 0. +0.j 0. +0.j 0. +0.j -0.1066+0.j 0. +0.j 0. +0.j 0. +0.j 0. +0.j 0. +0.j 0. +0.j 0. +0.j 0. +0.j 0.9943+0.j 0. +0.j 0. +0.j 0. +0.j]

At this time, qml.MPSPrep is only supported on the lightning.tensor device.

Additionally, custom-made state preparation for linear combinations of quantum states is now available with the qml.Superposition operator, which can take a list of basis state coefficients and basis states as binary, lexicographic-order arrays.

Better QSVT functionality 🀩

QSVT in PennyLane has never been better πŸ’ͺ. With this release, we've made several additions and improvements to the way you can do QSVT and quantum signal processing (QSP) in PennyLane, including new functions for dealing with phase angles, new operators, and more.

Better QSVT functionality

  • Calculating and converting phase angles for use in QSP or QSVT can now be done with qml.poly_to_angles and qml.transform_angles. The qml.poly_to_angles function calculates phase angles directly given polynomial coefficients and the routine in which the angles will be used ("QSVT", "QSP", or "GQSP"β€”see the next bullet point πŸ‘€), while the qml.transform_angles function suitably converts phase angles for use in either algorithm.

    >>> poly = [0, 1.0, 0, -1/2, 0, 1/3] >>> qsvt_angles = qml.poly_to_angles(poly, "QSVT") >>> print(qsvt_angles) [-5.49778714 1.57079633 1.57079633 0.5833829 1.61095884 0.74753829] >>> qsp_angles = qml.transform_angles(qsvt_angles, "QSVT", "QSP") >>> print(qsp_angles) [ 0. 0. 0. -0.98741343 0.04016252 1.53293645]
  • A new qml.GQSP operator has been added to perform Generalized Quantum Signal Processing (GQSP). Similar to QSVT, GQSP is an algorithm that polynomially transforms an input unitary operator, but with fewer restrictions on the chosen polynomial.

    # P(x) = 0.1 + 0.2j x + 0.3 x^2 poly = [0.1, 0.2j, 0.3] angles = qml.poly_to_angles(poly, "GQSP") @qml.prod # transforms the qfunc into an Operator def unitary(wires): qml.RX(0.3, wires) qml.RY(0.2, wires) dev = qml.device("default.qubit") @qml.qnode(dev) def circuit(angles): qml.GQSP(unitary(wires = 1), angles, control = 0) return qml.state() matrix = qml.matrix(circuit, wire_order=[0, 1])(angles)
    >>> print(np.round(matrix,3)[:2, :2]) [[ 0.378+0.206j -0.029-0.108j] [ 0.088-0.068j 0.384+0.188j]]
  • The qml.qsvt function has been improved to be more user-friendly; block encoding and phase angle computation are now handled automatically when given a matrix to encode, polynomial coefficients, and a block encoding method ("prepselprep", "qubitization", "embedding", or "fable").

To see some of these features in action, check out our assortment of demonstrations on QSVT!

Vibrational Hamiltonians βš›οΈ

This feature will leave you shaking πŸ™€! We've now got support for vibrational Hamiltonians and bosonic operators.

Vibrational Hamiltonians

Be it understanding chemical bonds or identifying atmospheric contents in distant planets via molecular spectra, modelling the vibrations of molecules is an incredibly useful tool that has yet to experience much love from existing quantum programming tools.

  • With this release, several new features are available in the qml.qchem module to help with the construction of vibrational Hamiltonians, including the qml.qchem.VibrationalPES class for storing potential energy surface information:

    pes_onemode = np.array([[0.309, 0.115, 0.038, 0.008, 0.000, 0.006, 0.020, 0.041, 0.070]]) pes_twomode = np.zeros((1, 1, 9, 9)) dipole_onemode = np.zeros((1, 9, 3)) gauss_weights = np.array([3.96e-05, 4.94e-03, 8.85e-02, 4.33e-01, 7.20e-01, 4.33e-01, 8.85e-02, 4.94e-03, 3.96e-05]) grid = np.array([-3.19, -2.27, -1.47, -0.72, 0.0, 0.72, 1.47, 2.27, 3.19]) pes_object = qml.qchem.VibrationalPES( freqs=np.array([0.025]), grid=grid, uloc=np.array([[1.0]]), gauss_weights=gauss_weights, pes_data=[pes_onemode, pes_twomode], dipole_data=[dipole_onemode], localized=False, dipole_level=1, )

    From this object, the new qml.qchem.taylor_hamiltonian function can be used to build a Taylor Hamiltonian:

    >>> qml.qchem.taylor_hamiltonian(pes_object, 4, 2) ( 0.016867926879358452 * I(0) + -0.007078617919572303 * Z(0) + 0.0008679410939323631 * X(0) )

    For a comprehensive list of vibrational Hamiltonian features in qml.qchem, check out the full release notes!

  • A new module called qml.bose is available, which includes bosonic operators called qml.BoseWord and qml.BoseSentence that are analogous to qml.FermiWord and qml.FermiSentence in the qml.fermi module.

    >>> w1 = qml.BoseWord({(0, 0) : '+', (1, 1) : '-'}) >>> w2 = qml.BoseWord({(0, 1) : '+', (1, 2) : '-'}) >>> s = qml.BoseSentence({w1 : 1.2, w2: 3.1}) >>> print(s) 1.2 * b⁺(0) b(1) + 3.1 * b⁺(1) b(2)

    Additionally, the new qml.qchem.taylor_bosonic function allows for building a Taylor Hamiltonian in terms of Bosonic operators. Here is an example that uses the VibrationalPES object created in the previous bullet point:

    >>> coeffs_arr = qml.qchem.taylor_coeffs(pes_object) >>> bose_op = qml.qchem.taylor_bosonic(coeffs_arr, pes_object.freqs, is_local=pes_object.localized, uloc=pes_object.uloc) >>> type(bose_op) pennylane.bose.bosonic.BoseSentence

PennyLane Labs πŸ§‘β€πŸ”¬

The place for highly-valued, experimental research software βš—οΈ

PennyLane Labs

PennyLane v0.40 marks the official introduction of the qml.labs module. Labs is our unified area to host research software that we can rapidly prototype to provide researchers access to bleeding-edge quantum computing tools πŸ§ͺ.

This module is experimental, meaning that features may not integrate well with other PennyLane staples like differentiability, JAX, or JIT compatibility. There may also be unexpected sharp bits πŸ”ͺ and errors ❌. Breaking changes and removals can also happen without warning.

With this release, the qml.labs.resource_estimation module has been added to provide alternative functions that reduce the memory requirements and computational time of existing functions and objects in qml.resource, and new features for obtaining resource estimates, in general. This includes the following.

  • The qml.labs.resource_estimation.get_resources function offers a new entry point to efficiently obtain the resources of quantum circuits in terms of a specific target gate set.
  • Versions of many existing PennyLane operations now have a "resource" analogue to facilitate resource estimation, including qml.labs.resource_estimation.ResourceX, ResourceY, ResourceZ, ResourceHadamard, ResourceCNOT, ResourceQFT, and more.
  • The qml.labs.resource_estimation.ResourceOperator class expands qml.resource.ResourceOperation to allow for calculating resource estimates for a given decomposition. This lets the user provide their own decomposition for Resource{X, Y, Z, ...} and calculate resources based on that decomposition.

Here is an example of some of these features being used for resource estimates.

import pennylane.labs.resource_estimation as re def my_circuit(): for w in range(2): re.ResourceHadamard(w) re.ResourceCNOT([0, 1]) re.ResourceRX(1.23, 0) re.ResourceRY(-4.56, 1) re.ResourceQFT(wires=[0, 1, 2]) return qml.expval(re.ResourceHadamard(2))
>>> res = re.get_resources(my_circuit)() >>> print(res) wires: 3 gates: 202 gate_types: {'Hadamard': 5, 'CNOT': 10, 'T': 187}

For a full overview of qml.labs features included in this release, check out the full release notes.

Create custom compiler plugins with qjit πŸ”Œ

Pass this one to your compiler πŸ€πŸ’¨. Catalyst v0.10 includes support for loading and applying local MLIR plugins from the frontend.

Compiler plugins

Features and improvements for dynamic circuits with structure are going to be a big part of what we do going forward. On the Catalyst side, this involves work at the level of our compilation pipeline (written in MLIR). With this feature, we want to make it easier for the community to get involved in our compilation pipeline without needing to add to Catalyst directly.

Additional details on creating your own plugin can be found in our compiler plugin documentation. If you are interested in exploring MLIR and/or want to add support for your own compilation passes to Catalyst, give these features a try or get in touch with us!

Improvements πŸ› οΈ

  • Find the lowest energy configuration of molecules with the new qml.qchem.optimize_geometry function.

    >>> symbols = ['H', 'F'] >>> geometry = np.array([[0.0, 0.0, 0.0], [0.0, 0.0, 1.0]]) >>> mol = qml.qchem.Molecule(symbols, geometry) >>> eq_geom = qml.qchem.optimize_geometry(mol) >>> eq_geom array([[ 0. , 0. , -0.40277116], [ 0. , 0. , 1.40277116]])
  • qml.draw_mpl now has a wire_options keyword argument, which allows for global- and per-wire customization with options like color, linestyle, and linewidth. Here is an example that makes all wires cyan and bold except for wires 0 and 2, which are dashed and a different colour.

    @qml.qnode(qml.device("default.qubit")) def circuit(): for w in range(3): qml.Hadamard(w) return qml.expval(qml.PauliZ(0) @ qml.PauliY(1)) wire_options = {"color": "cyan", "linewidth": 5, 0: {"linestyle": "--", "color": "orange"}, 2: {"linestyle": "--", "color": "red"} } print(qml.draw_mpl(circuit, wire_options=wire_options)())

Improvement to qml.draw_mpl

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:

  • The PennyLane-Rigetti plugin is only compatible with PennyLane v0.40 or below. To use Rigetti hardware with newer versions of PennyLane please use the PennyLane-Braket plugin instead.

  • The old qml.qsvt functionality can be accessed with qml.qsvt_legacy.

  • The tape and qtape properties of QNode have been deprecated. Instead, use the
    qml.workflow.construct_tape function.

  • Legacy operator arithmetic has been removed. This includes qml.ops.Hamiltonian, qml.operation.Tensor, and more. Note that qml.Hamiltonian will continue to dispatch to qml.ops.LinearCombination. For more information, check out the updated operator troubleshooting page.


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, Shiwen An, Ali Asadi, Utkarsh Azad, Astral Cai, Joey Carter, Yushao Chen, Isaac De Vlugt, Diksha Dhawan, Lasse Dierich, Amintor Dusko, Tarik El-Khateeb, Lillian Frederiksen, Pietropaolo Frisoni, Simone Gasperini, Diego Guala, Austin Huang, David Ittah, Josh Izaac, Soran Jahangiri, Korbinian Kottmann, Christina Lee, Joseph Lee, Erick Ochoa Lopez, Mehrdad Malekmohammadi, Alan Martin, William Maxwell, Anton Naim Ibrahim, Luis Alfredo NuΓ±ez Meneses, Romain Moyard, Lee J. O'Riordan, Mudit Pandey, Andrija Paurevic, Justin Pickering, Jay Soni, Shuli Shu, Ritu Thombre, Raul Torres, Haochen Paul Wang, David Wierichs.

About the authors

Isaac De Vlugt
Isaac De Vlugt

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 Izaac

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 Guala

Diego Guala

Diego is a quantum scientist at Xanadu. His work is focused on supporting the development of the datasets service and PennyLane features.

Anton Naim Ibrahim
Anton Naim Ibrahim

Anton Naim Ibrahim

Exploring uncharted territory.

Last modified:Β January 15, 2025

Related Blog Posts

PennyLane

PennyLane is an open-source software framework for quantum machine learning, quantum chemistry, and quantum computing, with the ability to run on all hardware. Built with ❀️ by Xanadu.

Stay updated with our newsletter

For researchers

  • Research
  • Features
  • Demos
  • Compilation
  • Datasets
  • Performance
  • Learn
  • Videos
  • Documentation
  • Teach

For learners

  • Learn
  • Codebook
  • Teach
  • Videos
  • Challenges
  • Demos
  • Compilation
  • Glossary

For developers

  • Features
  • Documentation
  • API
  • GitHub
  • Datasets
  • Demos
  • Compilation
  • Performance
  • Devices
  • Catalyst

Β© Copyright 2025 | Xanadu | All rights reserved

TensorFlow, the TensorFlow logo and any related marks are trademarks of Google Inc.

Privacy Policy|Terms of Service|Cookie Policy|Code of Conduct