0
$\begingroup$

I'm looking for a Python library that can help me simulating quantum circuit using Tensor Networks. In particular I would like to write a quantum circuit using the constiuent quantum gates and then using tensor network with a precise approximation (e.g. bond dimension in MPS). I didn't find any Python library that gives me the possibility of specifying the bond dimension (in the context of quantum circuits).

It would be awesome if it is also possible to calculate the expectation value of an observable (e.g. $\langle Z \rangle$ of the first qubit of the final quantum state at the end of the circuit) exactly (without a finite number of shots). This can be easily done in the library "quimb", but I didn't find a way to specify the bond dimension or similar parameters in the context of quantum circuits.

Thank you.

$\endgroup$

3 Answers 3

0
$\begingroup$

You may want to try TorchMPS. It allows to specify the bond dimension using the parameter bond_dim:

from torchmps.torchmps import MPS

my_mps = MPS(input_dim=32**2, output_dim=10, bond_dim=16)

# Now get a batch of (flattened) images to classify...

batch_scores = my_mps(batch_images)

In Section Similar Software there is a list of alternative packages you may want to consider.

$\endgroup$
1
  • 1
    $\begingroup$ Thank you. How can I use this module to study quantum circuits? $\endgroup$
    – stopper
    Commented Apr 20, 2023 at 13:52
0
$\begingroup$

Qristal is an open-source Python and C++ SDK which can quickly setup MPS bond dimension and a circuit. You can get a Docker container image using:

docker run --rm -it --name qristal \
-d -p 8889:8889 \
registry.gitlab.com/qbau/software-and-apps/public/qbsdk/qristal-sdk

Once the container starts, visit http://localhost:8889

Then use this example Python code in a Jupyter notebook and set bond dimension of the MPS using:

import qb.core
tqb = qb.core.session(True)
tqb.qb12()

tqb.acc = "tnqvm"
tqb.qn = 6        # 6 qubits
tqb.random = 5    # Depth 5 random circuit
tqb.max_bond_dimension  # Shows the current setting of max bond dimension

tqb.max_bond_dimension = 16   # Set the max bond dimension to 16
tqb.run()    # Runs the circuit on the ExaTN MPS simulator

tqb.out_raw[0]   # Displays the shot outcomes
tqb.out_z_op_expect[0][0][0]  # Z-expectation calculated from shot outcomes

Here is screenshot of the output: Screenshot of output from Qristal demonstrating setting the max. bond dimension for the ExaTN MPS simulator

$\endgroup$
1
  • $\begingroup$ @stopper, note the expectation you get in the above is over a finite number of shots. Can you clarify further what you mean by "<Z> of the first qubit...without a finite number of shots"? $\endgroup$ Commented Sep 21, 2023 at 0:53
-1
$\begingroup$

It seems that Qiskit recently introduced a way to specify the bond dimension: https://qiskit.org/ecosystem/aer/stubs/qiskit_aer.AerSimulator.html

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.