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

Remove more analytic occurrences #1261

Merged
merged 5 commits into from
Apr 30, 2021
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
3 changes: 3 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@

<h3>Documentation</h3>

* Removes occurrences of the deprecated device argument ``analytic`` from the documentation.
[(#1261)](https://github.com/PennyLaneAI/pennylane/pull/1261)

* Updated the order of the parameters to the `GaussianState` operation to match
the way that the PennyLane-SF plugin uses them.
[(#1255)](https://github.com/PennyLaneAI/pennylane/pull/1255)
Expand Down
22 changes: 11 additions & 11 deletions doc/development/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,13 @@ following arguments:
or iterable that contains unique labels for the subsystems as numbers (i.e., ``[-1, 0, 2]``)
and/or strings (``['ancilla', 'q1', 'q2']``).

* ``shots=1000`` (*int*): number of circuit evaluations/random samples used to estimate
expectation values of observables in non-analytic mode.

* ``analytic=True`` (*bool*): If ``True``, the device calculates probability, expectation
values, and variances analytically. If ``False``, a finite number of samples
are used to estimate these quantities. Note that hardware devices should always set
``analytic=False``.
* ``shots=1000`` (*None*, *int* or *List[iint]*): number of circuit
evaluations/random samples used to estimate probabilities, expectation
values, variances of observables in non-analytic mode. If ``None``, the device
calculates probability, expectation values, and variances analytically. If an
integer, it specifies the number of samples to estimate these quantities. If a
list of integers is passed, the circuit evaluations are batched over the list
of shots.

To add your own device arguments, or to override any of the above defaults, simply
overwrite the ``__init__.py`` method. For example, here is a device where the number
Expand All @@ -167,7 +167,7 @@ of low-level hardware control options:
observables = {"PauliZ", "PauliX", "PauliY"}

def __init__(self, shots=1024, hardware_options=None):
super().__init__(wires=24, shots=shots, analytic=False)
super().__init__(wires=24, shots=shots)
self.hardware_options = hardware_options or hardware_defaults

Note that we have also overridden the default shot number.
Expand All @@ -193,7 +193,7 @@ To execute operations on the device, the following methods **must** be defined:

apply

If the device is a statevector simulator (it has an ``analytic`` attribute)
If the device is a statevector simulator (it can perform analytic computations when ``shots=None``)
then it **must** also overwrite:

.. autosummary::
Expand Down Expand Up @@ -241,7 +241,7 @@ your plugin which, by default, performs the following process:
self.apply(circuit.operations, rotations=circuit.diagonalizing_gates)

# generate computational basis samples
if (not self.analytic) or circuit.is_sampled:
if self.shots is not None or circuit.is_sampled:
self._samples = self.generate_samples()

# compute the required statistics
Expand Down Expand Up @@ -410,7 +410,7 @@ test utility:

.. code-block:: console

pl-device-test --device device_shortname --shots 10000 --analytic False
pl-device-test --device device_shortname --shots 10000

In general, as all supported operations have their gradient formula defined and tested by
PennyLane, testing that your device calculates the correct gradients is not required.
Expand Down
2 changes: 0 additions & 2 deletions tests/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@

[strawberryfields.global]
hbar = 1
shots = 1000
analytic = true
Comment on lines -43 to -44
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TOML doesn't seem to have the concept of None (see here), so just leaving shots out instead of shots=None.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!


[strawberryfields.fock]
cutoff_dim = 10
Expand Down