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

V0.23.0 notes #2474

Merged
merged 75 commits into from
Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
4cd2baf
notes + version
antalszava Apr 21, 2022
007e7ae
merge rc
antalszava Apr 21, 2022
cf33991
sections
antalszava Apr 21, 2022
7d38412
update examples
antalszava Apr 21, 2022
e8a8054
remove empty sections
antalszava Apr 21, 2022
638c7ed
has_matrix bug fix
antalszava Apr 21, 2022
64c4820
Adding more PRs to the changelog
antalszava Apr 21, 2022
f0eda54
PR, extend contributors
antalszava Apr 21, 2022
cc9ed09
Extend list of contributors
antalszava Apr 21, 2022
9b93989
Update the order of entries
antalszava Apr 21, 2022
8842be7
Merge branch 'v0.23.0-rc0' into v0.23.0-notes
antalszava Apr 22, 2022
a87109d
Add auto cutting example; reorg QChem
antalszava Apr 22, 2022
91aceea
Merge branch 'v0.23.0-notes' of github.com:PennyLaneAI/pennylane into…
antalszava Apr 22, 2022
6a4e2dc
remove curr release from 0.22.2 header
antalszava Apr 22, 2022
248496e
formatting
antalszava Apr 22, 2022
31d55c5
resolve
antalszava Apr 25, 2022
9ce1761
fix link
antalszava Apr 25, 2022
9898272
Update
rmoyard Apr 25, 2022
4639909
Trigger CI
antalszava Apr 25, 2022
aa3943d
Change code blooc
rmoyard Apr 25, 2022
9d9ee3c
Merge branch 'update_doc_pattern' of https://github.com/PennyLaneAI/p…
rmoyard Apr 25, 2022
d021370
Typo
rmoyard Apr 25, 2022
a39350f
Update pennylane/transforms/optimization/pattern_matching.py
rmoyard Apr 25, 2022
3596cb8
Update pennylane/transforms/optimization/pattern_matching.py
rmoyard Apr 25, 2022
6666639
Update pennylane/transforms/optimization/pattern_matching.py
rmoyard Apr 25, 2022
21c807c
Update pennylane/transforms/optimization/pattern_matching.py
rmoyard Apr 25, 2022
13b61f8
Addd seealso
rmoyard Apr 25, 2022
bde2f26
Merge branch 'update_doc_pattern' of https://github.com/PennyLaneAI/p…
rmoyard Apr 25, 2022
c70c1c5
modify the qchem section
soranjh Apr 25, 2022
f21764e
Merge branch 'v0.23.0-notes' of github.com:PennyLaneAI/pennylane into…
antalszava Apr 25, 2022
392f784
Update doc/releases/changelog-0.23.0.md
antalszava Apr 25, 2022
8b55f5a
Update doc/releases/changelog-0.23.0.md
antalszava Apr 25, 2022
6a15d57
Update doc/releases/changelog-0.23.0.md
antalszava Apr 25, 2022
0ca9b46
Update doc/releases/changelog-0.23.0.md
antalszava Apr 25, 2022
a2481ec
code review
antalszava Apr 25, 2022
cbd2290
code review
antalszava Apr 25, 2022
3d2ba90
code review (remove empty lines & add pattern matching opt docstring …
antalszava Apr 25, 2022
bb3566d
Update doc/releases/changelog-0.23.0.md
antalszava Apr 25, 2022
1c3bfb2
Update doc/releases/changelog-0.23.0.md
antalszava Apr 25, 2022
18646fc
shape and numeric type example
antalszava Apr 25, 2022
7017e6a
MP description update
antalszava Apr 25, 2022
be14d5a
rephrase expand_strategy for qml.specs improvement
antalszava Apr 25, 2022
f5889df
update
antalszava Apr 25, 2022
c43a9e9
caching phrasing
antalszava Apr 25, 2022
75e9c61
removed
antalszava Apr 25, 2022
6d72273
phrasing
antalszava Apr 25, 2022
b58ac5c
updates
antalszava Apr 25, 2022
7035c87
bug phrasing, reorder
antalszava Apr 25, 2022
0c83669
update link placement and use pycon
antalszava Apr 25, 2022
87356dd
Merge branch 'v0.23.0-rc0' into v0.23.0-notes
antalszava Apr 25, 2022
363513c
include swap test output in example
antalszava Apr 25, 2022
ae21243
More info on HS template
antalszava Apr 25, 2022
bac5c75
rephrase QCut
antalszava Apr 25, 2022
59ab134
move example to UsageDetails
antalszava Apr 25, 2022
5bff6a9
auto QCut rephrase
antalszava Apr 25, 2022
2412f45
More powerful circuit cutting
antalszava Apr 25, 2022
9b96d78
Trigger CI
antalszava Apr 25, 2022
79877d2
Upddate
rmoyard Apr 25, 2022
7a6c7a5
add qchem code example
soranjh Apr 25, 2022
1e23d8f
correct typo in qchem text
soranjh Apr 25, 2022
a8c5101
no backticks
antalszava Apr 25, 2022
00a417b
Merge branch 'v0.23.0-notes' of github.com:PennyLaneAI/pennylane into…
antalszava Apr 25, 2022
0708cff
fix the case when obs=None for a MeasurementProcess for interface sel…
antalszava Apr 25, 2022
2b95767
update
rmoyard Apr 25, 2022
12f7355
changelog
antalszava Apr 25, 2022
b756de3
docstring
antalszava Apr 25, 2022
8e7f120
Update doc/releases/changelog-0.23.0.md
antalszava Apr 25, 2022
04dfe32
update links as per code review
antalszava Apr 25, 2022
fa34936
typo
rmoyard Apr 25, 2022
acdc128
pycon syntax
antalszava Apr 25, 2022
b530e95
double backticks
antalszava Apr 25, 2022
c24873a
Merge branch 'update_doc_pattern' into v0.23.0-notes
antalszava Apr 25, 2022
defc512
Merge branch 'v0.23.0-rc0' into v0.23.0-notes
antalszava Apr 25, 2022
d4cee10
no dev in release header
antalszava Apr 25, 2022
596c7ef
Lightning v0.23.0 required in setup.py
antalszava Apr 25, 2022
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 .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ignored-modules=numpy,scipy,autograd,toml,appdir,autograd,autograd.numpy,autogra
# List of classes names for which member attributes should not be checked
# (useful for classes with attributes dynamically set). This supports can work
# with qualified names.
ignored-classes=numpy,scipy,autograd,toml,appdir,autograd,autograd.numpy,autograd.numpy.linalg,semantic_version,torch,tensorflow,tensorflow.contrib,tensorflow.contrib.eager,LazyLoader,networkx,networkx.dag,math,pennylane.numpy,pennylane.numpy.random,pennylane.numpy.linalg,pennylane.operation,retworkx
ignored-classes=numpy,scipy,autograd,toml,appdir,autograd,autograd.numpy,autograd.numpy.linalg,semantic_version,torch,tensorflow,tensorflow.contrib,tensorflow.contrib.eager,LazyLoader,networkx,networkx.dag,math,pennylane.numpy,pennylane.numpy.random,pennylane.numpy.linalg,pennylane.operation,retworkx,kahypar
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was getting linting issues in the QCut file.


[MESSAGES CONTROL]

Expand Down
2 changes: 1 addition & 1 deletion doc/releases/changelog-0.22.2.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
:orphan:

# Release 0.22.2 (current release)
# Release 0.22.2

<h3>Bug fixes</h3>

Expand Down
717 changes: 377 additions & 340 deletions doc/releases/changelog-0.23.0.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pennylane/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
Version number (major.minor.patch[-label])
"""

__version__ = "0.23.0-dev"
__version__ = "0.23.0"
8 changes: 5 additions & 3 deletions pennylane/interfaces/jax.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ def get_jax_interface_name(tapes):

# Unwrap the observable from a MeasurementProcess
op = op.obs if hasattr(op, "obs") else op
for param in op.data:
if qml.math.is_abstract(param):
return "jax-jit"
if op is not None:
# Some MeasurementProcess objects have obs=None
for param in op.data:
if qml.math.is_abstract(param):
return "jax-jit"

return "jax"

Expand Down
59 changes: 59 additions & 0 deletions pennylane/transforms/optimization/pattern_matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ def circuit():
3: ─├C─│───H─╰X─╰C─┤
4: ─╰C─╰X──────────┤

.. seealso:: :func:`~.pattern_matching`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: changes from #2489 have been directly incorporated in this PR.


**Reference:**

[1] Iten, R., Moyard, R., Metger, T., Sutter, D. and Woerner, S., 2022.
Expand Down Expand Up @@ -273,6 +275,63 @@ def pattern_matching(circuit_dag, pattern_dag):

Returns:
list(Match): the list of maximal matches.

**Example**

First let's consider the following circuit

.. code-block:: python

def circuit():
qml.S(wires=0)
qml.PauliZ(wires=0)
qml.S(wires=1)
qml.CZ(wires=[0, 1])
qml.S(wires=1)
qml.S(wires=2)
qml.CZ(wires=[1, 2])
qml.S(wires=2)
return qml.expval(qml.PauliX(wires=0))

Assume that we want to find all maximal matches of a pattern containing a sequence of two :class:`~.S` gates and
a :class:`~.PauliZ` gate:

.. code-block:: python

def pattern():
qml.S(wires=0)
qml.S(wires=0)
qml.PauliZ(wires=0)


>>> circuit_dag = qml.commutation_dag(circuit)()
>>> pattern_dag = qml.commutation_dag(pattern)()
>>> all_max_matches = qml.pattern_matching(circuit_dag, pattern_dag)

The matches are accessible by looping through the list outputted by ``qml.pattern_matching``. This output is a list
of lists containing indices. Each list represents a match between a gate in the pattern with a gate in the circuit.
The first indices represent the gates in the pattern and the second indices provides indices for the gates in the
circuit (by order of appearance).

>>> for match_conf in all_max_matches:
... print(match_conf.match)
[[0, 0], [2, 1]]
[[0, 2], [1, 4]]
[[0, 4], [1, 2]]
[[0, 5], [1, 7]]
[[0, 7], [1, 5]]

The first match of this list corresponds to match the first gate (:class:`~.S`) in the pattern with the first gate
in the circuit and also the third gate in the pattern (:class:`~.PauliZ`) with the second circuit gate.

.. seealso:: :func:`~.pattern_matching_optimization`

**Reference:**

[1] Iten, R., Moyard, R., Metger, T., Sutter, D. and Woerner, S., 2022.
Exact and practical pattern matching for quantum circuit optimization.
`doi.org/10.1145/3498325 <https://dl.acm.org/doi/abs/10.1145/3498325>`_

"""
# Match list
match_list = []
Expand Down
34 changes: 34 additions & 0 deletions pennylane/transforms/qcut.py
Original file line number Diff line number Diff line change
Expand Up @@ -1255,6 +1255,39 @@ def fn(x):
... fn
... )
array(-4.)

