diff --git a/demonstrations_v2/tutorial_How_to_optimize_QML_model_using_JAX_and_JAXopt/demo.py b/demonstrations_v2/tutorial_How_to_optimize_QML_model_using_JAX_and_JAXopt/demo.py index 608ac0fba4..29ea00b064 100644 --- a/demonstrations_v2/tutorial_How_to_optimize_QML_model_using_JAX_and_JAXopt/demo.py +++ b/demonstrations_v2/tutorial_How_to_optimize_QML_model_using_JAX_and_JAXopt/demo.py @@ -36,6 +36,7 @@ import jaxopt jax.config.update("jax_platform_name", "cpu") +jax.config.update("jax_enable_x64", True) n_wires = 5 data = jnp.sin(jnp.mgrid[-2:2:0.2].reshape(n_wires, -1)) ** 3 diff --git a/demonstrations_v2/tutorial_How_to_optimize_QML_model_using_JAX_and_JAXopt/metadata.json b/demonstrations_v2/tutorial_How_to_optimize_QML_model_using_JAX_and_JAXopt/metadata.json index cc61f72d6b..42f7190035 100644 --- a/demonstrations_v2/tutorial_How_to_optimize_QML_model_using_JAX_and_JAXopt/metadata.json +++ b/demonstrations_v2/tutorial_How_to_optimize_QML_model_using_JAX_and_JAXopt/metadata.json @@ -11,7 +11,7 @@ "executable_stable": true, "executable_latest": true, "dateOfPublication": "2024-01-18T00:00:00+00:00", - "dateOfLastModification": "2026-04-14T15:48:14+00:00", + "dateOfLastModification": "2026-05-05T00:00:00+00:00", "categories": [ "Quantum Machine Learning", "Optimization", diff --git a/demonstrations_v2/tutorial_How_to_optimize_QML_model_using_JAX_and_Optax/demo.py b/demonstrations_v2/tutorial_How_to_optimize_QML_model_using_JAX_and_Optax/demo.py index d15b8d4974..9f9db6ef7a 100644 --- a/demonstrations_v2/tutorial_How_to_optimize_QML_model_using_JAX_and_Optax/demo.py +++ b/demonstrations_v2/tutorial_How_to_optimize_QML_model_using_JAX_and_Optax/demo.py @@ -36,6 +36,8 @@ from jax import numpy as jnp import optax +jax.config.update("jax_enable_x64", True) + n_wires = 5 data = jnp.sin(jnp.mgrid[-2:2:0.2].reshape(n_wires, -1)) ** 3 targets = jnp.array([-0.2, 0.4, 0.35, 0.2]) diff --git a/demonstrations_v2/tutorial_How_to_optimize_QML_model_using_JAX_and_Optax/metadata.json b/demonstrations_v2/tutorial_How_to_optimize_QML_model_using_JAX_and_Optax/metadata.json index 0c361693ab..14465fb357 100644 --- a/demonstrations_v2/tutorial_How_to_optimize_QML_model_using_JAX_and_Optax/metadata.json +++ b/demonstrations_v2/tutorial_How_to_optimize_QML_model_using_JAX_and_Optax/metadata.json @@ -11,7 +11,7 @@ "executable_stable": true, "executable_latest": true, "dateOfPublication": "2024-01-18T00:00:00+00:00", - "dateOfLastModification": "2026-04-14T15:48:14+00:00", + "dateOfLastModification": "2026-05-05T00:00:00+00:00", "categories": [ "Quantum Machine Learning", "Optimization", diff --git a/demonstrations_v2/tutorial_contextuality/demo.py b/demonstrations_v2/tutorial_contextuality/demo.py index 33bf28dcd0..450a251d62 100644 --- a/demonstrations_v2/tutorial_contextuality/demo.py +++ b/demonstrations_v2/tutorial_contextuality/demo.py @@ -177,6 +177,7 @@ import pennylane as qp import numpy as np jax.config.update("jax_platform_name", "cpu") +jax.config.update("jax_enable_x64", True) np.random.seed(666) # seed used for random functions A01 = np.array([[1, -1, 1], [1, -1, -1], [-1, 1, 0]]) # rules for player 0 vs player 1 diff --git a/demonstrations_v2/tutorial_contextuality/metadata.json b/demonstrations_v2/tutorial_contextuality/metadata.json index 9271f7302a..b465710472 100644 --- a/demonstrations_v2/tutorial_contextuality/metadata.json +++ b/demonstrations_v2/tutorial_contextuality/metadata.json @@ -8,7 +8,7 @@ "executable_stable": true, "executable_latest": true, "dateOfPublication": "2023-09-06T00:00:00+00:00", - "dateOfLastModification": "2026-04-17T15:48:14+00:00", + "dateOfLastModification": "2026-05-05T00:00:00+00:00", "categories": [ "Quantum Machine Learning" ], diff --git a/demonstrations_v2/tutorial_eqnn_force_field/demo.py b/demonstrations_v2/tutorial_eqnn_force_field/demo.py index fa11e9e5b5..5b83ea0452 100644 --- a/demonstrations_v2/tutorial_eqnn_force_field/demo.py +++ b/demonstrations_v2/tutorial_eqnn_force_field/demo.py @@ -205,7 +205,7 @@ def equivariant_encoding(alpha, data, wires): hamiltonian = jnp.einsum("i,ijk", data, sigmas) # Heisenberg Hamiltonian U = jax.scipy.linalg.expm(-1.0j * alpha * hamiltonian / 2) - qp.QubitUnitary(U, wires=wires, id="E") + qp.fourier.mark(qp.QubitUnitary(U, wires=wires), "E") ###################################################################### @@ -260,7 +260,7 @@ def equivariant_encoding(alpha, data, wires): def trainable_layer(weight, wires): hamiltonian = jnp.einsum("ijk->jk", sigmas_sigmas) U = jax.scipy.linalg.expm(-1.0j * weight * hamiltonian) - qp.QubitUnitary(U, wires=wires, id="U") + qp.fourier.mark(qp.QubitUnitary(U, wires=wires), "U") # Invariant observable diff --git a/demonstrations_v2/tutorial_eqnn_force_field/metadata.json b/demonstrations_v2/tutorial_eqnn_force_field/metadata.json index bd870d81e5..3173849bd0 100644 --- a/demonstrations_v2/tutorial_eqnn_force_field/metadata.json +++ b/demonstrations_v2/tutorial_eqnn_force_field/metadata.json @@ -11,7 +11,7 @@ "executable_stable": true, "executable_latest": true, "dateOfPublication": "2024-03-12T00:00:00+00:00", - "dateOfLastModification": "2026-04-17T15:48:14+00:00", + "dateOfLastModification": "2026-04-22T15:48:14+00:00", "categories": [ "Quantum Machine Learning", "Quantum Chemistry" @@ -107,4 +107,4 @@ "weight": 1.0 } ] -} \ No newline at end of file +} diff --git a/demonstrations_v2/tutorial_general_parshift/demo.py b/demonstrations_v2/tutorial_general_parshift/demo.py index fe93c33c99..e8ecbb9974 100644 --- a/demonstrations_v2/tutorial_general_parshift/demo.py +++ b/demonstrations_v2/tutorial_general_parshift/demo.py @@ -141,7 +141,7 @@ def cost(x): """Cost function on N qubits with N frequencies.""" qp.StatePrep(random_state(N, seed), wires=dev.wires) for w in dev.wires: - qp.RZ(x, wires=w, id="x") + qp.fourier.mark(qp.RZ(x, wires=w), "x") return qp.expval(qp.Hermitian(random_observable(N, seed), wires=dev.wires)) return cost diff --git a/demonstrations_v2/tutorial_general_parshift/metadata.json b/demonstrations_v2/tutorial_general_parshift/metadata.json index ef4fa269a8..db88352fb6 100644 --- a/demonstrations_v2/tutorial_general_parshift/metadata.json +++ b/demonstrations_v2/tutorial_general_parshift/metadata.json @@ -8,7 +8,7 @@ "executable_stable": true, "executable_latest": true, "dateOfPublication": "2021-08-23T00:00:00+00:00", - "dateOfLastModification": "2026-04-17T15:48:14+00:00", + "dateOfLastModification": "2026-04-22T15:48:14+00:00", "categories": [ "Optimization" ], @@ -89,4 +89,4 @@ "weight": 1.0 } ] -} \ No newline at end of file +} diff --git a/demonstrations_v2/tutorial_how_to_build_compressed_double_factorized_hamiltonians/demo.py b/demonstrations_v2/tutorial_how_to_build_compressed_double_factorized_hamiltonians/demo.py index 94ffa369b2..c08295f3b7 100644 --- a/demonstrations_v2/tutorial_how_to_build_compressed_double_factorized_hamiltonians/demo.py +++ b/demonstrations_v2/tutorial_how_to_build_compressed_double_factorized_hamiltonians/demo.py @@ -31,6 +31,10 @@ """ import pennylane as qp +import numpy as np + +import warnings +warnings.filterwarnings(action="ignore", category=np.exceptions.ComplexWarning) symbols = ["H", "H", "H", "H"] geometry = qp.math.array([[0., 0., -0.2], [0., 0., -0.1], [0., 0., 0.1], [0., 0., 0.2]]) @@ -234,7 +238,8 @@ def leaf_unitary_rotation(leaf, wires): """Applies the basis rotation transformation corresponding to the leaf tensor.""" basis_mat = qp.math.kron(leaf, qp.math.eye(2)) # account for spin - return qp.BasisRotation(unitary_matrix=basis_mat, wires=wires) + qp.BasisRotation(unitary_matrix=basis_mat, wires=wires) + ###################################################################### # Similarly, the unitary transformation for the core tensors can be applied efficiently @@ -248,22 +253,20 @@ def leaf_unitary_rotation(leaf, wires): def core_unitary_rotation(core, body_type, wires): """Applies the unitary transformation corresponding to the core tensor.""" - ops = [] if body_type == "one_body": # implements one-body term for wire, cval in enumerate(qp.math.diag(core)): for sigma in [0, 1]: - ops.append(qp.RZ(-cval, wires=2 * wire + sigma)) - ops.append(qp.GlobalPhase(qp.math.sum(core), wires=wires)) + qp.RZ(-cval, wires=2 * wire + sigma) + qp.GlobalPhase(qp.math.sum(core), wires=wires) if body_type == "two_body": # implements two-body term for odx1, odx2 in it.product(range(len(wires) // 2), repeat=2): cval = core[odx1, odx2] / 4.0 for sigma, tau in it.product(range(2), repeat=2): if odx1 != odx2 or sigma != tau: - ops.append(qp.IsingZZ(cval, wires=[2*odx1+sigma, 2*odx2+tau])) + qp.IsingZZ(cval, wires=[2*odx1+sigma, 2*odx2+tau]) gphase = 0.5 * qp.math.sum(core) - 0.25 * qp.math.trace(core) - ops.append(qp.GlobalPhase(-gphase, wires=wires)) - return ops + qp.GlobalPhase(-gphase, wires=wires) ###################################################################### # We can now use these functions to approximate the evolution operator :math:`e^{-iHt}` for @@ -281,9 +284,20 @@ def core_unitary_rotation(core, body_type, wires): # step using the following :func:`CDFTrotterStep` function that uses the CDF Hamiltonian # with the ``leaf_unitary_rotation`` and ``core_unitary_rotation`` functions defined earlier. # We can then use the :func:`~.pennylane.trotterize` function to implement any higher-order -# Suzuki-Trotter products. +# Suzuki-Trotter products. It is crucial to wrap these steps in :func:`~.pennylane.prod`; this ensures +# the sequence of operators are preserved as a single block which prevents +# :func:`~.pennylane.trotterize` from re-ordering or reversing the internal terms. # +@qp.prod +def block(time, leaf, core, body_type, wires): + # apply the basis rotation for leaf tensor + leaf_unitary_rotation(leaf, wires) + # apply the rotation for core tensor scaled by the time-step + core_unitary_rotation(time * core, body_type, wires) + # revert the change-of-basis for leaf tensor + leaf_unitary_rotation(leaf.conjugate().T, wires) + def CDFTrotterStep(time, cdf_ham, wires): """Implements a first-order Trotter step for a CDF Hamiltonian. @@ -296,14 +310,7 @@ def CDFTrotterStep(time, cdf_ham, wires): for bidx, (core, leaf) in enumerate(zip(cores, leaves)): # Note: only the first term is one-body, others are two-body body_type = "two_body" if bidx else "one_body" - qp.prod( - # revert the change-of-basis for leaf tensor - leaf_unitary_rotation(leaf.conjugate().T, wires), - # apply the rotation for core tensor scaled by the time-step - *core_unitary_rotation(time * core, body_type, wires), - # apply the basis rotation for leaf tensor - leaf_unitary_rotation(leaf, wires), - ) # Note: prod applies operations in the reverse order (right-to-left). + block(time, leaf, core, body_type, wires) ###################################################################### # We now use this function to simulate the evolution of the :math:`H_4` Hamiltonian diff --git a/demonstrations_v2/tutorial_how_to_build_compressed_double_factorized_hamiltonians/metadata.json b/demonstrations_v2/tutorial_how_to_build_compressed_double_factorized_hamiltonians/metadata.json index bc0bf3763d..10e827d2e9 100644 --- a/demonstrations_v2/tutorial_how_to_build_compressed_double_factorized_hamiltonians/metadata.json +++ b/demonstrations_v2/tutorial_how_to_build_compressed_double_factorized_hamiltonians/metadata.json @@ -8,7 +8,7 @@ "executable_stable": true, "executable_latest": true, "dateOfPublication": "2025-03-05T09:00:00+00:00", - "dateOfLastModification": "2026-04-17T15:48:14+00:00", + "dateOfLastModification": "2026-05-05T00:00:00+00:00", "categories": [ "Quantum Chemistry", "Algorithms", diff --git a/demonstrations_v2/tutorial_how_to_quantum_just_in_time_compile_vqe_catalyst/demo.py b/demonstrations_v2/tutorial_how_to_quantum_just_in_time_compile_vqe_catalyst/demo.py index 1f9c9741d2..5b658b53f9 100644 --- a/demonstrations_v2/tutorial_how_to_quantum_just_in_time_compile_vqe_catalyst/demo.py +++ b/demonstrations_v2/tutorial_how_to_quantum_just_in_time_compile_vqe_catalyst/demo.py @@ -44,7 +44,10 @@ # import pennylane as qp -from pennylane import numpy as np +import numpy as np +import warnings + +warnings.filterwarnings(action="ignore", category=UserWarning) dataset = qp.data.load('qchem', molname="H3+")[0] H, qubits = dataset.hamiltonian, len(dataset.hamiltonian.wires) diff --git a/demonstrations_v2/tutorial_how_to_quantum_just_in_time_compile_vqe_catalyst/metadata.json b/demonstrations_v2/tutorial_how_to_quantum_just_in_time_compile_vqe_catalyst/metadata.json index 0d47296f4a..58cc132755 100644 --- a/demonstrations_v2/tutorial_how_to_quantum_just_in_time_compile_vqe_catalyst/metadata.json +++ b/demonstrations_v2/tutorial_how_to_quantum_just_in_time_compile_vqe_catalyst/metadata.json @@ -11,7 +11,7 @@ "executable_stable": true, "executable_latest": true, "dateOfPublication": "2024-04-26T00:00:00+00:00", - "dateOfLastModification": "2026-04-17T04:00:00+00:00", + "dateOfLastModification": "2026-05-05T00:00:00+00:00", "categories": [ "Quantum Machine Learning", "Optimization", diff --git a/demonstrations_v2/tutorial_liealgebra/demo.py b/demonstrations_v2/tutorial_liealgebra/demo.py index af9a664483..e56d78f171 100644 --- a/demonstrations_v2/tutorial_liealgebra/demo.py +++ b/demonstrations_v2/tutorial_liealgebra/demo.py @@ -100,6 +100,9 @@ import numpy as np import pennylane as qp from pennylane import X, Y, Z +import warnings + +warnings.filterwarnings(action="ignore", category=RuntimeWarning) su2 = [1j * X(0), 1j * Y(0), 1j * Z(0)] diff --git a/demonstrations_v2/tutorial_liealgebra/metadata.json b/demonstrations_v2/tutorial_liealgebra/metadata.json index 3eec4a5f88..958e7fb282 100644 --- a/demonstrations_v2/tutorial_liealgebra/metadata.json +++ b/demonstrations_v2/tutorial_liealgebra/metadata.json @@ -8,7 +8,7 @@ "executable_stable": true, "executable_latest": true, "dateOfPublication": "2024-02-27T00:00:00+00:00", - "dateOfLastModification": "2026-04-21T15:48:14+00:00", + "dateOfLastModification": "2026-05-05T00:00:00+00:00", "categories": [ "Quantum Computing" ], diff --git a/demonstrations_v2/tutorial_qnn_multivariate_regression/demo.py b/demonstrations_v2/tutorial_qnn_multivariate_regression/demo.py index 75cd2d7424..4e2b9b2221 100644 --- a/demonstrations_v2/tutorial_qnn_multivariate_regression/demo.py +++ b/demonstrations_v2/tutorial_qnn_multivariate_regression/demo.py @@ -73,6 +73,8 @@ from jax import numpy as jnp import optax +jax.config.update("jax_enable_x64", True) + pnp.random.seed(42) dev = qp.device('default.qubit', wires=2) diff --git a/demonstrations_v2/tutorial_qnn_multivariate_regression/metadata.json b/demonstrations_v2/tutorial_qnn_multivariate_regression/metadata.json index 1da2c7e5e8..6deea3b87c 100644 --- a/demonstrations_v2/tutorial_qnn_multivariate_regression/metadata.json +++ b/demonstrations_v2/tutorial_qnn_multivariate_regression/metadata.json @@ -11,7 +11,7 @@ "executable_stable": true, "executable_latest": true, "dateOfPublication": "2024-10-01T00:00:00+00:00", - "dateOfLastModification": "2026-04-21T15:48:14+00:00", + "dateOfLastModification": "2026-05-05T00:00:00+00:00", "categories": [ "Quantum Computing", "Quantum Machine Learning" diff --git a/dependencies/constraints-plc-dev.json b/dependencies/constraints-plc-dev.json index 1d70abb146..347e96a8e0 100644 --- a/dependencies/constraints-plc-dev.json +++ b/dependencies/constraints-plc-dev.json @@ -1,5 +1,5 @@ [ - {"name": "pennylane-catalyst", "version": "0.15.0"}, - {"name": "pennylane-lightning", "version": "0.45.0"}, - {"name": "pennylane", "version": "0.45.0"} + {"name": "pennylane-catalyst", "version": "0.16.0"}, + {"name": "pennylane-lightning", "version": "0.46.0"}, + {"name": "pennylane", "version": "0.46.0"} ] diff --git a/dependencies/constraints-stable.txt b/dependencies/constraints-stable.txt index 0f5baad9d2..3c37eeedcc 100644 --- a/dependencies/constraints-stable.txt +++ b/dependencies/constraints-stable.txt @@ -1,10 +1,10 @@ # Specifies global constraints for the stable build --extra-index-url https://download.pytorch.org/whl/cpu -pennylane==0.44.* +pennylane==0.45.* pennylane-cirq==0.44.* -pennylane-qiskit==0.44.* +pennylane-qiskit==0.45.* pennylane-qulacs==0.44.* -pennylane-catalyst==0.14.* +pennylane-catalyst==0.15.* # Install external packages matplotlib==3.10.0