Skip to content

Commit

Permalink
Merge branch 'master' into update-python-version-to-3_8-in-install-page
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacdevlugt authored Jun 19, 2023
2 parents 493a08d + 3d419e2 commit 5a50f3c
Show file tree
Hide file tree
Showing 126 changed files with 8,439 additions and 1,981 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/interface-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
description: The version of JAX to install for any job that requires JAX
required: false
type: string
default: 0.4.10
default: 0.4.12
tensorflow_version:
description: The version of TensorFlow to install for any job that requires TensorFlow
required: false
Expand Down
92 changes: 92 additions & 0 deletions doc/code/qml_fermi.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
qml.fermi
=========

Overview
--------

This module contains functions and classes for creating and manipulating fermionic operators.

.. currentmodule:: pennylane.fermi

.. automodapi:: pennylane.fermi
:no-heading:
:no-main-docstr:
:no-inherited-members:

FermiC and FermiA
-----------------

The fermionic creation and annihilation operators are constructed with :class:`~pennylane.FermiC`
and :class:`~pennylane.FermiA`, respectively. We pass in the index of the orbital that the
operator acts on. For example, the operators :math:`a^{\dagger}_0` and :math:`a_3`, acting on the
:math:`0\text{th}` and :math:`3\text{rd}` orbitals, are constructed as

>>> qml.FermiC(0)
a⁺(0)
>>> qml.FermiA(3)
a(3)

These operators can be multiplied by each other to create :math:`n`-orbital fermionic operators such
as :math:`a^{\dagger}_0 a_0 a^{\dagger}_3 a_3`. We call these :math:`n`-orbital fermionic operators
Fermi words.

>>> qml.FermiC(0) * qml.FermiA(0) * qml.FermiC(3) * qml.FermiA(3)
a⁺(0) a(0) a⁺(3) a(3)

The Fermi words can be linearly combined to create fermionic operators that we call Fermi
sentences. For instance, a fermionic Hamiltonian such as
:math:`H = 1.2 a^{\dagger}_0 a_0 + 2.3 a^{\dagger}_3 a_3` can be constructed from Fermi words with

>>> h = 1.2 * qml.FermiC(0) * qml.FermiA(0) + 2.3 * qml.FermiC(3) * qml.FermiA(3)
>>> h
1.2 * a⁺(0) a(0)
+ 2.3 * a⁺(3) a(3)

Mapping to qubit operators
--------------------------

The fermionic operators can be mapped to the qubit basis by using the
:func:`~pennylane.jordan_wigner` function. This function can be used to map
:class:`~pennylane.FermiC` and :class:`~pennylane.FermiA` operators as well as Fermi words and
Fermi sentences.

>>> qml.jordan_wigner(qml.FermiA(1))
(0.5*(PauliZ(wires=[0]) @ PauliX(wires=[1])))
+ (0.5j*(PauliZ(wires=[0]) @ PauliY(wires=[1])))

>>> qml.jordan_wigner(qml.FermiC(1) * qml.FermiA(1))
((0.5+0j)*(Identity(wires=[1])))
+ ((-0.5+0j)*(PauliZ(wires=[1])))

>>> f = 0.5 * qml.FermiC(1) * qml.FermiA(1) + 0.75 * qml.FermiC(2) * qml.FermiA(2)
>>> qml.jordan_wigner(f)
((0.625+0j)*(Identity(wires=[1])))
+ ((-0.25+0j)*(PauliZ(wires=[1])))
+ ((-0.375+0j)*(PauliZ(wires=[2])))

FermiWord and FermiSentence
---------------------------

Fermi words and Fermi sentences can also be constructed directly with
:class:`~pennylane.fermi.FermiWord` and :class:`~pennylane.fermi.FermiSentence` by passing
dictionaries that define the fermionic operators.

For Fermi words, the dictionary items define the fermionic creation and annihilation operators.
The keys of the dictionary are tuples of two integers. The first integer represents the
position of the creation/annihilation operator in the Fermi word and the second integer represents
the orbital it acts on. The values of the dictionary are one of ``'+'`` or ``'-'`` symbols that
denote creation and annihilation operators, respectively. The operator
:math:`a^{\dagger}_0 a_3 a^{\dagger}_1` can then be constructed with

