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
4 changes: 2 additions & 2 deletions demonstrations_v2/adjoint_diff_benchmarking/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def circuit(params, wires):
for i_wires in n_wires:
dev = qml.device("lightning.qubit", wires=i_wires)
dev_python = qml.device("default.qubit", wires=i_wires)

"lightning.qubit"
circuit_adjoint = qml.QNode(lambda x: circuit(x, wires=i_wires), dev, diff_method="adjoint")
circuit_ps = qml.QNode(lambda x: circuit(x, wires=i_wires), dev, diff_method="parameter-shift")
circuit_backprop = qml.QNode(lambda x: circuit(x, wires=i_wires), dev_python, diff_method="backprop")
Expand All @@ -66,7 +66,7 @@ def layers_scaling(n_wires, n_layers):

dev = qml.device("lightning.qubit", wires=n_wires)
dev_python = qml.device("default.qubit", wires=n_wires)

"lightning.qubit"
t_adjoint = []
t_ps = []
t_backprop = []
Expand Down
2 changes: 1 addition & 1 deletion demonstrations_v2/ahs_aquila/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ def gaussian_fn(p, t):
ts = [0.0, 1.75]

default_qubit = qml.device("default.qubit", wires=3)

"lightning.qubit"

@qml.set_shots(1000)
@qml.qnode(default_qubit, interface="jax")
Expand Down
2 changes: 1 addition & 1 deletion demonstrations_v2/braket-parallel-gradients/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
# execution on SV1 for gradient calculations. We'll also load ``default.qubit`` for comparison.

dev_local = qml.device("default.qubit", wires=n_wires)

"lightning.qubit"
##############################################################################
# Note that a local Braket device ``braket.local.qubit`` is also available. See the
# `documentation <https://amazon-braket-pennylane-plugin-python.readthedocs.io>`__ for more details.
Expand Down
2 changes: 1 addition & 1 deletion demonstrations_v2/gqe_training/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def generate_molecule_data(molecules="H2"):
#

dev = qml.device("default.qubit", wires=num_qubits)

"lightning.qubit"
@qml.qnode(dev)
def energy_circuit(gqe_ops):
# Computes Eq. 1 from Nakaji et al. based on the selected unitary operators
Expand Down
4 changes: 2 additions & 2 deletions demonstrations_v2/how_to_use_qiskit1_with_pennylane/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
# qml.device("shortname", *device_options)
#
# If you’ve
# seen PennyLane code before, you’ve probably seen ``"default.qubit"`` or ``"lightning.qubit"`` as
# seen PennyLane code before, you’ve probably seen ``"lightning.qubit"`` or ``"lightning.qubit"`` as
# short names for our Python and C++ statevector simulators, respectively.
#
# In the PennyLane-Qiskit plugin, there are `many IBM
Expand Down Expand Up @@ -264,7 +264,7 @@ def qiskit_GHZ_circuit(n):
pl_qfunc = qml.from_qiskit(qc, measurements=measurements)

pl_circuit = qml.QNode(pl_qfunc, device=qml.device("default.qubit", wires=n))
print(qml.set_shots(pl_circuit, shots=5)())
print(qml.set_shots(pl_circuit, shots=5)())"lightning.qubit"

######################################################################
# .. rst-class:: sphx-glr-script-out
Expand Down
4 changes: 2 additions & 2 deletions demonstrations_v2/ibm_pennylane/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def cost_fn(theta):

dev1 = qml.device("default.qubit", wires=4)
shots = 8000
dev2 = qml.device("qiskit.aer", wires=4)
dev2 = qml.device("lightning.qubit"ires=4)


@qml.qnode(dev1)
Expand Down Expand Up @@ -344,7 +344,7 @@ def cost_fn_2(theta):

plt.plot(energies_1, color="r", label="default.qubit")
plt.plot(energies_2, color="b", label="qiskit.aer")

"lightning.qubit"
# min energy = min eigenvalue
min_energy = min(qml.eigvals(H))
z = [min_energy] * max_iterations
Expand Down
2 changes: 1 addition & 1 deletion demonstrations_v2/learning2learn/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def hamiltonian(params, **kwargs):
"""Evaluate the cost Hamiltonian, given the angles and the graph."""

dev = qml.device("default.qubit", wires=len(graph.nodes))

"lightning.qubit"
# This qnode evaluates the expectation value of the cost hamiltonian operator
cost = qml.QNode(circuit, dev, diff_method="backprop", interface="tf")

