Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KSL not running properly on docker #95

Open
emulvi opened this issue Dec 13, 2022 · 8 comments
Open

KSL not running properly on docker #95

emulvi opened this issue Dec 13, 2022 · 8 comments
Assignees
Labels

Comments

@emulvi
Copy link

emulvi commented Dec 13, 2022

After adding a random tt of rank 5+ as noise to a tt with rank 1 to reach a rank of 6+, when ksl propagates it on docker, the rank is 1 instead of maintaining the rank of the tt inputed to ksl.

For example, with the code:

    # initial tensor of up and down spins, will have rank 1
    spins = [np.array([0, 1]), np.array([1, 0])]
    initState = [1, 1, 0, 0, 1, 1, 0, 0]
    y0 = tt.tensor(spins[initState[0]])
    for i in range(1, 8):
        y0 = tt.kron(y0, tt.tensor(spins[initState[i]]))

    # hamiltonian, created in a separate function
    A = ham() 
        
    # loop to see behavior when the rank of the noise is increased
    for i in range(1, 7):
        print("i = ", i)

        # generate a random tensor with rank i
        tt_rand = tt.rand(y0.n, y0.d, i)
        tt_rand = tt_rand * tt_rand.norm()**(-1)

        # make the tt_rand a very small noise
        tt_rand = tt_rand * 10**(-1. * (10 + i))

        # add the random tensor to artificially increase the rank of y to 1 + i
        y = y0 + tt_rand
        y = y.round(10**(-1. * (30 + i)))

        print("rank before propagation = ", y.r)
        y = tt.ksl.ksl(A, y, 0.1)
        print("rank after propagation = ", y.r)`

The output with docker is:

i =  1
rank before propagation =  [1 2 2 2 2 2 2 2 1]
rank after propagation =  [1 2 2 2 2 2 2 2 1]
i =  2
rank before propagation =  [1 2 3 3 3 3 3 2 1]
rank after propagation =  [1 2 3 3 3 3 3 2 1]
i =  3
rank before propagation =  [1 2 4 4 4 4 4 2 1]
rank after propagation =  [1 2 3 4 4 4 4 2 1]
i =  4
rank before propagation =  [1 2 4 5 5 5 4 2 1]
rank after propagation =  [1 2 2 3 3 3 3 2 1]
i =  5
rank before propagation =  [1 2 4 6 6 6 4 2 1]
rank after propagation =  [1 1 1 1 1 1 1 1 1]
i =  6
rank before propagation =  [1 2 4 7 7 7 4 2 1]
rank after propagation =  [1 1 1 1 1 1 1 1 1]

Whereas the output with ttpy from github is:

i =  1
rank before propagation =  [1 2 2 2 2 2 2 2 1]
rank after propagation =  [1 2 2 2 2 2 2 2 1]
i =  2
rank before propagation =  [1 2 3 3 3 3 3 2 1]
rank after propagation =  [1 2 3 3 3 3 3 2 1]
i =  3
rank before propagation =  [1 2 4 4 4 4 4 2 1]
rank after propagation =  [1 2 4 4 4 4 4 2 1]
i =  4
rank before propagation =  [1 2 4 5 5 5 4 2 1]
rank after propagation =  [1 2 4 5 5 5 4 2 1]
i =  5
rank before propagation =  [1 2 4 6 6 6 4 2 1]
rank after propagation =  [1 2 4 6 6 6 4 2 1]
i =  6
rank before propagation =  [1 2 4 7 7 7 4 2 1]
rank after propagation =  [1 2 4 7 7 7 4 2 1]
@daskol
Copy link
Collaborator

daskol commented Dec 13, 2022

What is version of ttpy packages?

@emulvi
Copy link
Author

emulvi commented Dec 13, 2022

I downloaded the github version in February of this year, so I believe that is version 1.2.1. I did docker pull daskol/ttpy yesterday and ran docker inline as

$ docker run -it --rm -v "$PWD":/workspace daskol/ttpy
Python 3.10.6 (main, Aug  3 2022, 10:13:24) [GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

@emulvi
Copy link
Author

emulvi commented Dec 13, 2022

I also ran it on google colab to see how it would be behave; it installed version 1.2.1:

Screen Shot 2022-12-13 at 1 32 36 PM

and it gave the same output as my laptop, with the rank conserved:

Screen Shot 2022-12-13 at 1 36 28 PM

@emulvi
Copy link
Author

emulvi commented Dec 13, 2022

Looking at the ksl.py file in the tar file at https://pypi.org/project/ttpy/#files, it is different from the one here on github. Notably, there's a y0 = y0.round(1e-14) at line 65 on github that isn't in the pypi verions; that could be causing the change in rank.

@daskol
Copy link
Collaborator

daskol commented Dec 14, 2022

Yes. Package ttpy in PyPI is outdated and doesn't have some fixes so you can install ttpy directly from GitHub

git clone --recursive https://github.com/oseledets/ttpy.git
pip install ttpy

or use docker image.

@emulvi
Copy link
Author

emulvi commented Dec 14, 2022

The problem is that the version of ksl on github and docker is not working properly because it is changing the rank within the propagation. I think the problem is the line 65 with y0 = y0.round(1e-14), which was also noted in issue #79.

@daskol
Copy link
Collaborator

daskol commented Dec 14, 2022

I have deleted the line in #96. We need investigate commit 0e7bf47. It looks like a garbage hotfix for nothing.

@daskol daskol self-assigned this Dec 14, 2022
@daskol daskol added the bug label Dec 14, 2022
@emulvi
Copy link
Author

emulvi commented Dec 16, 2022

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants