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

QA PRs checking process for PL 0.40 during feature freeze #6775

Merged
merged 21 commits into from
Jan 9, 2025
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Fixes to capture module part 1
PietropaoloFrisoni committed Jan 8, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 2e542d0d23713575abd4273653b99fd317b35bd0
2 changes: 1 addition & 1 deletion doc/code/qml_noise.rst
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ noise-related metadata can also be supplied to construct a noise model using:
~NoiseModel

Each conditional in the ``model_map`` (and ``meas_map``) evaluates the gate operations
(and terminal measurments) in the quantum circuit based on some condition of its attributes
(and terminal measurements) in the quantum circuit based on some condition of its attributes
(e.g., type, parameters, wires, etc.) and uses the corresponding callable to apply the
noise operations, using the user-provided metadata (e.g., hardware topologies or relaxation
times), whenever the condition is true. A noise model, once built, can be attached
2 changes: 1 addition & 1 deletion pennylane/devices/default_clifford.py
Original file line number Diff line number Diff line change
@@ -579,7 +579,7 @@ def simulate(
tableau_simulator.do_circuit(stim_circuit)
global_phase = qml.GlobalPhase(qml.math.sum(op.data[0] for op in global_phase_ops))

# Perform measurments based on whether shots are provided
# Perform measurements based on whether shots are provided
if circuit.shots:
meas_results = self.measure_statistical(circuit, stim_circuit, seed=seed)
else:
2 changes: 1 addition & 1 deletion pennylane/devices/device_api.py
Original file line number Diff line number Diff line change
@@ -655,7 +655,7 @@ def execute(
>>> dev.execute([tape])
(array(1.0),)

If the script has multiple measurments, then the device should return a tuple of measurements.
If the script has multiple measurements, then the device should return a tuple of measurements.

>>> tape = qml.tape.QuantumTape(measurements=[qml.expval(qml.Z(0)), qml.probs(wires=(0,1))])
>>> tape.shape(dev)
5 changes: 3 additions & 2 deletions pennylane/tape/plxpr_conversion.py
Original file line number Diff line number Diff line change
@@ -60,8 +60,9 @@ def f(x):
return qml.probs(wires=0), qml.expval(qml.Z(1))

>>> from pennylane.tape.plxpr_conversion import CollectOpsandMeas
>>> from jax import make_jaxpr
>>> qml.capture.enable()
>>> plxpr = jax.make_plxpr(f)(0.5)
>>> plxpr = make_jaxpr(f)(0.5)
>>> collector = CollectOpsandMeas()
>>> collector.eval(plxpr.jaxpr, plxpr.consts, 1.2)
[probs(wires=[0]), expval(Z(1))]
@@ -223,7 +224,7 @@ def f(x):
qml.capture.enable()

plxpr = jax.make_jaxpr(f)(0.5)
tape = qml.capture.convert_to_tape(plxpr.jaxpr, plxpr.consts, 1.2)
tape = qml.tape.plxpr_to_tape(plxpr.jaxpr, plxpr.consts, 1.2)
print(qml.drawer.tape_text(tape, decimals=2))

.. code-block::
10 changes: 5 additions & 5 deletions pennylane/workflow/_capture_qnode.py
Original file line number Diff line number Diff line change
@@ -27,12 +27,12 @@
and reshape the outputs from measurements on the device when multiple measurements are present.

**Gradients other than default qubit backprop**. We managed to get backprop of default qubit for
free, but no other gradients methods have support yet.
free, but no other gradient methods have support yet.

**MCM methods other than single branch statistics**. Mid circuit measurements
**MCM methods other than single branch statistics**. Mid-circuit measurements
are only handled via a "single branch statistics" algorithm, which will lead to unexpected
results. Even on analytic devices, one branch will be randomly chosen on each execution.
Returning measurements based on mid circuit measurements, ``qml.sample(m0)``,
Returning measurements based on mid-circuit measurements, ``qml.sample(m0)``,
is also not yet supported on default qubit or lightning.

>>> @qml.qnode(qml.device('default.qubit', wires=1))
@@ -76,8 +76,8 @@
2. (self: pennylane_lightning.lightning_qubit_ops.StateVectorC128, arg0: list[int], arg1: list[bool], arg2: list[int], arg3: bool, arg4: list[float]) -> None

**Grouping commuting measurements and/or splitting up non-commuting measurements.** Currently, each
measurment is fully independent and generated from different raw samples than every other measurement.
To generate multiple measurments from the same samples, we need a way of denoting which measurements
measurement is fully independent and generated from different raw samples than every other measurement.
To generate multiple measurement from the same samples, we need a way of denoting which measurements
should be taken together. A "Combination measurement process" higher order primitive, or something like it.
We will also need to figure out how to implement splitting up a circuit with non-commuting measurements into
multiple circuits.
2 changes: 1 addition & 1 deletion pennylane/workflow/return_types_spec.rst
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Empty Wires
^^^^^^^^^^^

Some measurments allow broadcasting over all available wires, like ``qml.probs()``, ``qml.sample()``,
Some measurements allow broadcasting over all available wires, like ``qml.probs()``, ``qml.sample()``,
or ``qml.state()``. In such a case, the measurement process instance should have empty wires.
The shape of the result object may be dictated either by the device or the other operations present in the circuit.

2 changes: 1 addition & 1 deletion tests/capture/test_base_interpreter.py
Original file line number Diff line number Diff line change
@@ -188,7 +188,7 @@ def f():


def test_measurement_handling():
"""Test that the default measurment handling works."""
"""Test that the default measurement handling works."""

@SimplifyInterpreter()
def f(w):
2 changes: 1 addition & 1 deletion tests/drawer/test_drawer_utils.py
Original file line number Diff line number Diff line change
@@ -220,7 +220,7 @@ def test_single_measure_single_cond(self):
assert wires == [[0, 0]]

def test_multiple_measure_multiple_cond(self):
"""Test a case with multiple measurments and multiple conditionals."""
"""Test a case with multiple measurements and multiple conditionals."""
m0 = qml.measure(0)
m1 = qml.measure(1)
m2_nonused = qml.measure(2)
2 changes: 1 addition & 1 deletion tests/workflow/interfaces/test_jacobian_products.py
Original file line number Diff line number Diff line change
@@ -273,7 +273,7 @@ def test_batch_vjp(self, jpc, shots):
pytest.skip("jpc does not work with finite shots.")
if jpc is hadamard_grad_jpc and qml.measurements.Shots(shots).has_partitioned_shots:
pytest.skip(
"hadamard gradient does not support multiple measurments with partitioned shots."
"hadamard gradient does not support multiple measurements with partitioned shots."
)

x = 0.385