Skip to content

Commit

Permalink
Update dev with master (#1165)
Browse files Browse the repository at this point in the history
## Changes
- Update `dev` with `master`

---------

Co-authored-by: Astral Cai <[email protected]>
Co-authored-by: GitHub Nightly Merge Action <[email protected]>
Co-authored-by: Mudit Pandey <[email protected]>
Co-authored-by: Christina Lee <[email protected]>
Co-authored-by: Romain Moyard <[email protected]>
Co-authored-by: Matthew Silverman <[email protected]>
Co-authored-by: lillian542 <[email protected]>
Co-authored-by: Tom Bromley <[email protected]>
Co-authored-by: Josh Izaac <[email protected]>
Co-authored-by: Rashid N H M <[email protected]>
Co-authored-by: Guillermo Alonso-Linaje <[email protected]>
Co-authored-by: soranjh <[email protected]>
Co-authored-by: CatalinaAlbornoz <[email protected]>
Co-authored-by: Jay Soni <[email protected]>
Co-authored-by: soranjh <[email protected]>
Co-authored-by: ixfoduap <[email protected]>
Co-authored-by: Diego <[email protected]>
Co-authored-by: Utkarsh <[email protected]>
Co-authored-by: Stepan Fomichev <[email protected]>
Co-authored-by: soranjh <[email protected]>
Co-authored-by: Alvaro Ballon <[email protected]>
Co-authored-by: Diego <[email protected]>
Co-authored-by: Lee J. O'Riordan <[email protected]>
Co-authored-by: Korbinian Kottmann <[email protected]>
Co-authored-by: DanielNino27 <[email protected]>
Co-authored-by: Paul Finlay <[email protected]>
Co-authored-by: Mikhail Andrenkov <[email protected]>
Co-authored-by: David Wierichs <[email protected]>
Co-authored-by: Diksha Dhawan <[email protected]>
Co-authored-by: Ivana Kurečić <[email protected]>
Co-authored-by: Gopal Ramesh Dahale <[email protected]>
Co-authored-by: Sankalp Sanand <[email protected]>
Co-authored-by: Ivana Kurečić <[email protected]>
Co-authored-by: Austin Huang <[email protected]>
Co-authored-by: Isaac De Vlugt <[email protected]>
Co-authored-by: Michael Vu <[email protected]>
Co-authored-by: WrathfulSpatula <[email protected]>
Co-authored-by: Olivia Di Matteo <[email protected]>
Co-authored-by: Pietropaolo Frisoni <[email protected]>
Co-authored-by: Ahmed Darwish <[email protected]>
Co-authored-by: Isaac De Vlugt <[email protected]>
  • Loading branch information
Show file tree
Hide file tree
Showing 18 changed files with 3,206 additions and 2,467 deletions.
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.
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.
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.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
"basedOnPapers": [],
"referencedByPapers": [],
"relatedContent": [
{
"type": "demonstration",
"id": "tutorial_guide_to_pennylane_knowing_qiskit",
"weight": 1.0
},
{
"type": "demonstration",
"id": "tutorial_qubit_rotation",
Expand Down
4 changes: 2 additions & 2 deletions demonstrations/tutorial_error_mitigation.metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}
],
"dateOfPublication": "2021-11-29T00:00:00+00:00",
"dateOfLastModification": "2024-07-10T00:00:00+00:00",
"dateOfLastModification": "2024-07-17T00:00:00+00:00",
"categories": [
"Algorithms",
"Quantum Computing"
Expand Down Expand Up @@ -76,4 +76,4 @@
"weight": 1.0
}
]
}
}
46 changes: 31 additions & 15 deletions demonstrations/tutorial_error_mitigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def circuit(w1, w2):
##############################################################################
# First, we'll visualize the circuit:

print(qml.draw(ideal_qnode, expansion_strategy="device")(w1, w2))
print(qml.draw(ideal_qnode, level="device")(w1, w2))

##############################################################################
# As expected, executing the circuit on an ideal noise-free device gives a result of ``1``.
Expand Down Expand Up @@ -153,7 +153,9 @@ def circuit(w1, w2):
extrapolate = RichardsonFactory.extrapolate
scale_factors = [1, 2, 3]

mitigated_qnode = mitigate_with_zne(noisy_qnode, scale_factors, fold_global, extrapolate)
mitigated_qnode = mitigate_with_zne(
noisy_qnode, scale_factors, fold_global, extrapolate
)
mitigated_qnode(w1, w2)

##############################################################################
Expand Down Expand Up @@ -195,10 +197,12 @@ def circuit(w1, w2):
# :class:`QuantumTape <pennylane.tape.QuantumTape>`, which provides a low-level approach for circuit
# construction in PennyLane.

circuit = qml.tape.QuantumTape([
template(w1, w2, wires=range(n_wires)),
qml.adjoint(template(w1, w2, wires=range(n_wires)))
])
circuit = qml.tape.QuantumTape(
[
template(w1, w2, wires=range(n_wires)),
qml.adjoint(template(w1, w2, wires=range(n_wires))),
]
)

##############################################################################
# Don't worry, in most situations you will not need to work with a PennyLane
Expand Down Expand Up @@ -259,7 +263,9 @@ def executor(circuits, dev=dev_noisy):

# Loop through circuits and add on measurement
for c in circuits:
circuit_with_meas = qml.tape.QuantumTape(c.operations, [qml.expval(qml.PauliZ(0))])
circuit_with_meas = qml.tape.QuantumTape(
c.operations, [qml.expval(qml.PauliZ(0))]
)
circuits_with_meas.append(circuit_with_meas)

return qml.execute(circuits_with_meas, dev, gradient_fn=None)
Expand Down Expand Up @@ -354,7 +360,9 @@ def executor(circuits, dev=dev_noisy):

extrapolate = RichardsonFactory.extrapolate

mitigated_qnode = mitigate_with_zne(noisy_qnode, scale_factors, folding, extrapolate, reps_per_factor=100)
mitigated_qnode = mitigate_with_zne(
noisy_qnode, scale_factors, folding, extrapolate, reps_per_factor=100
)

mitigated_qnode(w1, w2)

Expand All @@ -366,7 +374,11 @@ def executor(circuits, dev=dev_noisy):
# circuits are all folded with a scale factor of :math:`s=1.1`:

for _ in range(3):
print(qml.drawer.tape_text(folding(circuit, scale_factor=1.1), decimals=2, max_length=80))
print(
qml.drawer.tape_text(
folding(circuit, scale_factor=1.1), decimals=2, max_length=80
)
)

##############################################################################
# To accommodate for this randomness, we can perform multiple repetitions of random folding for a
Expand Down Expand Up @@ -418,8 +430,8 @@ def executor(circuits, dev=dev_noisy):
# hardware. Suppose we want to simulate the ``ibmq_lima`` hardware device available on IBMQ. We
# can load a noise model that represents this device using:

from qiskit.providers.fake_provider import FakeLima
from qiskit.providers.aer.noise import NoiseModel
from qiskit_ibm_runtime.fake_provider import FakeLima
from qiskit_aer.noise import NoiseModel

backend = FakeLima()
noise_model = NoiseModel.from_backend(backend)
Expand Down Expand Up @@ -500,7 +512,11 @@ def qchem_circuit(phi):
H, _ = qchem.molecular_hamiltonian(molecule)

# Define ansatz circuit
ops = [qml.PauliX(0), qml.PauliX(1), qml.DoubleExcitation(phi, wires=range(n_wires))]
ops = [
qml.PauliX(0),
qml.PauliX(1),
qml.DoubleExcitation(phi, wires=range(n_wires)),
]
circuit = qml.tape.QuantumTape(ops)

# Define custom executor that expands Hamiltonian measurement
Expand All @@ -515,8 +531,8 @@ def executor(circuit):
# of Pauli operators. We get a list of circuits to execute
# and a postprocessing function to combine the results into
# a single number.
circuits, postproc = qml.transforms.hamiltonian_expand(
circuit_with_meas, group=False
circuits, postproc = qml.transforms.split_non_commuting(
circuit_with_meas, grouping_strategy=None
)
circuits_executed = qml.execute(circuits, dev_noisy, gradient_fn=None)
return postproc(circuits_executed)
Expand Down Expand Up @@ -575,4 +591,4 @@ def executor(circuit):
# -----------------
# .. include:: ../_static/authors/thomas_bromley.txt
#
# .. include:: ../_static/authors/andrea_mari.txt
# .. include:: ../_static/authors/andrea_mari.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}
],
"dateOfPublication": "2020-08-24T00:00:00+00:00",
"dateOfLastModification": "2024-01-01T00:00:00+00:00",
"dateOfLastModification": "2024-07-22T00:00:00+00:00",
"categories": [
"Quantum Machine Learning"
],
Expand Down Expand Up @@ -46,4 +46,4 @@
"weight": 1.0
}
]
}
}
Loading

0 comments on commit efe55a7

Please sign in to comment.