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

Add qml.workflow.construct_execution_config(qnode)(*args,**kwargs) #6901

Merged
merged 26 commits into from
Jan 30, 2025
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
891e4c8
initial commit
andrijapau Jan 29, 2025
385e6de
add example to docstring
andrijapau Jan 29, 2025
7669ab6
add type hinting
andrijapau Jan 29, 2025
2552bff
doc: changelog
andrijapau Jan 29, 2025
21daa92
Update pennylane/workflow/construct_execution_config.py
andrijapau Jan 29, 2025
11416b1
Update pennylane/workflow/construct_execution_config.py
andrijapau Jan 29, 2025
45b8630
Update pennylane/workflow/construct_execution_config.py
andrijapau Jan 29, 2025
fed1b2b
address Christina's review
andrijapau Jan 29, 2025
2191a10
Merge branch 'add-construct-exec-config' of github.com:PennyLaneAI/pe…
andrijapau Jan 29, 2025
618b396
refactor
andrijapau Jan 29, 2025
1c8290d
revert bc of circular imports
andrijapau Jan 29, 2025
db9a05f
doc: Update __init__.py for workflow
andrijapau Jan 29, 2025
683027e
doc: Fix docstring for sphinx
andrijapau Jan 29, 2025
152d484
remove pprint from code block
andrijapau Jan 29, 2025
63b1bdc
fix: Update execution.py typing hinting
andrijapau Jan 29, 2025
2e570f7
fix: Update execution.py typing hinting
andrijapau Jan 29, 2025
3204aa6
fix: Update docstring
andrijapau Jan 29, 2025
0aa70ae
fix: Update docstring
andrijapau Jan 29, 2025
c36afb4
Trigger CI
andrijapau Jan 29, 2025
f547bc8
fix: Update docstring
andrijapau Jan 29, 2025
368eb16
update interface as well in resolve_execution_config
andrijapau Jan 29, 2025
88459b4
update changelog as well
andrijapau Jan 29, 2025
07f3ca1
remove __str__
andrijapau Jan 30, 2025
90e36cf
Merge branch 'master' into add-construct-exec-config
andrijapau Jan 30, 2025
d914f24
Merge branch 'master' into add-construct-exec-config
andrijapau Jan 30, 2025
ca14f0e
Merge branch 'master' into add-construct-exec-config
andrijapau Jan 30, 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
Prev Previous commit
Next Next commit
fix: Update docstring
andrijapau committed Jan 29, 2025
commit 0aa70ae6ff31ef87e910dbaff22bca3742a65846
10 changes: 6 additions & 4 deletions pennylane/workflow/construct_execution_config.py
Original file line number Diff line number Diff line change
@@ -34,19 +34,21 @@ def construct_execution_config(qnode: "qml.QNode", resolve: bool = True):

.. code-block:: python

import pennylane as qml

@qml.qnode(qml.device("default.qubit", wires=1))
def circuit(x):
qml.RX(x, 0)
return qml.expval(qml.Z(0))

First, let's import ``pprint`` to make it easier to read the execution configuration objects.

>>> from pprint import pprint

If we wish to construct an unresolved execution configuration, we can specify
``resolve=False``. This will leave properties like ``gradient_method`` and ``interface``
in their unrefined state (e.g. ``"best"`` or ``"auto"`` respectively).

>>> config = qml.workflow.construct_execution_config(circuit, resolve=False)(1)
>>> pprint.pprint(config)
>>> pprint(config)
ExecutionConfig(grad_on_execution=None,
use_device_gradient=None,
use_device_jacobian_product=False,
@@ -62,7 +64,7 @@ def circuit(x):
given ``QNode`` configuration that was provided,

>>> resolved_config = qml.workflow.construct_execution_config(circuit, resolve=True)(1)
>>> pprint.pprint(resolved_config)
>>> pprint(resolved_config)
ExecutionConfig(grad_on_execution=False,
use_device_gradient=True,
use_device_jacobian_product=False,