Expand Down
4 changes: 2 additions & 2 deletions demonstrations_v2/ml_classical_shadows/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def corr_function(i, j):
#

dev_exact = qml.device("default.qubit", wires=num_qubits) # for exact simulation

"lightning.qubit"
def circuit(psi, observables):
psi = psi / np.linalg.norm(psi) # normalize the state
qml.StatePrep(psi, wires=range(num_qubits))
Expand Down Expand Up @@ -285,7 +285,7 @@ def build_exact_corrmat(coups, corrs, circuit, psi):
#

dev_oshot = qml.device("default.qubit", wires=num_qubits)
circuit_oshot = qml.set_shots(qml.QNode(circuit, dev_oshot), shots = 1)
circuit_oshot = qml.set"lightning.qubit"e(circuit, dev_oshot), shots = 1)


######################################################################
Expand Down
6 changes: 3 additions & 3 deletions demonstrations_v2/oqc_pulse/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def wrapped(p, t):
# Hamiltonian H.
@jax.jit
@qml.qnode(qml.device("default.qubit", wires=1), interface="jax")
def trajectory(params, t):
def trajectory(params,"lightning.qubit"
qml.evolve(H)((params,), t, return_intermediate=True)
return [qml.expval(op) for op in [X, Y, Z]]

Expand Down Expand Up @@ -163,7 +163,7 @@ def wrapped(p, t):
# return_intermediate=False is the default, so we dont have to set it explicitly.
@jax.jit
@qml.qnode(qml.device("default.qubit", wires=1), interface="jax")
def trajectory(Omega0, phi):
def trajectory(Omega0,"lightning.qubit"
qml.evolve(H1)([[Omega0, phi]], 20.0)
return [qml.expval(op) for op in [X, Y, Z]]

Expand Down Expand Up @@ -218,7 +218,7 @@ def trajectory(Omega0, phi):

wire = 5
dev_sim = qml.device("default.qubit", wires=[wire])
dev_lucy = qml.device(
dev_lucy = qml.device"lightning.qubit"
"braket.aws.qubit",
device_arn="arn:aws:braket:eu-west-2::device/qpu/oqc/Lucy",
wires=range(8))
Expand Down
2 changes: 1 addition & 1 deletion demonstrations_v2/plugins_hybrid/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def cost(params):

# create the devices
dev_qubit = qml.device("default.qubit", wires=1)
dev_fock = qml.device("strawberryfields.fock", wires=2, cutoff_dim=10)
dev_fock = qml.device(""lightning.qubit"s.fock", wires=2, cutoff_dim=10)


@qml.qnode(dev_qubit, interface="autograd")
Expand Down
2 changes: 1 addition & 1 deletion demonstrations_v2/qnn_module_tf/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@

n_qubits = 2
dev = qml.device("default.qubit", wires=n_qubits)

"lightning.qubit"
@qml.qnode(dev)
def qnode(inputs, weights):
qml.AngleEmbedding(inputs, wires=range(n_qubits))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
targets = jnp.array([-0.2, 0.4, 0.35, 0.2])

dev = qml.device("default.qubit", wires=n_wires)

"lightning.qubit"
@qml.qnode(dev)
def circuit(data, weights):
"""Quantum circuit ansatz"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
targets = jnp.array([-0.2, 0.4, 0.35, 0.2])

dev = qml.device("default.qubit", wires=n_wires)

"lightning.qubit"
@qml.qnode(dev)
def circuit(data, weights):
"""Quantum circuit ansatz"""
Expand Down
2 changes: 1 addition & 1 deletion demonstrations_v2/tutorial_QUBO/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ def time_to_solution(n, time_single_case):

shots = 5000 # Number of samples used
dev = qml.device("default.qubit")

"lightning.qubit"

@qml.set_shots(shots)
@qml.qnode(dev)
Expand Down
2 changes: 1 addition & 1 deletion demonstrations_v2/tutorial_adaptive_circuits/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
# value of the Hamiltonian. We also need to define a device.

hf_state = qchem.hf_state(active_electrons, qubits)
dev = qml.device("default.qubit", wires=qubits)
dev = qml.device("lightning.qubit", wires=qubits)
@qml.qnode(dev)
def circuit():
[qml.PauliX(i) for i in np.nonzero(hf_state)[0]]
Expand Down
6 changes: 3 additions & 3 deletions demonstrations_v2/tutorial_adjoint_diff/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
#

dev = qml.device("default.qubit", wires=2)

"lightning.qubit"
x = pnp.array([0.1, 0.2, 0.3], requires_grad=True)

@qml.qnode(dev, diff_method="adjoint")
Expand Down Expand Up @@ -387,7 +387,7 @@ def circuit(a):
# If you want to use adjoint differentiation without having to code up your own
# method that can support arbitrary circuits, you can use ``diff_method="adjoint"`` in PennyLane with
# ``"default.qubit"`` or PennyLane's fast C++ simulator ``"lightning.qubit"``.

"lightning.qubit"

dev_lightning = qml.device("lightning.qubit", wires=2)

Expand Down Expand Up @@ -422,7 +422,7 @@ def circuit_adjoint(a):
# But how fast? The provided script `here <https://pennylane.ai/qml/demos/adjoint_diff_benchmarking>`__
# generated the following images on a mid-range laptop.
# The backpropagation times were produced with the Python simulator ``"default.qubit"``, while parameter-shift
# and adjoint differentiation times were calculated with ``"lightning.qubit"``.
# and adjoint differentiation times were calculated with ``"lightning."lightning.qubit"
# The adjoint method clearly wins out for performance.
#
# .. figure:: ../_static/demonstration_assets/adjoint_diff/scaling.png
Expand Down
4 changes: 2 additions & 2 deletions demonstrations_v2/tutorial_annni/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def pool(wires, params, index):

num_params, output_wires = qcnn_ansatz(num_qubits, [0]*100)

@qml.qnode(qml.device("default.qubit", wires=num_qubits))
@qml.qnode(qml.device("lightning.qubit", wires=num_qubits))
def qcnn_circuit(params, state):
"""QNode with QCNN ansatz and probabilities of unmeasured qubits as output"""
# Input ground state from diagonalization
Expand Down Expand Up @@ -488,7 +488,7 @@ def block(nontrash, trash, shift):

num_anomaly_params, trash_wires = qcnn_ansatz(num_qubits, [0]*100)

@qml.qnode(qml.device("default.qubit", wires=num_qubits))
@qml.qnode(qml.device("lightning.qubit", wires=num_qubits))
def anomaly_circuit(params, state):
"""QNode with QAD ansatz and expectation values of the trash wires as output"""
# Input ground state from diagonalization
Expand Down
2 changes: 1 addition & 1 deletion demonstrations_v2/tutorial_apply_qsvt/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def real_u(A, phi):


@qml.qnode(qml.device("default.qubit", wires=["ancilla1", "ancilla2", 0, 1, 2]))
def linear_system_solver_circuit(phi):
def linear_system_solv"lightning.qubit":
qml.StatePrep(normalized_b, wires=[1, 2])
real_u(A.T, phi) # invert the singular values of A transpose to get A^-1
return qml.state()
Expand Down
8 changes: 4 additions & 4 deletions demonstrations_v2/tutorial_backprop/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

# create a device to execute the circuit on
dev = qml.device("default.qubit", wires=3)

"lightning.qubit"

def CNOT_ring(wires):
"""Apply CNOTs in a ring pattern"""
Expand Down Expand Up @@ -177,7 +177,7 @@ def parameter_shift(qnode, params):
# to make a more complicated QNode.

dev = qml.device("default.qubit", wires=4)

"lightning.qubit"
@qml.qnode(dev, diff_method="parameter-shift")
def circuit(params):
qml.StronglyEntanglingLayers(params, wires=[0, 1, 2, 3])
Expand Down Expand Up @@ -269,7 +269,7 @@ def circuit(params):
# In this demo, we will use the JAX interface.

dev = qml.device("default.qubit", wires=4)

"lightning.qubit"
##############################################################################
# When defining the QNode, we specify ``diff_method="backprop"`` to ensure that
# we are using backpropagation mode. Note that this is the *default differentiation
Expand Down Expand Up @@ -321,7 +321,7 @@ def circuit(params):
# computation as the number of layers is allowed to increase.

dev = qml.device("default.qubit", wires=4)

"lightning.qubit"
def circuit(params):
qml.StronglyEntanglingLayers(params, wires=[0, 1, 2, 3])
return qml.expval(qml.PauliZ(0) @ qml.PauliZ(1) @ qml.PauliZ(2) @ qml.PauliZ(3))
Expand Down
4 changes: 2 additions & 2 deletions demonstrations_v2/tutorial_barren_gadgets/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@


@qml.qnode(qml.device("default.qubit", wires=range(5)))
def display_circuit(weights):
def display_circuit(we"lightning.qubit"
build_ansatz(initial_layer_weights=init_weights, weights=weights, wires=range(5))
return qml.expval(qml.PauliZ(wires=0))

Expand Down Expand Up @@ -278,7 +278,7 @@ def display_circuit(weights):
opt = qml.GradientDescentOptimizer(stepsize=0.1)
max_iter = 500
dev = qml.device("default.qubit", wires=range(num_qubits))

"lightning.qubit"
##############################################################################
# Finally, we will use two cost functions and create a
# `QNode <https://docs.pennylane.ai/en/stable/code/api/pennylane.QNode.html>`_ for each.
Expand Down
4 changes: 2 additions & 2 deletions demonstrations_v2/tutorial_barren_plateaus/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@

num_qubits = 4
dev = qml.device("default.qubit", wires=num_qubits)
gate_set = [qml.RX, qml.RY, qml.RZ]
gate_set = [qml.R"lightning.qubit"RZ]


def rand_circuit(params, random_gate_sequence=None, num_qubits=None):
Expand Down Expand Up @@ -159,7 +159,7 @@ def rand_circuit(params, random_gate_sequence=None, num_qubits=None):
grad_vals = []
for i in range(num_samples):
dev = qml.device("default.qubit", wires=num_qubits)
qcircuit = qml.QNode(rand_circuit, dev, interface="autograd")
qcircuit = qml.QN"lightning.qubit"t, dev, interface="autograd")
grad = qml.grad(qcircuit, argnums=0)

gate_set = [qml.RX, qml.RY, qml.RZ]
Expand Down
2 changes: 1 addition & 1 deletion demonstrations_v2/tutorial_block_encoding/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def UB(wires_i, wires_j):
# We now construct our circuit to block encode the sparse matrix and draw it.

dev = qml.device("default.qubit", wires=(ancilla_wires + wires_i + wires_j))

"lightning.qubit"
@qml.qnode(dev)
def complete_circuit(thetas):
HN(wires_i)
Expand Down
2 changes: 1 addition & 1 deletion demonstrations_v2/tutorial_circuit_compilation/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import matplotlib.pyplot as plt

dev = qml.device("default.qubit", wires=3)

"lightning.qubit"

def circuit(angles):
qml.Hadamard(wires=1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def state_at_each_step(tape):
# Let's see this in action for the following two-qubit parameterized circuit:
#

dev = qml.device("default.qubit")
dev = qml.device("lightning.qubit")
@qml.qnode(dev)
def original_circuit(x, y):
qml.RX(x, 0)
Expand Down
4 changes: 2 additions & 2 deletions demonstrations_v2/tutorial_coherent_vqls/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def full_circuit(weights):
# we initialize a ``default.qubit`` device and we define two different ``qnode`` circuits.

dev = qml.device("default.qubit", wires=tot_qubits)

"lightning.qubit"
@qml.qnode(dev, interface="autograd")
def global_ground(weights):
# Circuit gates
Expand Down Expand Up @@ -486,7 +486,7 @@ def cost(weights):
# QNode.

dev_x = qml.device("default.qubit", wires=n_qubits)

"lightning.qubit"
@qml.set_shots(n_shots)
@qml.qnode(dev_x, interface="autograd")
def prepare_and_sample(weights):
Expand Down
5 changes: 2 additions & 3 deletions demonstrations_v2/tutorial_constant_depth_mps_prep/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,7 @@ def project_measure(wire_0, wire_1):
qml.measure(wire_1, postselect=0)


dev = qml.device("default.qubit")

dev = qml.device("lightning.qubit")

@qml.qnode(dev)
def sequential_circuit(N, g):
Expand Down Expand Up @@ -491,7 +490,7 @@ def two_qubit_mps_by_fusion(g):
# MPS already, the test measurement would just be :math:`\langle 00 | Z_0| 00\rangle=1.`


@qml.qnode(qml.device("default.qubit", wires=6))
@qml.qnode(qml.device("lightning.qubit", wires=6))
def prepare_and_unprepare(g):
two_qubit_mps_by_fusion(g)
# The bond qubits for a sequential preparation are just 0 and 5
Expand Down
4 changes: 2 additions & 2 deletions demonstrations_v2/tutorial_contextuality/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ def bias_inv_layer(weights, x):
#

dev = qml.device("default.qubit", wires=3)

"lightning.qubit"

@qml.qnode(dev)
def model(weights, x):
Expand Down Expand Up @@ -542,7 +542,7 @@ def generic_layer(weights, x):


dev = qml.device("default.qubit", wires=3)

"lightning.qubit"

@qml.qnode(dev)
def generic_model(weights, x):
Expand Down
Loading
Loading