Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development branch #637

Merged
merged 131 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
5743fa5
Development branch
josh146 Nov 15, 2022
39ca8c1
Merge branch 'master' into dev
actions-user Nov 18, 2022
17fdcb4
Merge branch 'master' into dev
actions-user Nov 21, 2022
47e83e1
Merge branch 'master' into dev
actions-user Nov 21, 2022
12ef0b8
Merge branch 'master' into dev
actions-user Nov 22, 2022
ecad024
Merge branch 'master' into dev
actions-user Nov 23, 2022
b0fb42b
Merge branch 'master' into dev
actions-user Nov 25, 2022
f39ee3f
Merge branch 'master' into dev
actions-user Nov 28, 2022
00becee
Merge branch 'master' into dev
actions-user Nov 28, 2022
3685225
Merge branch 'master' into dev
actions-user Nov 29, 2022
ce0d527
Merge branch 'master' into dev
actions-user Dec 1, 2022
8a86295
Merge branch 'master' into dev
actions-user Dec 2, 2022
7a323e1
Merge branch 'master' into dev
actions-user Dec 5, 2022
289baab
Merge branch 'master' into dev
actions-user Dec 7, 2022
b91874b
Merge branch 'master' into dev
actions-user Dec 9, 2022
9c92f0e
Merge branch 'master' into dev
actions-user Dec 10, 2022
1d32d2b
Merge branch 'master' into dev
actions-user Dec 12, 2022
8c25d7d
Merge branch 'master' into dev
actions-user Dec 12, 2022
222e6a6
Merge branch 'master' into dev
actions-user Dec 16, 2022
a8284e3
Bumped requirement package versions (#667)
rashidnhm Dec 19, 2022
ccfcf45
Merge dev in master following v0.28.0 release of PennyLane (#671) (#672)
rashidnhm Dec 21, 2022
808b1d8
Merge branch 'master' into dev
rashidnhm Dec 21, 2022
00a7c8c
Merge branch 'master' into dev
actions-user Jan 3, 2023
bf00d71
Merge branch 'master' into dev
actions-user Jan 4, 2023
cc47e89
Merge branch 'master' into dev
actions-user Jan 5, 2023
b3f7f3e
Merge branch 'master' into dev
actions-user Jan 5, 2023
9316a8f
Merge branch 'master' into dev
actions-user Jan 18, 2023
eb7a990
Merge branch 'master' into dev
actions-user Jan 20, 2023
595b898
Merge branch 'master' into dev
actions-user Jan 23, 2023
03ee056
Merge branch 'master' into dev
actions-user Jan 23, 2023
76d7343
Merge branch 'master' into dev
actions-user Jan 30, 2023
5281bd8
Merge branch 'master' into dev
actions-user Feb 3, 2023
dadd39c
Merge branch 'master' into dev
actions-user Feb 3, 2023
a8ab874
Merge branch 'master' into dev
actions-user Feb 6, 2023
b39a0e7
Merge branch 'master' into dev
actions-user Feb 6, 2023
4f65f43
Merge branch 'master' into dev
actions-user Feb 10, 2023
673e059
Merge branch 'master' into dev
actions-user Feb 14, 2023
34b6c43
Merge branch 'master' into dev
actions-user Feb 21, 2023
3b40e58
Merge branch 'master' into dev
actions-user Feb 21, 2023
8356cca
Update chemical reactions demo to use pyscf for openshell H3 (#704)
soranjh Feb 21, 2023
10d6d86
Change ibm device in Quantum volume (#703)
rmoyard Feb 22, 2023
ab34e2a
Update demos to remove warnings (#705)
mudit2812 Feb 22, 2023
e8811cd
Update classical shadows (#708)
rmoyard Feb 23, 2023
942cbb5
Update SPSA demo to count circuit executions manually. (#706)
dwierichs Feb 24, 2023
c2bcccb
Merge branch 'master' into dev
actions-user Feb 24, 2023
62295af
Merge branch 'master' into dev
actions-user Feb 28, 2023
f98c1ec
Merge branch 'master' into dev
trbromley Mar 1, 2023
fd6fb94
Merge branch 'master' into dev
actions-user Mar 3, 2023
cf7ddcf
Merge branch 'master' into dev
actions-user Mar 3, 2023
3e34def
Merge branch 'master' into dev
rashidnhm Mar 15, 2023
f487736
Merge branch 'master' into dev
actions-user Mar 16, 2023
a2c4aac
Merge branch 'master' into dev
actions-user Mar 17, 2023
580ea7b
Merge branch 'master' into dev
actions-user Mar 20, 2023
36bd9a7
Merge branch 'master' into dev
actions-user Mar 22, 2023
125fe67
Merge branch 'master' into dev
actions-user Mar 22, 2023
a8cb199
Merge branch 'master' into dev
actions-user Mar 24, 2023
649de42
Merge branch 'master' into dev
actions-user Apr 3, 2023
3471f48
Merge branch 'master' into dev
actions-user Apr 4, 2023
59d2d60
Merge branch 'master' into dev
actions-user Apr 4, 2023
ff563c6
Merge branch 'master' into dev
actions-user Apr 4, 2023
e68fa30
Merge branch 'master' into dev
actions-user Apr 10, 2023
432b6e9
Merge branch 'master' into dev
actions-user Apr 10, 2023
dbccd02
Merge branch 'master' into dev
actions-user Apr 10, 2023
ce4d5bb
Updated adaptive circuits demo for new return type (#735)
mudit2812 Apr 14, 2023
ef4184f
Merge branch 'master' into dev
actions-user Apr 17, 2023
a5ad1d6
Merge branch 'master' into dev
actions-user Apr 18, 2023
d6b47ac
Merge branch 'master' into dev
actions-user Apr 18, 2023
d770e5b
Merge branch 'master' into dev
actions-user Apr 19, 2023
16b4dd2
Merge branch 'master' into dev
actions-user Apr 19, 2023
1e61f33
Merge branch 'master' into dev
actions-user Apr 21, 2023
3cdc59a
Merge branch 'master' into dev
actions-user Apr 22, 2023
a84c9a9
Merge branch 'master' into dev
actions-user Apr 24, 2023
7e4dfe9
Update automatically run demos to be able to execute with v0.30 (#741)
albi3ro Apr 24, 2023
be299d6
remove nlopt from list of requirements (#755)
albi3ro Apr 24, 2023
ba04866
Merge branch 'master' into dev
actions-user Apr 24, 2023
11991f5
use dev version of lightning for demo checker (#759)
albi3ro Apr 25, 2023
d494b50
Improve formatting of output in toric code demo (#762)
albi3ro Apr 26, 2023
c219606
Merge branch 'master' into dev
actions-user Apr 26, 2023
30a6039
use lightning in quantumvolume; fix qnspsa for new return; use H.spar…
timmysilv Apr 27, 2023
63a7104
Merge branch 'master' into dev
actions-user Apr 27, 2023
8c7e4cd
Merge branch 'master' into dev
actions-user Apr 28, 2023
ba89a43
Merge branch 'master' into dev
actions-user Apr 28, 2023
680d318
Merge branch 'master' into dev
actions-user Apr 28, 2023
1ce2d79
Update manually run demos (#766)
mudit2812 Apr 28, 2023
ad2e71d
Add warnings to pennylane-sf plugins and expected output (#761)
albi3ro Apr 28, 2023
0d40cb6
Merge branch 'master' into dev
rashidnhm May 3, 2023
53619bc
Merge branch 'master' into dev
actions-user May 4, 2023
4c41de4
Merge branch 'master' into dev
actions-user May 5, 2023
1bffa08
Merge branch 'master' into dev
actions-user May 8, 2023
2668695
Merge branch 'master' into dev
actions-user May 8, 2023
f898f7b
Merge branch 'master' into dev
actions-user May 8, 2023
d5c4f5d
Merge branch 'master' into dev
actions-user May 11, 2023
931403b
Merge branch 'master' into dev
actions-user May 12, 2023
89fe71f
Merge branch 'master' into dev
actions-user May 12, 2023
cd482a5
Merge branch 'master' into dev
actions-user May 15, 2023
0128b31
Merge branch 'master' into dev
actions-user May 15, 2023
2575190
Merge branch 'master' into dev
actions-user May 17, 2023
07bdfd9
Merge branch 'master' into dev
actions-user May 17, 2023
d584998
Merge branch 'master' into dev
actions-user May 18, 2023
e49598f
Merge branch 'master' into dev
actions-user May 18, 2023
301ab7a
Merge branch 'master' into dev
actions-user May 19, 2023
ccde5b1
Merge branch 'master' into dev
actions-user May 24, 2023
abdace6
Merge branch 'master' into dev
actions-user May 24, 2023
fb79fdd
Merge branch 'master' into dev
actions-user May 29, 2023
52137be
Merge branch 'master' into dev
actions-user May 30, 2023
f35a3fd
Merge branch 'master' into dev
actions-user May 31, 2023
dba08dd
Merge branch 'master' into dev
actions-user May 31, 2023
1e22667
Merge branch 'master' into dev
actions-user Jun 5, 2023
ef87ab0
Merge branch 'master' into dev
actions-user Jun 5, 2023
acfac90
Merge branch 'master' into dev
actions-user Jun 5, 2023
ed9495c
Merge branch 'master' into dev
actions-user Jun 6, 2023
29282b9
Merge branch 'master' into dev
actions-user Jun 7, 2023
f97947b
Merge branch 'master' into dev
actions-user Jun 8, 2023
953fdc2
Merge branch 'master' into dev
actions-user Jun 9, 2023
e9b1ae9
Merge branch 'master' into dev
actions-user Jun 9, 2023
2fc33cc
Merge branch 'master' into dev
actions-user Jun 12, 2023
bd943fb
Merge branch 'master' into dev
actions-user Jun 12, 2023
7b971bb
dev (#824)
KetpuntoG Jun 13, 2023
bada2cf
Update requirements.txt (#825)
trbromley Jun 16, 2023
4ae5736
Merge branch 'master' into dev
actions-user Jun 16, 2023
576f734
Merge branch 'master' into dev
actions-user Jun 16, 2023
66cd235
Update resource estimation demo for non-cubic systems (#823)
soranjh Jun 16, 2023
2f8959e
Merge branch 'master' into dev
actions-user Jun 19, 2023
7c2be4e
Merge branch 'master' into dev
actions-user Jun 19, 2023
020e8c3
Merge branch 'master' into dev
actions-user Jun 20, 2023
b7b20da
Change private methods in adjoint diff tutorial (#832)
albi3ro Jun 20, 2023
f478b84
Merge branch 'master' into dev
actions-user Jun 21, 2023
21061d0
Add fermionic operators demo (#813)
soranjh Jun 23, 2023
08206a6
Fixes for 0.31 release (#835)
mudit2812 Jun 23, 2023
9d979ee
Modify image in fermionic demo (#838)
soranjh Jun 23, 2023
e82ec77
use pinned versions of pennylane and plugins (#840)
timmysilv Jun 26, 2023
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion demonstrations/ensemble_multi_qpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@
# plotting later on. The first two principal components of the data are used.

np.random.seed(1967)
x, y = zip(*np.random.permutation(list(zip(x, y))))

data_order = np.random.permutation(np.arange(n_samples))
x, y = x[data_order], y[data_order]

pca = sklearn.decomposition.PCA(n_components=n_features)
pca.fit(x)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 35 additions & 31 deletions demonstrations/tutorial_adjoint_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"""

##############################################################################
# *Author: Christina Lee. Posted: 23 Nov 2021. Last updated: 23 Nov 2021.*
# *Author: Christina Lee. Posted: 23 Nov 2021. Last updated: 20 Jun 2023.*
#
# `Classical automatic differentiation <https://en.wikipedia.org/wiki/Automatic_differentiation#The_chain_rule,_forward_and_reverse_accumulation>`__
# has two methods of calculation: forward and reverse.
Expand Down Expand Up @@ -110,21 +110,26 @@ def circuit(a):
M = qml.PauliX(wires=1)

##############################################################################
# We create our state by using the ``"default.qubit"`` methods ``_create_basis_state``
# and ``_apply_operation``.
# We will be using internal functions to manipulate the nuts and bolts of a statevector
# simulation.
#
# Internally, the statevector simulation uses a 2x2x2x... array to represent the state, whereas
# the result of a measurement ``qml.state()`` flattens this internal representation. Each dimension
# in the statevector corresponds to a different qubit.
#
# The internal functions ``create_initial_state`` and ``apply_operation``
# make additional assumptions about their inputs, and will fail or give incorrect results
# if those assumptions are not met. To work with these simulation tools, all operations should provide
# a matrix, and all wires must corresponding to dimensions of the statevector. This means all wires must already
# be integers starting from ``0``, and not exceed the number of dimensions in the state vector.
#
# These are private methods that you shouldn't typically use and are subject to change
# without a deprecation period,
# but we use them here to illustrate the algorithm.
#
# Internally, the device uses a 2x2x2x... array to represent the state, whereas
# the measurement ``qml.state()`` and the device attribute ``dev.state``
# flatten this internal representation.

state = dev._create_basis_state(0)
from pennylane.devices.qubit import create_initial_state, apply_operation

state = create_initial_state((0, 1))

for op in ops:
state = dev._apply_operation(state, op)
state = apply_operation(op, state)

print(state)

Expand All @@ -145,7 +150,7 @@ def circuit(a):
# Using the ``state`` calculated above, we can create these :math:`|b\rangle` and :math:`|k\rangle`
# vectors.

bra = dev._apply_operation(state, M)
bra = apply_operation(M, state)
ket = state

##############################################################################
Expand All @@ -171,17 +176,17 @@ def circuit(a):
# and gotten the exact same results. Here, the subscript :math:`n` is used to indicate that :math:`U_n`
# was moved to the bra side of the expression. Let's calculate that instead:

bra_n = dev._create_basis_state(0)
bra_n = create_initial_state((0, 1))

for op in ops:
bra_n = dev._apply_operation(bra_n, op)
bra_n = dev._apply_operation(bra_n, M)
bra_n = dev._apply_operation(bra_n, qml.adjoint(ops[-1]))
bra_n = apply_operation(op, bra_n)
bra_n = apply_operation(M, bra_n)
bra_n = apply_operation(qml.adjoint(ops[-1]), bra_n)

ket_n = dev._create_basis_state(0)
ket_n = create_initial_state((0, 1))

for op in ops[:-1]: # don't apply last operation
ket_n = dev._apply_operation(ket_n, op)
ket_n = apply_operation(op, ket_n)

M_expval_n = np.vdot(bra_n, ket_n)
print(M_expval_n)
Expand Down Expand Up @@ -210,13 +215,13 @@ def circuit(a):
#
# Let's call this the "version 2" method.

bra_n_v2 = dev._apply_operation(state, M)
bra_n_v2 = apply_operation(M, state)
ket_n_v2 = state

adj_op = qml.adjoint(ops[-1])

bra_n_v2 = dev._apply_operation(bra_n_v2, adj_op)
ket_n_v2 = dev._apply_operation(ket_n_v2, adj_op)
bra_n_v2 = apply_operation(adj_op, bra_n_v2)
ket_n_v2 = apply_operation(adj_op, ket_n_v2)

M_expval_n_v2 = np.vdot(bra_n_v2, ket_n_v2)
print(M_expval_n_v2)
Expand All @@ -240,13 +245,13 @@ def circuit(a):
# For each iteration, we move an operation from the ket side to the bra side.
# We start near the center at :math:`U_n` and reverse through the operations list until we reach :math:`U_0`.

bra_loop = dev._apply_operation(state, M)
bra_loop = apply_operation(M, state)
ket_loop = state

for op in reversed(ops):
adj_op = qml.adjoint(op)
bra_loop = dev._apply_operation(bra_loop, adj_op)
ket_loop = dev._apply_operation(ket_loop, adj_op)
bra_loop = apply_operation(adj_op, bra_loop)
ket_loop = apply_operation(adj_op, ket_loop)
print(np.vdot(bra_loop, ket_loop))

##############################################################################
Expand Down Expand Up @@ -345,27 +350,26 @@ def circuit(a):
# We loop over the reversed operations, just as before. But if the operation has a parameter,
# we calculate its derivative and append it to a list before moving on. Since the ``operation_derivative``
# function spits back out a matrix instead of an operation,
# we have to use ``dev._apply_unitary`` instead to create :math:`|\tilde{k}_i\rangle`.
# we have to use :class:`~pennylane.QubitUnitary` instead to create :math:`|\tilde{k}_i\rangle`.

bra = dev._apply_operation(state, M)
bra = apply_operation(M, state)
ket = state

grads = []

for op in reversed(ops):
adj_op = qml.adjoint(op)
ket = dev._apply_operation(ket, adj_op)
ket = apply_operation(adj_op, ket)

# Calculating the derivative
if op.num_params != 0:
dU = qml.operation.operation_derivative(op)

ket_temp = dev._apply_unitary(ket, dU, op.wires)
ket_temp = apply_operation(qml.QubitUnitary(dU, op.wires), ket)

dM = 2 * np.real(np.vdot(bra, ket_temp))
grads.append(dM)

bra = dev._apply_operation(bra, adj_op)
bra = apply_operation(adj_op, bra)


# Finally reverse the order of the gradients
Expand Down
56 changes: 56 additions & 0 deletions demonstrations/tutorial_fermionic_operators.metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"title": "Fermionic operators",
"authors": [
{
"id": "soran_jahangiri"
}
],
"dateOfPublication": "2023-06-27T00:00:00",
"dateOfLastModification": "2023-06-27T00:00:00",
"categories": [
"Quantum Chemistry"
],
"tags": [],
"previewImages": [
{
"type": "thumbnail",
"uri": "/_images/thumbnail_tutorial_fermionic_operators.png"
},
{
"type": "large_thumbnail",
"uri": "/_static/large_demo_thumbnails/thumbnail_large_fermionic_operators.png"
},
{
"type": "hero_image",
"uri": "/_static/hero_illustrations/fermionic_ops_hero.png"
}
],
"seoDescription": "Construct Hamiltonians and other observables using fermionic creation and annihilation operators.",
"doi": "",
"canonicalURL": "/qml/demos/tutorial_fermionic_operators",
"references": [
{
"id": "surjan",
"title": "Second Quantized Approach to Quantum Chemistry",
"authors": "Peter R. Surjan",
"year": "1989",
"publisher": "Springer-Verlag",
"doi": "",
"url": ""
}
],
"basedOnPapers": [],
"referencedByPapers": [],
"relatedContent": [
{
"type": "demonstration",
"id": "tutorial_quantum_chemistry",
"weight": 1.0
},
{
"type": "demonstration",
"id": "tutorial_vqe",
"weight": 1.0
}
]
}
Loading