Skip to content

Commit

Permalink
Merge branch 'dev' into joeycarter/qjit-grovers-algo-with-catalyst
Browse files Browse the repository at this point in the history
  • Loading branch information
joeycarter authored Nov 1, 2024
2 parents 92c05f3 + 9cd9d67 commit 520e1b1
Show file tree
Hide file tree
Showing 40 changed files with 271 additions and 231 deletions.
29 changes: 23 additions & 6 deletions .github/workflows/update-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,29 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.NIGHTLY_TOKEN }}
fetch-depth: 0 # We want entire git-history to avoid any merge conflicts

- name: Nightly Merge
uses: robotology/[email protected]
with:
stable_branch: 'master'
development_branch: 'dev'
allow_ff: false
env:
GITHUB_TOKEN: ${{ secrets.NIGHTLY_TOKEN }}
CONFIG_USERNAME: GitHub Nightly Merge Action
CONFIG_EMAIL: [email protected]
MERGE_HEAD: master
MERGE_BASE: dev
MERGE_ARGS: --no-ff --allow-unrelated-histories --no-edit
run: |
# This script is adapted from the robotology/[email protected] GitHub action:
# https://github.com/robotology/gh-action-nightly-merge/blob/master/entrypoint.sh
git config --global user.name "$CONFIG_USERNAME"
git config --global user.email "$CONFIG_EMAIL"
git fetch origin $MERGE_HEAD
(git checkout $MERGE_HEAD && git pull origin $MERGE_HEAD)
git fetch origin $MERGE_BASE
(git checkout $MERGE_BASE && git pull origin $MERGE_BASE)
git merge $MERGE_ARGS $MERGE_HEAD
git push origin $MERGE_BASE
4 changes: 2 additions & 2 deletions demonstrations/quantum_volume.metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"title": "Quantum volume",
"authors": [
{
"id": "olivia_di_matteo"
"username": "glassnotes"
}
],
"dateOfPublication": "2020-12-15T00:00:00+00:00",
"dateOfLastModification": "2024-10-07T00:00:00+00:00",
"dateOfLastModification": "2024-10-11T00:00:00+00:00",
"categories": [
"Quantum Hardware",
"Quantum Computing"
Expand Down
5 changes: 0 additions & 5 deletions demonstrations/quantum_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,8 +888,3 @@ def heavy_output_set(m, probs):
# and Operating Systems (pp. 1001–1014)
# (2019). <https://dl.acm.org/doi/10.1145/3297858.3304023>`__ New York, NY,
# USA: Association for Computing Machinery.
#
#
# About the author
# ----------------
# .. include:: ../_static/authors/olivia_di_matteo.txt
3 changes: 2 additions & 1 deletion demonstrations/tutorial_QUBO.metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@
"basedOnPapers": [],
"referencedByPapers": [],
"relatedContent": [
]
],
"discussionForumUrl": "https://discuss.pennylane.ai/t/quadratic-unconstrained-binary-optimization-qubo-demo/7339"
}
4 changes: 2 additions & 2 deletions demonstrations/tutorial_barren_plateaus.metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"title": "Barren plateaus in quantum neural networks",
"authors": [
{
"id": "shahnawaz_ahmed"
"username": "quantshah"
}
],
"dateOfPublication": "2019-10-11T00:00:00+00:00",
"dateOfLastModification": "2024-10-07T00:00:00+00:00",
"dateOfLastModification": "2024-10-15T00:00:00+00:00",
"categories": [
"Optimization"
],
Expand Down
7 changes: 4 additions & 3 deletions demonstrations/tutorial_classical_shadows.metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"title": "Classical shadows",
"authors": [
{
"id": "roeland_wiersema"
"username": "therooler"
},
{
"id": "brian_doolittle"
}
],
"dateOfPublication": "2021-06-14T00:00:00+00:00",
"dateOfLastModification": "2024-10-07T00:00:00+00:00",
"dateOfLastModification": "2024-10-14T00:00:00+00:00",
"categories": [
"Algorithms"
],
Expand Down Expand Up @@ -69,5 +69,6 @@
"id": "tutorial_quantum_metrology",
"weight": 1.0
}
]
],
"discussionForumUrl": "https://discuss.pennylane.ai/t/classical-shadows-in-calculating-fidelity/3727"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"title": "Data-reuploading classifier",
"authors": [
{
"id": "shahnawaz_ahmed"
"username": "quantshah"
}
],
"dateOfPublication": "2019-10-11T00:00:00+00:00",
"dateOfLastModification": "2024-10-07T00:00:00+00:00",
"dateOfLastModification": "2024-10-15T00:00:00+00:00",
"categories": [
"Quantum Machine Learning"
],
Expand Down
14 changes: 8 additions & 6 deletions demonstrations/tutorial_diffable-mitigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
Thus, we can improve the estimates of observables without breaking the differentiable workflow of our variational algorithm.
We will briefly introduce these functionalities and afterwards go more in depth to explore what happens under the hood.
We start by initializing a noisy device under the :class:`~.pennylane.DepolarizingChannel`:
We start by initializing a noisy device using a noise model with :class:`~.pennylane.DepolarizingChannel` errors:
"""

import pennylane as qml
Expand All @@ -54,13 +54,14 @@
n_wires = 4
np.random.seed(1234)

# Describe noise
noise_gate = qml.DepolarizingChannel
noise_strength = 0.05
# Describe noise model
fcond = qml.noise.wires_in(range(n_wires))
noise = qml.noise.partial_wires(qml.DepolarizingChannel, 0.05)
noise_model = qml.NoiseModel({fcond: noise})

# Load devices
dev_ideal = qml.device("default.mixed", wires=n_wires)
dev_noisy = qml.transforms.insert(dev_ideal, noise_gate, noise_strength, position="all")
dev_noisy = qml.add_noise(dev_ideal, noise_model=noise_model)

##############################################################################
# We are going to use the transverse field Ising model Hamiltonian :math:`H = - \sum_i X_i X_{i+1} + 0.5 \sum_i Z_i` as our observable:
Expand All @@ -85,8 +86,9 @@ def qfunc(w1, w2):
qml.SimplifiedTwoDesign(w1, w2, wires=range(n_wires))
return qml.expval(H)

qnode_noisy = qml.QNode(qfunc, dev_noisy)
qnode_ideal = qml.QNode(qfunc, dev_ideal)
qnode_noisy = qml.QNode(qfunc, dev_noisy)
qnode_noisy = qml.transforms.decompose(qnode_noisy, gate_set = ["RY", "CZ"])

##############################################################################
# We can then simply transform the noisy QNode :math:`f^{⚡}` with :func:`~.pennylane.transforms.mitigate_with_zne` to generate :math:`\tilde{f}.`
Expand Down
4 changes: 2 additions & 2 deletions demonstrations/tutorial_eqnn_force_field.metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"title": "Symmetry-invariant quantum machine learning force fields",
"authors": [
{
"id": "oriel_kiss"
"username": "orielkiss"
},
{
"id": "isabel_nha_minh_le"
}
],
"dateOfPublication": "2024-03-12T00:00:00+00:00",
"dateOfLastModification": "2024-10-07T00:00:00+00:00",
"dateOfLastModification": "2024-10-15T00:00:00+00:00",
"categories": [
"Quantum Machine Learning",
"Quantum Chemistry"
Expand Down
35 changes: 21 additions & 14 deletions demonstrations/tutorial_error_mitigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,31 +49,35 @@
Mitigating noise in a simple circuit
------------------------------------
We first need a noisy device to execute our circuit on. Let's keep things simple for now by loading
the :mod:`default.mixed <pennylane.devices.default_mixed>` simulator and artificially adding
:class:`PhaseDamping <pennylane.PhaseDamping>` noise.
We first need a noisy device to execute our circuit on. Let's keep things simple
for now by loading the :mod:`default.mixed <pennylane.devices.default_mixed>` simulator
and artificially adding :class:`PhaseDamping <pennylane.PhaseDamping>` noise using a
:class:`NoiseModel <pennylane.NoiseModel>`.
"""

import pennylane as qml

n_wires = 4

# Describe noise
noise_gate = qml.PhaseDamping
noise_strength = 0.1
# Describe noise model
fcond = qml.noise.wires_in(range(n_wires))
noise = qml.noise.partial_wires(qml.PhaseDamping, 0.1)
noise_model = qml.NoiseModel({fcond: noise})

# Load devices
dev_ideal = qml.device("default.mixed", wires=n_wires)
dev_noisy = qml.transforms.insert(dev_ideal, noise_gate, noise_strength)
dev_noisy = qml.add_noise(dev_ideal, noise_model=noise_model)

###############################################################################
# In the above, we load a noise-free device ``dev_ideal`` and a noisy device ``dev_noisy``, which
# is constructed from the :func:`qml.transforms.insert <pennylane.transforms.insert>` transform.
# This transform works by intercepting each circuit executed on the device and adding the
# :class:`PhaseDamping <pennylane.PhaseDamping>` noise channel directly after every gate in the
# circuit. To get a better understanding of noise channels like
# :class:`PhaseDamping <pennylane.PhaseDamping>`, check out the :doc:`tutorial_noisy_circuits`
# tutorial.
# In the above, we load a noise-free device ``dev_ideal`` and a noisy device ``dev_noisy``,
# which is constructed from the :func:`qml.add_noise <pennylane.transforms.add_noise>`
# transform. This transform works by intercepting each circuit executed on the device and
# adding the noise to it based on the ``noise_model``. For example, in this case, it will
# add :class:`PhaseDamping <pennylane.PhaseDamping>` noise channel after every gate in the
# circuit acting on wires :math:`[0, 1, 2, 3]`. To get a better understanding of noise
# channels like :class:`PhaseDamping <pennylane.PhaseDamping>` and using noise models,
# check out the :doc:`tutorial_noisy_circuits` and :doc:`tutorial_how_to_use_noise_models`
# tutorials, respectively.
#
# The next step is to define our circuit. Inspired by the mirror circuits concept introduced by
# Proctor *et al.* [#proctor2020measuring]_ let's fix a circuit that applies a unitary :math:`U`
Expand Down Expand Up @@ -112,6 +116,7 @@ def circuit(w1, w2):

ideal_qnode = qml.QNode(circuit, dev_ideal)
noisy_qnode = qml.QNode(circuit, dev_noisy)
noisy_qnode = qml.transforms.decompose(noisy_qnode, gate_set = ["RY", "CZ"])

##############################################################################
# First, we'll visualize the circuit:
Expand Down Expand Up @@ -490,6 +495,7 @@ def qchem_circuit(phi):

ideal_energy = qml.QNode(qchem_circuit, dev_ideal)
noisy_energy = qml.QNode(qchem_circuit, dev_noisy)
noisy_energy = qml.transforms.decompose(noisy_energy, gate_set=["RX", "RY", "RZ", "CNOT"])

ideal_energies.append(ideal_energy(phi))
noisy_energies.append(noisy_energy(phi))
Expand Down Expand Up @@ -517,6 +523,7 @@ def qchem_circuit(phi):
qml.DoubleExcitation(phi, wires=range(n_wires)),
]
circuit = qml.tape.QuantumTape(ops)
[circuit], _ = qml.transforms.decompose(circuit, gate_set=["RX", "RY", "RZ", "CNOT"])

# Define custom executor that expands Hamiltonian measurement
# into a linear combination of tensor products of Pauli
Expand Down
2 changes: 1 addition & 1 deletion demonstrations/tutorial_fermionic_operators.metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}
],
"dateOfPublication": "2023-06-27T00:00:00+00:00",
"dateOfLastModification": "2024-10-07T00:00:00+00:00",
"dateOfLastModification": "2024-10-30T00:00:00+00:00",
"categories": [
"Quantum Chemistry"
],
Expand Down
6 changes: 3 additions & 3 deletions demonstrations/tutorial_fermionic_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@

fermi_word = a0_dag * a1
fermi_sentence = 1.3 * a0_dag * a1 + 2.4 * a1
fermi_sentence
print(fermi_sentence)

##############################################################################
# In this simple example, we first created the operator :math:`a^{\dagger}_0 a_1` and then created
# the linear combination :math:`1.3 a^{\dagger}_0 a_1 + 2.4 a_1.` We can also perform
# arithmetic operations between Fermi words and Fermi sentences.

fermi_sentence = fermi_sentence * fermi_word + 2.3 * fermi_word
fermi_sentence
print(fermi_sentence)

##############################################################################
# Beyond multiplication, summation, and subtraction, we can exponentiate fermionic operators in
Expand All @@ -61,7 +61,7 @@
# in the same way that you would write down the operator on a piece of paper:

fermi_sentence = 1.2 * a0_dag + 0.5 * a1 - 2.3 * (a0_dag * a1) ** 2
fermi_sentence
print(fermi_sentence)

