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

Collection of documentation fixes for v0.40 QA #6798

Merged
merged 15 commits into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion doc/code/qml_noise.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions doc/development/autograph.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Python control flow:

return qml.expval(qml.PauliZ(0) + qml.PauliZ(3))

While this function cannot be captured directly because there is control flow that depends on the function's inputs' values—the inputs are treated as JAX tracers at capture time, which don't have concrete valuesit can be captured by converting to native PennyLane syntax
While this function cannot be captured directly because there is control flow that depends on the values of the function's inputs (the inputs are treated as JAX tracers at capture time, which don't have concrete values) it can be captured by converting to native PennyLane syntax
via AutoGraph. This is the default behaviour of :func:`~.autograph.make_plxpr`.

>>> weights = jnp.linspace(-1, 1, 20).reshape([5, 4])
Expand Down Expand Up @@ -351,7 +351,7 @@ For example, using a ``for`` loop with static bounds to index a JAX array is str
However, indexing within a ``for`` loop with AutoGraph will require that the object indexed is
a JAX array or dynamic runtime variable.

If the array you are indexing within the for loop is not a JAX array
If the array you are indexing within the ``for`` loop is not a JAX array
or dynamic variable, an error will be raised:

>>> @qml.qnode(dev)
Expand All @@ -378,7 +378,7 @@ a JAX array:
>>> eval_jaxpr(plxpr.jaxpr, plxpr.consts)
[Array(0.99500417, dtype=float64)]

If the object you are indexing **cannot** be converted to a JAX array, it is not possible for AutoGraph to capture this for loop.
If the object you are indexing **cannot** be converted to a JAX array, it is not possible for AutoGraph to capture this ``for`` loop.

If you are updating elements of the array, this must be done using the JAX ``.at`` and ``.set`` syntax.

Expand Down Expand Up @@ -440,7 +440,7 @@ However, like with conditionals, a similar restriction applies: variables
which are updated across iterations of the loop must have a JAX compilable
type (Booleans, Python numeric types, and JAX arrays).

You can also utilize temporary variables within a for loop:
You can also utilize temporary variables within a ``for`` loop:

>>> def f(x):
... for y in [0, 4, 5]:
Expand Down Expand Up @@ -520,7 +520,7 @@ To allow AutoGraph conversion to work in this case, simply convert the list to a
>>> eval_jaxpr(plxpr.jaxpr, plxpr.consts)
[Array(0.99500417, dtype=float64)]

If the object you are indexing **cannot** be converted to a JAX array, it is not possible for AutoGraph to capture this for loop.
If the object you are indexing **cannot** be converted to a JAX array, it is not possible for AutoGraph to capture this ``while`` loop.

If you are updating elements of the array, this must be done using the JAX ``.at`` and ``.set`` syntax.

Expand Down
10 changes: 0 additions & 10 deletions doc/development/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,6 @@ Pending deprecations
- Deprecated in v0.40
- Will be removed in v0.41

- Deprecated in v0.39
- Will be removed in v0.40

* The ``QubitStateVector`` template is deprecated.
Instead, use ``StatePrep``.

- Deprecated in v0.39
- Will be removed in v0.40

* ``op.ops`` and ``op.coeffs`` for ``Sum`` and ``Prod`` will be removed in the future. Use
:meth:`~.Operator.terms` instead.

Expand All @@ -70,7 +61,6 @@ Pending deprecations
values with a bit string. In the future, it will no longer accepts strings as control values.

- Deprecated in v0.36
- Will be removed in v0.37

Completed removal of legacy operator arithmetic
-----------------------------------------------
Expand Down
18 changes: 10 additions & 8 deletions doc/development/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ For example:

This execute method works in tandem with the optional :meth:`Device.preprocess_transforms <pennylane.devices.Device.preprocess_transforms>`
and :meth:`Device.setup_execution_config`, described below in more detail. Preprocessing transforms
turns generic circuits into ones supported by the device, or raises an error if the circuit is invalid.
turns generic circuits into ones supported by the device or raises an error if the circuit is invalid.
Execution produces numerical results from those supported circuits.

In a more minimal example, for any initial batch of quantum tapes and a config object, we expect to be able to do:
Expand Down Expand Up @@ -376,7 +376,7 @@ Wires
Devices can now either:

1) Strictly use wires provided by the user on initialization: ``device(name, wires=wires)``
2) Infer the number and ordering of wires provided by the submitted circuit.
2) Infer the number and order of wires provided by the submitted circuit
3) Strictly require specific wire labels

Option 2 allows workflows to change the number and labeling of wires over time, but sometimes users want
Expand Down Expand Up @@ -434,18 +434,20 @@ The execution config stores two kinds of information:

Device options are any device specific options used to configure the behavior of an execution. For
example, ``default.qubit`` has ``max_workers``, ``rng``, and ``prng_key``. ``default.tensor`` has
``contract``, ``cutoff``, ``dtype``, ``method``, and ``max_bond_dim``. These options are often set
``contract``, ``contraction_optimizer``, ``cutoff``, ``c_dtype``, ``local_simplify``, ``method``, and ``max_bond_dim``. These options are often set
with default values on initialization. These values should be placed into the ``ExecutionConfig.device_options``
dictionary in :meth:`~.devices.Device.setup_execution_config`. Note that we do provide a default
implementation of this method, but you will most likely need to override it yourself.

>>> dev = qml.device('default.tensor', wires=2, max_bond_dim=4, contract="nonlocal", dtype=np.complex64)
>>> dev = qml.device('default.tensor', wires=2, max_bond_dim=4, contract="nonlocal", c_dtype=np.complex64)
>>> dev.setup_execution_config().device_options
{'contract': 'nonlocal',
'cutoff': 1.1920929e-07,
'dtype': numpy.complex64,
'method': 'mps',
'max_bond_dim': 4}
'contraction_optimizer': 'auto-hq',
'cutoff': None,
'c_dtype': numpy.complex64,
'local_simplify': 'ADCRS',
'max_bond_dim': 4,
'method': 'mps'}

Even if the property is stored as an attribute on the device, execution should pull the value of
these properties from the config instead of from the device instance. While not yet integrated at
Expand Down
Loading
Loading