Skip to content

Commit

Permalink
[feature] Shots backend (#130)
Browse files Browse the repository at this point in the history
# Description

- Refactors `CuTensorNetBackend` into `CuTensorNetStateBackend` which
now uses the new `GeneralState`.
- Introduces a new `CuTensorNetShotsBackend` for shot-based simulation.

# Related issues

Completes #121.

# Checklist

- [x] I have run the tests on a device with GPUs.
- [x] I have performed a self-review of my code.
- [x] I have commented hard-to-understand parts of my code.
- [x] I have made corresponding changes to the public API documentation.
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have updated the changelog with any user-facing changes.
  • Loading branch information
PabloAndresCQ authored Jul 4, 2024
1 parent 1fcff74 commit b224587
Show file tree
Hide file tree
Showing 11 changed files with 378 additions and 221 deletions.
7 changes: 7 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ Changelog
Unreleased
----------

* API breaking changes
* Renamed ``CuTensorNetBackend`` to ``CuTensorNetStateBackend``.
* Moved ``get_operator_expectation_value`` and ``get_circuit_overlap`` from ``backends`` submodule to ``general_state`` submodule.
* **Warning** ``TensorNetwork`` object will soon be deprecated in favour of the new ``GeneralState``.


* New API: ``GeneralState`` for exact simulation of circuits via contraction-path optimisation. Currently supports ``get_statevector()``, ``expectation_value()`` and ``sample()``.
* New feature: ``CuTensorNetShotsBackend`` for simulation of circuit shots.
* New feature: ``add_qubit`` to add fresh qubits at specified positions in an ``MPS``.
* New feature: added an option to ``measure`` to toggle destructive measurement on/off. Currently only supported for ``MPS``.
* New feature: a seed can now be provided to ``Config`` objects, providing reproducibility across ``StructuredState`` simulations.
Expand Down
8 changes: 6 additions & 2 deletions docs/modules/general_state.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ cuQuantum `contract` API interface

.. autoclass:: pytket.extensions.cutensornet.general_state.ExpectationValueTensorNetwork

.. autofunction:: pytket.extensions.cutensornet.general_state.tk_to_tensor_network

.. autofunction:: pytket.extensions.cutensornet.general_state.measure_qubits_state

.. autofunction:: pytket.extensions.cutensornet.general_state.tk_to_tensor_network
.. autofunction:: pytket.extensions.cutensornet.general_state.get_operator_expectation_value

.. autofunction:: pytket.extensions.cutensornet.general_state.get_circuit_overlap


Pytket backend
~~~~~~~~~~~~~~

.. automodule:: pytket.extensions.cutensornet
:members: CuTensorNetBackend
:members: CuTensorNetStateBackend, CuTensorNetShotsBackend
2 changes: 1 addition & 1 deletion pytket/extensions/cutensornet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
"""Module for conversion from tket primitives to cuQuantum primitives."""

from .backends import CuTensorNetBackend
from .backends import CuTensorNetStateBackend, CuTensorNetShotsBackend
from .general import CuTensorNetHandle

# _metadata.py is copied to the folder after installation.
Expand Down
2 changes: 1 addition & 1 deletion pytket/extensions/cutensornet/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# limitations under the License.
"""Backend for utilising the cuQuantum simulator directly from pytket"""

from .cutensornet_backend import CuTensorNetBackend
from .cutensornet_backend import CuTensorNetStateBackend, CuTensorNetShotsBackend
Loading

0 comments on commit b224587

Please sign in to comment.