##############################################################################
# This Fermi sentence can be mapped to the qubit basis using the
Expand Down
3 changes: 2 additions & 1 deletion demonstrations/tutorial_grovers_algorithm.metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@
"id": "tutorial_qft_arithmetics",
"weight": 1.0
}
]
],
"discussionForumUrl": "https://discuss.pennylane.ai/t/understanding-grover/3340"
}
7 changes: 4 additions & 3 deletions demonstrations/tutorial_haar_measure.metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"title": "Understanding the Haar measure",
"authors": [
{
"id": "olivia_di_matteo"
"username": "glassnotes"
}
],
"dateOfPublication": "2021-03-22T00:00:00+00:00",
"dateOfLastModification": "2024-10-07T00:00:00+00:00",
"dateOfLastModification": "2024-10-11T00:00:00+00:00",
"categories": [
"Quantum Machine Learning",
"Quantum Computing"
Expand Down Expand Up @@ -139,5 +139,6 @@
"id": "tutorial_barren_plateaus",
"weight": 1.0
}
]
],
"discussionForumUrl": "https://discuss.pennylane.ai/t/understanding-the-haar-measure-demo/7334"
}
6 changes: 1 addition & 5 deletions demonstrations/tutorial_haar_measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,8 +809,4 @@ def qr_haar_random_unitary():
# Z. Holmes, K. Sharma, M. Cerezo, and P. J. Coles (2021) "Connecting ansatz
# expressibility to gradient magnitudes and barren plateaus". (`arXiv
# <https://arxiv.org/abs/2101.02138>`__)
#
#
# About the author
# ----------------
# .. include:: ../_static/authors/olivia_di_matteo.txt
#
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"title": "Implicit differentiation of variational quantum algorithms",
"authors": [
{
"id": "shahnawaz_ahmed"
"username": "quantshah"
},
{
"id": "juan_felipe_carrasquilla_alvarez"
}
],
"dateOfPublication": "2022-11-28T00:00:00+00:00",
"dateOfLastModification": "2024-10-07T00:00:00+00:00",
"dateOfLastModification": "2024-10-15T00:00:00+00:00",
"categories": [
"Optimization"
],
Expand Down
3 changes: 2 additions & 1 deletion demonstrations/tutorial_intro_qsvt.metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,6 @@
"id": "function_fitting_qsp",
"weight": 1.0
}
]
],
"discussionForumUrl": "https://discuss.pennylane.ai/t/qsvt-algorithm-computing-the-angles-for-projector-controlled-phase-gate/3203"
}
3 changes: 2 additions & 1 deletion demonstrations/tutorial_kernel_based_training.metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
"id": "tutorial_variational_classifier",
"weight": 1.0
}
]
],
"discussionForumUrl": "https://discuss.pennylane.ai/t/kernel-based-training-demonstration/1017"
}
3 changes: 2 additions & 1 deletion demonstrations/tutorial_lcu_blockencoding.metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"id": "tutorial_apply_qsvt",
"weight": 1.0
}
]
],
"discussionForumUrl": "https://discuss.pennylane.ai/t/lcu-demo-comment/7316"
}
2 changes: 1 addition & 1 deletion demonstrations/tutorial_optimal_control.metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}
],
"dateOfPublication": "2023-08-08T00:00:00+00:00",
"dateOfLastModification": "2024-10-07T00:00:00+00:00",
"dateOfLastModification": "2024-10-30T00:00:00+00:00",
"categories": [
"Optimization",
"Quantum Computing",
Expand Down
4 changes: 2 additions & 2 deletions demonstrations/tutorial_optimal_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ def profit(params):
# Initial parameters for the start and end times of the rectangles
times = [jnp.linspace(eps, T - eps, P * 2) for op in ops_param]
# All initial parameters: small alternating amplitudes and times
params = [jnp.hstack([[0.1 * (-1) ** i for i in range(P)], time]) for time in times]
params = [jnp.hstack([jnp.array([0.1 * (-1) ** i for i in range(P)]), time]) for time in times]

#############################################################################
# Now we are all set up to train the parameters of the pulse sequence to produce
Expand Down Expand Up @@ -679,7 +679,7 @@ def profit(params):
# produced plot.

times = [jnp.linspace(eps, T - eps, P * 2) for op in ops_param]
params = [jnp.hstack([[0.2 * (-1) ** i for i in range(P)], time]) for time in times]
params = [jnp.hstack([jnp.array([0.2 * (-1) ** i for i in range(P)]), time]) for time in times]

num_steps = 1200
learning_rate = -2e-3
Expand Down
Loading

0 comments on commit 520e1b1

Please sign in to comment.