Skip to content

Commit

Permalink
Basic TTN simulation (#41)
Browse files Browse the repository at this point in the history
* Created new general.py file for logger and cutensornet handle. Updated copyright comment.
* Moved MPS code to make room for TTN.

* Moved ConfigMPS to Config in general.py

* Began implementation of TTN

* Added single-qubit gate support and some basic tests.

* Added vdot to TTN

* Implemented get_amplitude and get_statevector. Current tests passing.

* Implemented canonicalisation

* Canonicalisation debugged

* Exact apply 2q gate implemented and debugged

* Added truncation by chi and value_of_zero

* Unified TTN and MPS via StructuredState abstract class

* _get_qubit_partition now does recursive balanced bisections.

* Added truncation_fidelity approach to TTNxGate

Co-authored-by: Iakov Polyak <[email protected]>

* Updated docstring.

---------

Co-authored-by: PabloAndresCQ <[email protected]>
Co-authored-by: Iakov Polyak <[email protected]>
  • Loading branch information
3 people authored Feb 2, 2024
1 parent a7b10bd commit 4317b14
Show file tree
Hide file tree
Showing 17 changed files with 3,959 additions and 1,795 deletions.
2 changes: 1 addition & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ API documentation

.. toctree::
modules/fullTN.rst
modules/mps.rst
modules/structured_state.rst
63 changes: 0 additions & 63 deletions docs/modules/mps.rst

This file was deleted.

61 changes: 61 additions & 0 deletions docs/modules/structured_state.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
Structured state evolution
==========================

.. automodule:: pytket.extensions.cutensornet.structured_state


Simulation
~~~~~~~~~~

.. autofunction:: pytket.extensions.cutensornet.structured_state.simulate

.. autoenum:: pytket.extensions.cutensornet.structured_state.SimulationAlgorithm()
:members:

.. autoclass:: pytket.extensions.cutensornet.structured_state.Config()

.. automethod:: __init__

.. autoclass:: pytket.extensions.cutensornet.structured_state.CuTensorNetHandle


Classes
~~~~~~~

.. autoclass:: pytket.extensions.cutensornet.structured_state.StructuredState()

.. automethod:: __init__
.. automethod:: is_valid
.. automethod:: apply_gate
.. automethod:: apply_scalar
.. automethod:: vdot
.. automethod:: sample
.. automethod:: measure
.. automethod:: postselect
.. automethod:: expectation_value
.. automethod:: get_fidelity
.. automethod:: get_statevector
.. automethod:: get_amplitude
.. automethod:: get_qubits
.. automethod:: get_byte_size
.. automethod:: get_device_id
.. automethod:: update_libhandle
.. automethod:: copy

.. autoclass:: pytket.extensions.cutensornet.structured_state.TTNxGate()

.. automethod:: __init__

.. autoclass:: pytket.extensions.cutensornet.structured_state.MPSxGate()

.. automethod:: __init__

.. autoclass:: pytket.extensions.cutensornet.structured_state.MPSxMPO()

.. automethod:: __init__


Miscellaneous
~~~~~~~~~~~~~

.. autofunction:: pytket.extensions.cutensornet.structured_state.prepare_circuit_mps
8 changes: 4 additions & 4 deletions examples/mpi/mpi_overlap_bcast_mps.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@

from pytket.circuit import Circuit, fresh_symbol

from pytket.extensions.cutensornet.mps import (
from pytket.extensions.cutensornet.structured_state import (
simulate,
ConfigMPS,
ContractionAlg,
Config,
SimulationAlgorithm,
CuTensorNetHandle,
)

Expand Down Expand Up @@ -109,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, ConfigMPS())
mps = simulate(libhandle, circ, SimulationAlgorithm.MPSxGate, Config())
this_proc_mps.append(mps)

if rank == root:
Expand Down
2,260 changes: 1,122 additions & 1,138 deletions examples/mps_tutorial.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit 4317b14

Please sign in to comment.