Skip to content

Commit

Permalink
Merge pull request #39 from CQCL/release/v0.4.0
Browse files Browse the repository at this point in the history
Release v0.4.0
  • Loading branch information
PabloAndresCQ authored Oct 26, 2023
2 parents 972bed6 + b7e7631 commit 9714ba7
Show file tree
Hide file tree
Showing 17 changed files with 1,805 additions and 320 deletions.
1 change: 1 addition & 0 deletions .github/workflows/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"repository_url": "https://github.com/CQCL/pytket-cutensornet",
"use_repository_button": True,
"use_issues_button": True,
"navigation_with_keys": True,
"logo": {
"image_light": "Quantinuum_logo_black.png",
"image_dark": "Quantinuum_logo_white.png",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sphinx
sphinx >= 4.5, <7
sphinx_autodoc_annotation
sphinx-autodoc-typehints>=1.19.3
sphinx_book_theme >= 1.0.1, <2.0
Expand Down
2 changes: 1 addition & 1 deletion _metadata.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__extension_version__ = "0.3.0"
__extension_version__ = "0.4.0"
__extension_name__ = "pytket-cutensornet"
10 changes: 10 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Changelog
~~~~~~~~~

0.4.0 (October 2023)
--------------------

* API Update. Configuration of ``MPS`` simulation parameters is now done via ``ConfigMPS``.
* Added a ``value_of_zero`` parameter to ``ConfigMPS`` for the user to indicate the threshold below which numbers are so small that can be interpreted as zero.
* Added a logger to MPS methods. Use it by setting ``loglevel`` in ``ConfigMPS``.
* Improved performance of contraction across ``MPS`` methods by hardcoding the contraction paths.
* Fixed a bug that caused more MPS canonicalisation than strictly required.
* Fixed a bug where ``simulate`` would not apply the last batch of gates when using ``MPSxMPO``.

0.3.0 (September 2023)
----------------------

Expand Down
11 changes: 5 additions & 6 deletions docs/intro.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ pytket-cutensornet
==================

``pytket-cutensornet`` is an extension to ``pytket`` that allows ``pytket`` circuits and
expectation values to be simulated using `cuTensorNet <https://docs.nvidia.com/cuda/cuquantum/cutensornet/index.html>`_.
expectation values to be simulated using `cuTensorNet <https://docs.nvidia.com/cuda/cuquantum/latest/cutensornet/index.html>`_.

`cuTensorNet <https://docs.nvidia.com/cuda/cuquantum/cutensornet/index.html>`_ is a
`cuTensorNet <https://docs.nvidia.com/cuda/cuquantum/latest/cutensornet/index.html>`_ is a
high-performance library for tensor network computations, developed by NVIDIA.
It is part of the `cuQuantum <https://docs.nvidia.com/cuda/cuquantum/index.html>`_ SDK --
It is part of the `cuQuantum <https://docs.nvidia.com/cuda/cuquantum/latest/index.html>`_ SDK --
a high-performance library aimed at quantum circuit simulations on the NVIDIA GPU chips.

We provide two core functionalities:
Expand All @@ -19,9 +19,8 @@ Currently, only single-GPU calculations are supported, but a multi-GPU execution
implemented in the due course using ``mpi4py`` library.

``pytket-cutensornet`` is available for Python 3.9, 3.10 and 3.11 on Linux.
In order to use it, you need access to a Linux machine with either ``Volta``, ``Ampere``
or ``Hopper`` GPU and first install ``cuQuantum Python`` following their installation
`instructions <https://docs.nvidia.com/cuda/cuquantum/python/README.html#installation>`_.
In order to use it, you need access to a Linux machine with an NVIDIA GPU of Compute Capability +7.0 (check it `here <https://developer.nvidia.com/cuda-gpus>`_) and first install ``cuQuantum Python`` following their installation
`instructions <https://docs.nvidia.com/cuda/cuquantum/latest/python/README.html#installation>`_.
This will include the necessary dependencies such as CUDA toolkit. Then, to install
``pytket-cutensornet``, run:

Expand Down
10 changes: 7 additions & 3 deletions docs/modules/mps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ Matrix Product State (MPS)
Simulation
~~~~~~~~~~

.. autofunction:: pytket.extensions.cutensornet.mps.simulate

.. autoenum:: pytket.extensions.cutensornet.mps.ContractionAlg()
:members:

.. autofunction:: pytket.extensions.cutensornet.mps.simulate
.. autoclass:: pytket.extensions.cutensornet.mps.ConfigMPS()

.. automethod:: __init__

.. autoclass:: pytket.extensions.cutensornet.mps.CuTensorNetHandle


Classes
Expand Down Expand Up @@ -47,8 +53,6 @@ Classes

.. automethod:: __init__

.. autoclass:: pytket.extensions.cutensornet.mps.CuTensorNetHandle


Miscellaneous
~~~~~~~~~~~~~
Expand Down
3 changes: 2 additions & 1 deletion examples/mpi/mpi_overlap_bcast_mps.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

from pytket.extensions.cutensornet.mps import (
simulate,
ConfigMPS,
ContractionAlg,
CuTensorNetHandle,
)
Expand Down Expand Up @@ -108,7 +109,7 @@
this_proc_mps = []
with CuTensorNetHandle(device_id) as libhandle: # Different handle for each process
for circ in this_proc_circs:
mps = simulate(libhandle, circ, ContractionAlg.MPSxGate)
mps = simulate(libhandle, circ, ContractionAlg.MPSxGate, ConfigMPS())
this_proc_mps.append(mps)

if rank == root:
Expand Down
1,230 changes: 1,200 additions & 30 deletions examples/mps_tutorial.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def get_operator_expectation_value(
if isinstance(coeff, Expr):
numeric_coeff = complex(coeff.evalf()) # type: ignore
else:
numeric_coeff = complex(coeff)
numeric_coeff = complex(coeff) # type: ignore
expectation_term = numeric_coeff * cq.contract(
*expectation_value_network.cuquantum_interleaved
)
Expand Down
42 changes: 42 additions & 0 deletions pytket/extensions/cutensornet/general.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2019-2023 Quantinuum
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
##
# http://www.apache.org/licenses/LICENSE-2.0
##
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
from logging import Logger


def set_logger(
logger_name: str,
level: int = logging.WARNING,
fmt: str = "[%(asctime)s] %(name)s (%(levelname)s) - %(message)s",
) -> Logger:
"""Initialises and configures a logger object.
Args:
logger_name: Name for the logger object.
level: Logger output level.
fmt: Logger output format.
Returns:
New configured logger object.
"""
logger = logging.getLogger(logger_name)
logger.setLevel(level)
logger.propagate = False
if not logger.handlers:
handler = logging.StreamHandler()
handler.setLevel(level)
formatter = logging.Formatter(fmt, datefmt="%H:%M:%S")
handler.setFormatter(formatter)
logger.addHandler(handler)
return logger
7 changes: 4 additions & 3 deletions pytket/extensions/cutensornet/mps/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Copyright 2019 Cambridge Quantum Computing
# Copyright 2019-2023 Quantinuum
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
##
# http://www.apache.org/licenses/LICENSE-2.0
#
##
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -20,6 +20,7 @@
from .mps import (
CuTensorNetHandle,
DirectionMPS,
ConfigMPS,
Handle,
Tensor,
MPS,
Expand Down
Loading

0 comments on commit 9714ba7

Please sign in to comment.