Using the Monte Carlo approach of [Peng et. al](https://arxiv.org/abs/1904.00102), the
`cut_circuit_mc` transform also supports returning sample-based expectation values of
observables that are diagonal in the computational basis, as shown below for a `ZZ` measurement
on wires `0` and `2`:

.. code-block::

dev = qml.device("default.qubit", wires=2, shots=10000)

def observable(bitstring):
return (-1) ** np.sum(bitstring)

@qml.cut_circuit_mc(classical_processing_fn=observable)
@qml.qnode(dev)
def circuit(x):
qml.RX(0.89, wires=0)
qml.RY(0.5, wires=1)
qml.RX(1.3, wires=2)

qml.CNOT(wires=[0, 1])
qml.WireCut(wires=1)
qml.CNOT(wires=[1, 2])

qml.RX(x, wires=0)
qml.RY(0.7, wires=1)
qml.RX(2.3, wires=2)
return qml.sample(wires=[0, 2])

We can now approximate the expectation value of the observable using

>>> circuit(x)
tensor(-0.776, requires_grad=True)
"""
# pylint: disable=unused-argument, too-many-arguments

Expand Down Expand Up @@ -3107,6 +3140,7 @@ def _is_valid_cut(

correct_num_fragments = k <= num_fragments_requested
best_candidate_yet = (key not in cut_candidates) or (len(cut_candidates[key]) > num_cuts)
# pylint: disable=no-member
all_fragments_fit = all(
len(graph_to_tape(f).wires) <= max_free_wires for j, f in enumerate(fragments)
)
Expand Down
72 changes: 35 additions & 37 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,41 +28,39 @@
"semantic_version==2.6",
"autoray",
"cachetools",
"pennylane-lightning>=0.22",
"pennylane-lightning>=0.23",
]

info = {
'name': 'PennyLane',
'version': version,
'maintainer': 'Xanadu Inc.',
'maintainer_email': 'software@xanadu.ai',
'url': 'https://github.com/XanaduAI/pennylane',
'license': 'Apache License 2.0',
'packages': find_packages(where="."),
'entry_points': {
"name": "PennyLane",
"version": version,
"maintainer": "Xanadu Inc.",
"maintainer_email": "software@xanadu.ai",
"url": "https://github.com/XanaduAI/pennylane",
"license": "Apache License 2.0",
"packages": find_packages(where="."),
"entry_points": {
# TODO: rename entry point 'pennylane.plugins' to 'pennylane.devices'.
# This requires a rename in the setup file of all devices, and is best done during another refactor
'pennylane.plugins': [
'default.qubit = pennylane.devices:DefaultQubit',
'default.gaussian = pennylane.devices:DefaultGaussian',
'default.qubit.tf = pennylane.devices.default_qubit_tf:DefaultQubitTF',
'default.qubit.torch = pennylane.devices.default_qubit_torch:DefaultQubitTorch',
'default.qubit.autograd = pennylane.devices.default_qubit_autograd:DefaultQubitAutograd',
'default.qubit.jax = pennylane.devices.default_qubit_jax:DefaultQubitJax',
'default.mixed = pennylane.devices.default_mixed:DefaultMixed'
],
'console_scripts': [
'pl-device-test=pennylane.devices.tests:cli'
]
},
'description': 'PennyLane is a Python quantum machine learning library by Xanadu Inc.',
'long_description': open('README.md').read(),
'long_description_content_type': "text/markdown",
'provides': ["pennylane"],
'install_requires': requirements,
'extras_require': {'kernels': ['cvxpy', 'cvxopt']},
'package_data': {'pennylane': ['devices/tests/pytest.ini']},
'include_package_data': True
"pennylane.plugins": [
"default.qubit = pennylane.devices:DefaultQubit",
"default.gaussian = pennylane.devices:DefaultGaussian",
"default.qubit.tf = pennylane.devices.default_qubit_tf:DefaultQubitTF",
"default.qubit.torch = pennylane.devices.default_qubit_torch:DefaultQubitTorch",
"default.qubit.autograd = pennylane.devices.default_qubit_autograd:DefaultQubitAutograd",
"default.qubit.jax = pennylane.devices.default_qubit_jax:DefaultQubitJax",
"default.mixed = pennylane.devices.default_mixed:DefaultMixed",
],
"console_scripts": ["pl-device-test=pennylane.devices.tests:cli"],
},
"description": "PennyLane is a Python quantum machine learning library by Xanadu Inc.",
"long_description": open("README.md").read(),
"long_description_content_type": "text/markdown",
"provides": ["pennylane"],
"install_requires": requirements,
"extras_require": {"kernels": ["cvxpy", "cvxopt"]},
"package_data": {"pennylane": ["devices/tests/pytest.ini"]},
"include_package_data": True,
}

classifiers = [
Expand All @@ -76,13 +74,13 @@
"Operating System :: POSIX :: Linux",
"Operating System :: Microsoft :: Windows",
"Programming Language :: Python",
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3 :: Only',
"Topic :: Scientific/Engineering :: Physics"
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Scientific/Engineering :: Physics",
]

setup(classifiers=classifiers, **(info))
18 changes: 18 additions & 0 deletions tests/interfaces/test_jax_qnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -1343,6 +1343,24 @@ def circ(projector):

assert jnp.allclose(circ(projector), 1)

@pytest.mark.filterwarnings(
"ignore:Requested adjoint differentiation to be computed with finite shots."
)
@pytest.mark.parametrize("shots", [10, 1000])
def test_probs_obs_none(self, dev_name, diff_method, mode, shots):
"""Test that the jax device works with qml.probs, a MeasurementProcess
that has obs=None even when shots>0."""
dev = qml.device(dev_name, wires=2, shots=shots)

if diff_method == "backprop":
pytest.skip("Backpropagation is unsupported if shots > 0.")

@qml.qnode(dev, interface="jax", diff_method="parameter-shift")
def circuit():
return qml.probs(wires=0)

assert jnp.allclose(circuit(), jnp.array([1.0, 0.0]))

@pytest.mark.xfail(
reason="Non-trainable parameters are not being correctly unwrapped by the interface"
)
Expand Down