>>> qml.fermi.FermiWord({(0, 0): '+', (1, 3): '-', (2, 1): '+'})
a⁺(0) a(3) a⁺(1)

A Fermi sentence can be constructed directly by passing a dictionary of Fermi words and their
corresponding coefficients to the :class:`~pennylane.fermi.FermiSentence` class. For instance, the
Fermi sentence :math:`1.2 a^{\dagger}_0 a_0 + 2.3 a^{\dagger}_3 a_3` can be constructed as

>>> fw1 = qml.fermi.FermiWord({(0, 0): '+', (1, 0): '-'})
>>> fw2 = qml.fermi.FermiWord({(0, 3): '+', (1, 3): '-'})
>>> qml.fermi.FermiSentence({fw1: 1.2, fw2: 2.3})
1.2 * a⁺(0) a(0)
+ 2.3 * a⁺(3) a(3)
37 changes: 37 additions & 0 deletions doc/development/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ Deprecations
Pending deprecations
--------------------

* The `grouping_type` and `grouping_method` arguments of `qchem.molecular_hamiltonian()` are deprecated.

- Deprecated in v0.31
- Will be removed in v0.32

Instead, simply construct a new instance of ``Hamiltonian`` with the grouping specified:

.. code-block:: python
H, qubits = molecular_hamiltonian(symbols, coordinates)
grouped_h = qml.Hamiltonian(
H.coeffs,
H.ops,
grouping_type=grouping_type,
method=grouping_method,
)
* ``zyz_decomposition`` and ``xyx_decomposition`` are deprecated, use ``one_qubit_decomposition`` with a rotations
keyword instead.

Expand Down Expand Up @@ -81,6 +98,26 @@ Pending deprecations
some_qfunc(params)
return qml.expval(Hamiltonian)
* The public methods of ``DefaultQubit`` are pending changes to
follow the new device API, as used in ``DefaultQubit2``.

We will be switching to the new device interface in a coming release.
In this new interface, simulation implementation details
will be abstracted away from the device class itself and provided by composition, rather than inheritance.
Therefore, some public and private methods from ``DefaultQubit`` will no longer exist, though its behaviour
in a workflow will remain the same.

If you directly interact with device methods, please consult
:class:`pennylane.devices.experimental.Device` and
:class:`pennylane.devices.experimental.DefaultQubit2`
for more information on what the new interface will look like and be prepared
to make updates in a coming release. If you have any feedback on these
changes, please create an
`issue <https://github.com/PennyLaneAI/pennylane/issues>`_ or post in our
`discussion forum <https://discuss.pennylane.ai/>`_.

- Deprecated in v0.31


Completed deprecation cycles
----------------------------
Expand Down
10 changes: 10 additions & 0 deletions doc/development/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ and subclassing it:
which contains a lot of functionality specific to computations based on qubits. We will
take a deeper look at this important case below.

.. warning::

The API of PennyLane devices will be updated soon to follow a new interface defined by
the experimental :class:`pennylane.devices.experimental.Device` class. This guide describes
how to create a device with the current :class:`pennylane.Device` and
:class:`pennylane.QubitDevice` base classes, and will be updated as we switch to the new API.
In the meantime, please reach out to the PennyLane team if you would like help with building
a plugin, either by creating an `issue <https://github.com/PennyLaneAI/pennylane/issues>`_ or
by posting in our `discussion forum <https://discuss.pennylane.ai/>`_.

Here, we have begun defining some important class attributes that allow PennyLane to identify
and use the device. These include:

Expand Down
2 changes: 2 additions & 0 deletions doc/development/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ This page contains the release notes for PennyLane.

.. mdinclude:: ../releases/changelog-dev.md

.. mdinclude:: ../releases/changelog-0.31.0.md

.. mdinclude:: ../releases/changelog-0.30.0.md

.. mdinclude:: ../releases/changelog-0.29.0.md
Expand Down
1 change: 1 addition & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ PennyLane is **free** and **open source**, released under the Apache License, Ve
code/qml
code/qml_data
code/qml_drawer
code/qml_fermi
code/qml_fourier
code/qml_gradients
code/qml_kernels
Expand Down
Loading

0 comments on commit 5a50f3c

Please sign in to comment.