quicophy / mdopt

Discrete optimization in the tensor-network (specifically, MPS-MPO) language.
http://mdopt.readthedocs.io/
MIT License
30 stars 3 forks source link

MPS-rand-circ fails with type error #276

Closed twobombs closed 1 month ago

twobombs commented 3 months ago

What happened?

whilst running MPS-rand-circ a type error pops up - preventing the notebook to continue https://github.com/quicophy/mdopt/blob/main/examples/random_circuit/mps-rand-circ.ipynb

Screenshot from 2024-07-13 09-19-15

What did you expect to happen?

a random circ test

Minimal Complete Verifiable Example

No response

Relevant log output

No response

Anything else we need to know?

Python 3.10.12 on jupyter notebook Screenshot from 2024-07-13 09-25-08

Environment

occurs both with pip3 install mdopt and from main installing it with -r requirements.txt

meandmytram commented 2 months ago

Hey @twobombs, thanks a lot for reporting this and very sorry for a late response, let me look into it and get back to you shortly!

meandmytram commented 2 months ago

@twobombs Can you try reproducing the error from the current version of the main branch please?

twobombs commented 2 months ago

I forgot to mention last time wich could be important: after removing the random_circuit double declaration leaving only examples to import the notebook runs image this time it stops at the same place with the same error image

meandmytram commented 2 months ago

Hey @twobombs, thanks for the clarification!

First, the imports for the examples folder in a notebook might require adding the directory to the os.path. Feel free to open a PR, that should be just a one-liner: smth like try import ... and except ModuleNotFoundError os.path[0].append(...). In the newest version of the main the examples folder has subdirectories to isolate different examples from each other.

Second, the current version of the function mps.utils.create_simple_product_state has an argument called tolerance which corresponds to how much we can deviate from "real" (normalised) quantum states. Thus the second error must go away once the main branch is pulled.

Thanks a bunch and let me know!