Skip to content
This repository was archived by the owner on Nov 7, 2024. It is now read-only.

Add eigenvector=True to torch.symeig due to pytorch=1.4.0 release (#427) - #467

Merged
chaserileyroberts merged 8 commits into
google:masterfrom
IllgamhoDuck:master
Feb 13, 2020
Merged

chaserileyroberts merged 8 commits into
google:masterfrom
IllgamhoDuck:master

Conversation

@IllgamhoDuck

@IllgamhoDuck IllgamhoDuck commented Feb 13, 2020 •

Copy link
Copy Markdown
Contributor

Fix #427

Due to pytorch 1.4.0 version release the torch.symeig now return 0-element eigenvector tensor when eigenvectors=False(default)
https://github.com/pytorch/pytorch/releases

eigvals, u = A_tridiag.symeig()
eigenvectors = []
for n2 in range(min(numeig, len(eigvals))):
state = self.zeros(initial_state.shape, initial_state.dtype)
for n1, vec in enumerate(krylov_vecs):
state += vec * u[n1, n2]

The upper code A_tridiag.symeig() return the value at the following table.

version torch.symeig return
torch 1.3.1 torch.Size([21, 21])
torch 1.4.0 torch.Size([0])

So it brakes at state += vec * u[n1, n2] because there is nothing at u

So we have to add eigenvector=True to the torch.symeig
A_tridiag.symeig() -> A_tridiag.symeig(eigenvector=True)

To fix this add the eigenvector=True parameter to where torch.symeig is used

*1. pytorch_backend.py
    - pytorch_backend.eigsh_lanczos
*2. pytorch_backend_test.py
    - test_eigsh_lanczos_1
    - test_eigsh_lanczos_2
    - test_eigsh_lanczos_reorthogonalize

IllgamhoDuck and others added 7 commits January 17, 2020 13:08
BaseNode class - Add protection to name, axis_names
*Protected in 3 place
*Initialize stage - __init__
*Function use setting - set_name / add_axis_names
*Property - Add @Property to name to protect direct adding node.name = 123

Edge class - Add protection to name
*Protected in 3 place
*Initialize stage - __init__
*Function use setting - set_name
*Property
*if type(name) != str
*if not isinstance(name, str)
*change using type to isinstance to follow pylint
…ogle#427)

Due to pytorch 1.4.0 version release the torch.symeig now return 0-element eigenvector tensor when eigenvectors=False(default)
To fix this add the eigenvector=True parameter to where torch.symeig is used
*1. pytorch_backend.py
    - pytorch_backend.eigsh_lanczos
*2. pytorch_backend_test.py
    - test_eigsh_lanczos_1
    - test_eigsh_lanczos_2
    - test_eigsh_lanczos_reorthogonalize
@IllgamhoDuck

Copy link
Copy Markdown
Contributor Author

@MichaelMarien Sorry for late bit busy :) I finally had time to investigate today

@chaserileyroberts chaserileyroberts left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Ducky!

Can you change the requirements_travis.txt to remove the version requirement for pytorch?

remove pytorch version requirement (==1.3.1) and replace it to (>=1.1)
@IllgamhoDuck

Copy link
Copy Markdown
Contributor Author

@Thenerdstation Sure I changed torch version from (==1.3.1) to (>=1.1) what originally placed 😃

@chaserileyroberts

Copy link
Copy Markdown
Contributor

Beautiful. Thanks!

@chaserileyroberts
chaserileyroberts merged commit 3fdad23 into google:master Feb 13, 2020
mganahl added a commit that referenced this pull request Feb 18, 2020
* default value changed

* fixed bug, old version is now faster again

* cleaned up reshape

* started adding tests

* replace kron with broadcasting

* column-major -> row-major

* documentation

* added function to compute unique charges and charge degeneracies

Function avoids explicit full fusion of all legs, and instead only keeps track of the unique charges and their degeneracies upon fusion

* improved block finding, fixed bug in reshape

re-intorduced BlockSparseTensor.dense_shape
new method for fusing charges and degeneracies (faster for very rectangular matrices)

* fuse_charge_pair added

fuse_charges added

* use is_leave

* new tests

* removed TODO, BlockSparseTensor.shape returns ref instead of copy

* added tests

* added tests

* column-major -> row-major

forgot to fix fusing order of charges and degeneracies

* fix broken tests

* test added

* mostly docstring

* docstring

* added map_to_integer

* test for map_to_integer

* added functions to find sparse positions when fusing two charges

* renaming of routines

* added unfuse

* test unfuse

* fixed bug in the new routine for finding diagonal blocks

* test added

* docstring

* added tests

* renaming

* tests

* transpose added, map_to_integer removed

(used np.unravel_index and np.ravel_multi_index instead)

* find_dense_positions made faster

* working on transpose

* transpose modified

* Index.name -> property

* added charge types

* adding tests

* fixing bugs

* implementing more symmetries

* typo + remove cython lookup

* split charge.py from index.py

* tests for charge.py

* test added

* added matmul

* added test for matmul

* tests + allow np.int8

* typo

* undo typo

* test\

* savety commit, starting to add multiple charges

* Charge -> ChargeCollection

* removed offsets from U1Charge (unnecessary), Charge -> ChargeCollection

* new tests

* tests for new index

* new Index class

* new block tensor

* shorter code

* add __eq__, remove nonzero, add unique

* working on charges.py

* fix small bug in  BaseCharge.__init__

* fix tests after bugfix

* tests for equals() and __eq__

* added equals()

for comparing with unshifted target charges
__eq__ now only compares shifted target charges

* added typing

* ChargeCollection.__repr__ modified

* *** empty log message ***

* this commit is not working

* fix bug in __len__

fix various bugs in __eq__ and __getitem__

* working in implemetation of multiple charges

* bugfix in ChargeCollection.__getitem__

* adding tests

* sleep commit

* added iterators

* ChargeCollection.__init__:

charges are now always stacked, self.charges contain views to the stacked
charges
__init__ can be called with optional shifts and stacked_charges to initialize
the BaseCharges object with it

* lunch commit

* back from lunch

* tests added

* ported find_sparse_positions and find_diagonal_sparse_blocks to new charge interface

* broken commit

* fixed bug in find_dense_positions

* fix bug in find_dense_positions

* docstring

* fix bug in Index initialization

* fix bug in Index initialization

* typo

* remove __rmul__ calls of ChargeCollection and BaseCharge

* removed __rmul__

* removed some bugs inb transpose

* broken commit

* broken commit

* remove csr matrix, use search sorted

* remove unfuse, use divmod

* broken commit, working on tensordot

* tensordot implemented, not tested

* removed commented codex

* fix tests

* fix tests

* added test for BlockSparseTensor back

* renaming files

* fix tutorial, fix import

* faster find_dense_positions

* added intersect to BaseCharge

* broken commmit (Apple sucks big time)

* broken commit

* broken commit

* broken commit

* broken commit

* broken

* added `return_indices` to intersect

* faster transpose + tensordot implementation

* rewrote find_dense_positions to take multipe charges

avoids a for loop in _find_diagonal_dense_blocks and speeds up the code

* find_sparse_positions update to be a tiny bit faster

* fix bug in _get_diagonal_dense_blocks

* fix bug

* fixed bug in transpose

* fixed final_order passing for tensordot

* improved performance, but only u1 currently supported in this commit

* merging Glen's and my code

* fix bug in unique

* adding/removing tests

* add benchmark file

* adding files

* deleted some files

* fix bug

* renaming and shortening

* cleaning up code

* cleaning up

* removed _check_flows

* remove a print

* fix bug

* nothing

* fix big in flatten_meta_data

* added bunch of tests

* added inner and outer product

* removed binary tree, switched to a list of charges

* added copy()

* bugfix

* added __add__ __sub__ __mul__ __rmul__

* added __eq__

* change dosctring

* added svd

* better check

* add proper compute_uv flag , remove artifact return values

* added qr, eigh, eig

* added tests

* fix tests

* fix index bugs

* fixed bug in unique

* renaming some variables

mostly

* renaming some variables

mostly

* added decompositions

* svd now returns singvals in a vector

* svd_decomposition returns s in a vector now

* fix tests

* fix tests

* added ChargeArray, a 1d array storing a vector and charges

* fix bug in decompositions.py

* adding ChargeArray, and some other stuff

* added test

* added tests

* change trunction to have same connvention as other backends

* added sqrt

* added bunch of linalg and initialization

* more tests

* fix return values of flat_flows

* added tests

* added test

* added __len__

* added tests

* adding tests

* added bunch of tests

* linting

* linting

* linting

* typing

* linting

* fix typing

* fix tutorial

* added __init__

* added __init__

* rename module block_tensor -> block_sparse

* fixed bug in tensordot

* add symmetric backend

* ChargeArray: index-> indices

* fix rand and random of ChargeArray

* add symmetric support to split_node

* raise error in convert_to_tensor

* formatting

* add tests for symmetric backend

* linting

* added tests, typing, linting and other

* tests added

* fix trace issues

* fix issue in todense()

* add tests

* fix tests

* fix tests

* fix benchmark

* linting + tests

* linting

* fix test

* fixed broken test

* fix fix

* fix bug in reshape

* fix bugs

* added `sparse_shape` to backends

* add flag to BlockSparseTensor.__init__ to skip checks

* Add eigenvector=True to torch.symeig due to pytorch=1.4.0 release (#427) (#467)

* BaseNode / Edge class text input protection added (#423)

BaseNode class - Add protection to name, axis_names
*Protected in 3 place
*Initialize stage - __init__
*Function use setting - set_name / add_axis_names
*Property - Add @Property to name to protect direct adding node.name = 123

Edge class - Add protection to name
*Protected in 3 place
*Initialize stage - __init__
*Function use setting - set_name
*Property

* BaseNode / Edge class text input protection code revise (#423)

*if type(name) != str
*if not isinstance(name, str)
*change using type to isinstance to follow pylint

* Add eigenvector=True to torch.symeig due to pytorch=1.4.0 release (#427)

Due to pytorch 1.4.0 version release the torch.symeig now return 0-element eigenvector tensor when eigenvectors=False(default)
To fix this add the eigenvector=True parameter to where torch.symeig is used
*1. pytorch_backend.py
    - pytorch_backend.eigsh_lanczos
*2. pytorch_backend_test.py
    - test_eigsh_lanczos_1
    - test_eigsh_lanczos_2
    - test_eigsh_lanczos_reorthogonalize

* Update requirements_travis.txt (#427)

remove pytorch version requirement (==1.3.1) and replace it to (>=1.1)

Co-authored-by: Chase Roberts <chaseriley@google.com>

* indices are gone from BlockSparseTensor.__init__

transposes are now lazy

* fixed tests to conform to new lazy transpose and tensor layout

* fixed some issues in diag, change compute_sparse_lookup

* remove commented code

* fix pinv

* fix

* pinv fixed

* fix return types of empty result in _find_transposed_diagonal_sparse_blocks

* fix bug in trace

* clean code

* fix tests for backend

* docstrings

* docstrings

* remove commented code

* remove commented code

* fix typing

* docstrings

* linting

* linting

* change requirements: np >= 1.17

Co-authored-by: Hyunbyung, Park <hyunbyung87@gmail.com>
Co-authored-by: Chase Roberts <chaseriley@google.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pytorch 1.4.0 breaks our build

3 participants