Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c3b4d1f
PLDW in kwargs
JerryChen97 Jul 17, 2025
10ab7d5
log?
JerryChen97 Jul 17, 2025
34a8fea
rst
JerryChen97 Jul 17, 2025
b61fe37
mf
JerryChen97 Jul 18, 2025
434353a
rm the PLDW in init to allow user qfunc definition using shots=
JerryChen97 Jul 18, 2025
9fd697b
adjust tests
JerryChen97 Jul 18, 2025
d4a71e0
Merge branch 'master' into shots-decoupling/deprecate_qnode_call_shots
JerryChen97 Jul 18, 2025
70a01cd
Update pennylane/workflow/qnode.py
JerryChen97 Jul 21, 2025
2cd7ce6
Merge branch 'master' into shots-decoupling/deprecate_qnode_call_shots
JerryChen97 Jul 21, 2025
ee96313
correct the deprecation logic
JerryChen97 Jul 21, 2025
cdde1eb
fix test_default_qubit.py
JerryChen97 Jul 21, 2025
5c5506e
Merge branch 'master' into shots-decoupling/deprecate_qnode_call_shots
JerryChen97 Jul 21, 2025
d0c159d
debug
JerryChen97 Jul 21, 2025
55fbdd0
dynamic shots available now
JerryChen97 Jul 21, 2025
813af2d
debug three files
JerryChen97 Jul 21, 2025
95668ff
wish no tensorflow in paradise
JerryChen97 Jul 21, 2025
4290b81
fix jax qnode
JerryChen97 Jul 21, 2025
f86037e
some leftover
JerryChen97 Jul 21, 2025
2a9a3f2
fix qcut
JerryChen97 Jul 21, 2025
0100ba4
debugging test debugging
JerryChen97 Jul 21, 2025
b352122
qcut leftover
JerryChen97 Jul 21, 2025
0cd3186
legacy
JerryChen97 Jul 21, 2025
f92c0d2
Fix optimize issue
JerryChen97 Jul 21, 2025
812feb7
fix defer measurement
JerryChen97 Jul 21, 2025
b79d8ac
rm unused partial
JerryChen97 Jul 21, 2025
049f4a1
fix two more
JerryChen97 Jul 21, 2025
8c4d7ce
try import from workflow?
JerryChen97 Jul 21, 2025
dd000f4
Merge branch 'master' into shots-decoupling/deprecate_qnode_call_shots
JerryChen97 Jul 22, 2025
2f7c206
Update pennylane/workflow/qnode.py
JerryChen97 Jul 22, 2025
5a1c6b9
Apply suggestions from code review
JerryChen97 Jul 22, 2025
841212e
remove a test that's essentially legacy test
JerryChen97 Jul 22, 2025
ee4b276
update msg tsrings
JerryChen97 Jul 22, 2025
bc27fd9
dont' xfail
JerryChen97 Jul 22, 2025
2a164a6
no xfail 2
JerryChen97 Jul 22, 2025
0856455
Merge branch 'master' into shots-decoupling/deprecate_qnode_call_shots
JerryChen97 Jul 22, 2025
b6a4119
Merge branch 'master' into shots-decoupling/deprecate_qnode_call_shots
JerryChen97 Jul 22, 2025
10c0aa2
Merge branch 'master' into shots-decoupling/deprecate_qnode_call_shots
JerryChen97 Jul 23, 2025
25aadaa
Merge branch 'master' into shots-decoupling/deprecate_qnode_call_shots
JerryChen97 Jul 23, 2025
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
6 changes: 6 additions & 0 deletions doc/development/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ deprecations are listed below.
Pending deprecations
--------------------

* ``shots=`` in ``QNode`` calls is deprecated and will be removed in v0.44.
Instead, please use the ``qml.workflow.set_shots`` transform to set the number of shots for a ``QNode``.

- Deprecated in v0.43
- Will be removed in v0.44

* ``qml.qnn.cost.SquaredErrorLoss`` is deprecated and will be removed in version v0.44. Instead, this hybrid workflow can be accomplished
with a function like ``loss = lambda *args: (circuit(*args) - target)**2``.

Expand Down
4 changes: 4 additions & 0 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@

<h3>Deprecations 👋</h3>

* `shots=` in `QNode` calls is deprecated and will be removed in v0.44.
Instead, please use the `qml.workflow.set_shots` transform to set the number of shots for a QNode.
[(#7906)](https://github.com/PennyLaneAI/pennylane/pull/7906)

* The `level=None` argument in the :func:`pennylane.workflow.get_transform_program`, :func:`pennylane.workflow.construct_batch`, `qml.draw`, `qml.draw_mpl`, and `qml.specs` transforms is deprecated and will be removed in v0.43.
Please use `level='device'` instead to apply the noise model at the device level.
[(#7886)](https://github.com/PennyLaneAI/pennylane/pull/7886)
Expand Down
4 changes: 4 additions & 0 deletions pennylane/workflow/qnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,10 @@ def construct(self, args, kwargs) -> qml.tape.QuantumScript:
"""Call the quantum function with a tape context, ensuring the operations get queued."""
kwargs = copy.copy(kwargs)
if "shots" in kwargs and self._shots_override_device:
warnings.warn(
"'shots' as an argument to the quantum function is deprecated and will be removed in v0.44. ",
PennyLaneDeprecationWarning,
)
_kwargs_shots = kwargs.pop("shots")
warnings.warn(
"Both 'shots=' parameter and 'set_shots' transform are specified. "
Expand Down
17 changes: 9 additions & 8 deletions tests/test_qnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -2055,11 +2055,15 @@ def circuit():

# Then try to pass shots parameter when calling the QNode
with pytest.warns(
UserWarning,
match="Both 'shots=' parameter and 'set_shots' transform are specified. "
"The transform will take precedence over",
PennyLaneDeprecationWarning,
match="'shots' as an argument to the quantum function is deprecated",
):
result = modified_circuit(shots=25)
with pytest.warns(
UserWarning,
match="Both 'shots=' parameter and 'set_shots' transform are specified. "
"The transform will take precedence over",
):
result = modified_circuit(shots=25)

# Verify that the set_shots value (50) was used, not the parameter value (25)
assert len(result) == 50
Expand Down Expand Up @@ -2332,8 +2336,5 @@ def circuit():
return qml.sample(qml.PauliZ(0))

# No warning should be raised when calling with the same shots value
with pytest.warns(
UserWarning, match="Both 'shots=' parameter and 'set_shots' transform are specified."
):
result = circuit.update(diff_method="parameter-shift")(shots=50)
result = circuit.update(diff_method="parameter-shift")()
assert len(result) == 100