Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pennylane as qml
qml.capture.enable()
from pennylane import numpy as np

def non_identity_obs(obs):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pennylane as qml
qml.capture.enable()
from pennylane import numpy as np

""" Based on the SimplifiedTwoDesign template from pennylane
Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/adjoint_diff_benchmarking/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import timeit
import matplotlib.pyplot as plt
import pennylane as qml
qml.capture.enable()
import pennylane.numpy as pnp

plt.style.use("bmh")
Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/ahs_aquila/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@
"""

import pennylane as qml
qml.capture.enable()

aquila = qml.device(
"braket.aws.ahs",
Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/braket-parallel-gradients/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
# SV1 can now be loaded with the standard PennyLane :func:`~.pennylane.device`:

import pennylane as qml
qml.capture.enable()
from pennylane import numpy as np

n_wires = 25
Expand Down
2 changes: 2 additions & 0 deletions demonstrations_v2/covalent_cloud_gpu/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import covalent_cloud as cc
import matplotlib.pyplot as plt
import pennylane as qml
qml.capture.enable()
from matplotlib.colors import ListedColormap
from pennylane import numpy as np
from sklearn.datasets import make_blobs
Expand Down Expand Up @@ -266,6 +267,7 @@ def run_qsvm(n_samples, test_size):
# import covalent_cloud as cc
# import matplotlib.pyplot as plt
# import pennylane as qml
qml.capture.enable()
# from matplotlib.colors import ListedColormap
# from pennylane import numpy as np
# from sklearn.datasets import make_blobs
Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/ensemble_multi_qpu/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import matplotlib.pyplot as plt
import numpy as np
import pennylane as qml
qml.capture.enable()
import sklearn.datasets
import sklearn.decomposition
import torch
Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/function_fitting_qsp/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ def generate_many_sro(a_vals):


import pennylane as qml
qml.capture.enable()


def QSP_circ(phi, W):
Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/gbs/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@

# import PennyLane
import pennylane as qml
qml.capture.enable()

##############################################################################
# We must define the unitary matrix we would like to embed in the circuit.
Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/getting_started_with_hybrid_jobs/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
#

import pennylane as qml
qml.capture.enable()
from pennylane import numpy as np


Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/gqe_training/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@

import numpy as np
import pennylane as qml
qml.capture.enable()

def generate_molecule_data(molecules="H2"):
datasets = qml.data.load("qchem", molname=molecules)
Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/how_to_catalyst_lightning_gpu/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
# .. code-block:: python
#
# import pennylane as qml
qml.capture.enable()
# import jax.numpy as jnp
#
# import jax
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
#

import pennylane as qml
qml.capture.enable()

dev = qml.device("qiskit.basicsim", wires=2)

Expand Down
2 changes: 2 additions & 0 deletions demonstrations_v2/ibm_pennylane/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
# Currently, there are three devices available — ``Aer``, ``BasicSim`` and ``Remote`` — that can be initialized
# as follows:
import pennylane as qml
qml.capture.enable()
from qiskit_aer import AerSimulator

qubits = 4
Expand Down Expand Up @@ -138,6 +139,7 @@
from qiskit_ibm_runtime import QiskitRuntimeService

import pennylane as qml
qml.capture.enable()

# Obtaining the Hamiltonian for H2 from PennyLane QChem dataset
[dataset] = qml.data.load("qchem", molname="H2", bondlength=0.742, basis="STO-3G")
Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/learning2learn/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@

# Quantum Machine Learning
import pennylane as qml
qml.capture.enable()
from pennylane import qaoa

# Classical Machine Learning
Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/ml_classical_shadows/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def build_coupling_mats(num_mats, num_rows, num_cols):
#

import pennylane as qml
qml.capture.enable()

def Hamiltonian(J_mat):
coeffs, ops = [], []
Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/oqc_pulse/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"""

import pennylane as qml
qml.capture.enable()
import numpy as np
import jax.numpy as jnp
import jax
Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/plugins_hybrid/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
"""

import pennylane as qml
qml.capture.enable()
from pennylane import numpy as np

##############################################################################
Expand Down
2 changes: 2 additions & 0 deletions demonstrations_v2/pytorch_noise/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"""

import pennylane as qml
qml.capture.enable()
import torch
from torch.autograd import Variable

Expand Down Expand Up @@ -200,6 +201,7 @@ def cost(phi, theta, step):
# :doc:`Computing gradients in parallel with Amazon Braket <demos/braket-parallel-gradients>`.

import pennylane as qml
qml.capture.enable()
import torch
from torch.autograd import Variable

Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/qnn_module_tf/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
# operations from the :doc:`templates <introduction/templates>` module.

import pennylane as qml
qml.capture.enable()

n_qubits = 2
dev = qml.device("default.qubit", wires=n_qubits)
Expand Down
2 changes: 2 additions & 0 deletions demonstrations_v2/qnspsa/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
# initialize a graph for the max cut problem
import networkx as nx
import pennylane as qml
qml.capture.enable()
from pennylane import qaoa

nodes = n_qubits = 4
Expand Down Expand Up @@ -636,6 +637,7 @@ def get_next_params(params, gradient):

import random
import pennylane as qml
qml.capture.enable()
from pennylane import numpy as np
from scipy.linalg import sqrtm
import warnings
Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/qonn/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
#

import pennylane as qml
qml.capture.enable()
from pennylane import numpy as np

import nlopt
Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/qrack/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"""

import pennylane as qml
qml.capture.enable()
from pennylane import numpy as np
from catalyst import qjit

Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/qsim_beyond_classical/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
#

import pennylane as qml
qml.capture.enable()
from pennylane_cirq import ops

import cirq
Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/quantum_neural_net/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"""

import pennylane as qml
qml.capture.enable()
from pennylane import numpy as np
from pennylane.optimize import AdamOptimizer

Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/quantum_volume/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@
# :func:`~.pennylane.Permute` subroutine.

import pennylane as qml
qml.capture.enable()

# Object for random number generation from numpy
rng = np.random.default_rng()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#

import pennylane as qml
qml.capture.enable()
import jax
from jax import numpy as jnp
import jaxopt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#

import pennylane as qml
qml.capture.enable()
import jax
from jax import numpy as jnp
import optax
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"""

import pennylane as qml
qml.capture.enable()
from jax import numpy as jnp
import optax
import catalyst
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#

import pennylane as qml
qml.capture.enable()
import numpy as np

# Define the keyword arguments for the MPS method
Expand Down Expand Up @@ -137,6 +138,7 @@ def circuit(theta, phi, num_qubits):
#

import pennylane as qml
qml.capture.enable()
import numpy as np

# Define the keyword arguments for the TN method
Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/tutorial_QGAN/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

import numpy as np
import pennylane as qml
qml.capture.enable()
import tensorflow as tf

##############################################################################
Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/tutorial_QUBO/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ def time_to_solution(n, time_single_case):
# ----------------------------- QAOA circuit ------------------------------------
from collections import defaultdict
import pennylane as qml
qml.capture.enable()

shots = 5000 # Number of samples used
dev = qml.device("default.qubit")
Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/tutorial_adaptive_circuits/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"""

import pennylane as qml
qml.capture.enable()
import jax
import numpy as np
import time
Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/tutorial_adjoint_diff/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
# To start, we import PennyLane and Jax's numpy:

import pennylane as qml
qml.capture.enable()
import pennylane.numpy as pnp


Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/tutorial_adversarial_attacks_QML/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
#

import pennylane as qml
qml.capture.enable()
from pennylane import numpy as np
import torch
from matplotlib import pyplot as plt
Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/tutorial_annni/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
as well as setting some important constants:
"""
import pennylane as qml
qml.capture.enable()
import numpy as np
from jax import jit, vmap, value_and_grad, random, config
from jax import numpy as jnp
Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/tutorial_apply_qsvt/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"""

import pennylane as qml
qml.capture.enable()
from pennylane import numpy as np

dev = qml.device("lightning.qubit", wires=[0, 1])
Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/tutorial_backprop/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
Let's have a go implementing the parameter-shift rule manually in PennyLane.
"""
import pennylane as qml
qml.capture.enable()
from jax import numpy as jnp
from matplotlib import pyplot as plt
import jax
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pennylane as qml
qml.capture.enable()
from pennylane import numpy as np

def non_identity_obs(obs):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pennylane as qml
qml.capture.enable()
from pennylane import numpy as np

""" Based on the SimplifiedTwoDesign template from pennylane
Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/tutorial_barren_gadgets/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
# Finally, ``build_ansatz`` puts the pieces together.

import pennylane as qml
qml.capture.enable()
from pennylane import numpy as np
from barren_gadgets.barren_gadgets import PerturbativeGadgets
from barren_gadgets.layered_ansatz import (
Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/tutorial_barren_plateaus/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"""

import pennylane as qml
qml.capture.enable()
from pennylane import numpy as np
import matplotlib.pyplot as plt

Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/tutorial_block_encoding/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"""

import pennylane as qml
qml.capture.enable()
from pennylane.templates.state_preparations.mottonen import compute_theta, gray_code
import numpy as np
import matplotlib.pyplot as plt
Expand Down
1 change: 1 addition & 0 deletions demonstrations_v2/tutorial_bluequbit/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"""

import pennylane as qml
qml.capture.enable()
import matplotlib.pyplot as plt
import numpy as np

Expand Down
2 changes: 2 additions & 0 deletions demonstrations_v2/tutorial_bp_catalyst/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
from typing import Callable, Optional, Dict, Union, Sequence

import pennylane as qml
qml.capture.enable()

syndromes = ["XXZIZIX", "XXIIZZI"]
dev = qml.device("lightning.qubit", wires := max(map(len, syndromes)) + 1)
Expand Down Expand Up @@ -740,6 +741,7 @@ def ml_rep_decoder(syndrome: ArrayLike) -> ArrayLike:
#

import pennylane as qml
qml.capture.enable()
from jax import random
import catalyst

Expand Down
Loading
Loading