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

[Enhancement] Add quantum number support in TTNO constructor. #116

Merged
merged 34 commits into from
Jan 11, 2024

Conversation

b-kloss
Copy link
Contributor

@b-kloss b-kloss commented Jan 8, 2024

This PR generalizes the existing constructor of a TTN from an OpSum and IndsNetwork (svdTTN) to physical indices with QNs (qn_svdTTN). This implementation closely follows the parallel logic in ITensors.svdMPO and ITensors.qn_svdMPO. Tests of the functionality (at the same level as tests of the existing constructor) have been added.

ToDo:

  • test/generalize for TTN's with vertices without physical indices
  • implement autoFermion support
  • test whether QN code can be used also for non-QN siteinds with the goal to remove non-QN code
  • implement profiling/instrumentation for future performance optimizations
  • add function barrier for type stability
  • change to snaking case
  • move non-QN functionality into a deprecated.jl file

@mtfishman
Copy link
Member

Not sure what these test failures are, they look unrelated to this PR.

@b-kloss do you see them locally? @JoeyT1994 have you seen these?

@mtfishman
Copy link
Member

Working on fixing some test issues in #118.

@mtfishman
Copy link
Member

mtfishman commented Jan 10, 2024

#118 fixed tests on Julia 1.10, I merged it into main. Could you merge the latest main into your branch and see if we can get tests to pass at least on Julia 1.10?

@b-kloss
Copy link
Contributor Author

b-kloss commented Jan 10, 2024

I am running the tests right now, will update this when they are done.
I also edited the code to be compatible with internal indices (minor changes only) locally --- Would you prefer to put that in a separate PR or review the changes here?

@b-kloss
Copy link
Contributor Author

b-kloss commented Jan 10, 2024

On Julia Version 1.9.3 I get errors from the tebd test:
Running test file test_tebd.jl
Ising TEBD: Error During Test at /home/bkloss/.julia/dev/ITensorNetworks/test/test_tebd.jl:7
Got exception outside of a @test
MethodError: no method matching sort(::Tuple{Index{Int64}, Index{Int64}}; by::typeof(plev))

Closest candidates are:
sort(::Union{OrderedCollections.OrderedDict, OrderedCollections.OrderedSet}; args...)
@ OrderedCollections ~/.julia/packages/OrderedCollections/9C4Uz/src/dict_sorting.jl:34
sort(::AbstractIndices{I}; kwargs...) where I
@ Dictionaries ~/.julia/packages/Dictionaries/7aBxp/src/AbstractIndices.jl:376
sort(::AbstractUnitRange) got unsupported keyword argument "by"
@ Base range.jl:1397
...

Stacktrace:
[1] permute(M::MPO, #unused#::Tuple{typeof(linkind), typeof(siteinds), typeof(linkind)})
@ ITensors ~/.julia/dev/ITensors/src/mps/dmrg.jl:13
[2] #dmrg#1051
@ ~/.julia/dev/ITensors/src/mps/dmrg.jl:25 [inlined]
[3] dmrg
@ ~/.julia/dev/ITensors/src/mps/dmrg.jl:20 [inlined]
[4] #dmrg#1057
@ ~/.julia/dev/ITensors/src/mps/dmrg.jl:389 [inlined]
[5] macro expansion
@ ~/.julia/dev/ITensorNetworks/test/test_tebd.jl:24 [inlined]

@b-kloss b-kloss changed the title [Enhancement] Add quantum number support in TTNO constructor, qn_svdTTN. [Enhancement] Add quantum number support in TTNO constructor. Jan 10, 2024
@mtfishman
Copy link
Member

@b-kloss #119 should fix another test error that popped up.

@mtfishman
Copy link
Member

I am running the tests right now, will update this when they are done. I also edited the code to be compatible with internal indices (minor changes only) locally --- Would you prefer to put that in a separate PR or review the changes here?

Let's still plan to put it in a separate PR, this one has become pretty unwieldy to review as it is. It will be easier for me to see what changes are required for that based on diffs.

@JoeyT1994
Copy link
Contributor

JoeyT1994 commented Jan 11, 2024

All tests pass on my local build (Linux, Julia 1.9.2) which is pinned to the latest merges you have done on ITensorNetwork (Merge #119 ). This is my package list:

image

Looks like some strange behaviour coming from Julia 1.7. Maybe recent updates to one of the dependencies aren't compatible with it.

@mtfishman
Copy link
Member

mtfishman commented Jan 11, 2024

Thanks for checking @JoeyT1994. So on main it seems like their is some issue on Julia 1.7, which is pretty strange but not worth worrying about right now if things are working on Julia 1.9 and 1.10.

@b-kloss, it looks like this test is failing: https://github.com/mtfishman/ITensorNetworks.jl/blob/aff21aa79cf649e2b3c104e0cf44cc0ef10856ba/test/test_treetensornetworks/test_solvers/test_dmrg_x.jl#L52-L56 since it is assuming that QN TTNO construction is broken. Could you remove those lines and see if that fixes that test?

@JoeyT1994
Copy link
Contributor

JoeyT1994 commented Jan 11, 2024

I also (since this morning) am running into this issue when first booting up Julia (1.8/1.9) and calling using ITensorNetworks

image

Not sure if it's related or just something to do with my environment?

It goes away after calling Pkg.resolve()

@mtfishman
Copy link
Member

Yeah, that's unrelated.

@b-kloss
Copy link
Contributor Author

b-kloss commented Jan 11, 2024

Hi,
I still get failing tests (on 1.9.3) both for TEBD and and DMRG(_X), seem to be related to lack of implementation of sort in both cases.

MPS DMRG-X: Error During Test at /home/bkloss/.julia/dev/ITensorNetworks/test/test_treetensornetworks/test_solvers/test_dmrg_x.jl:6
Got exception outside of a @test
MethodError: no method matching sort(::Tuple{Int64})

Closest candidates are:
sort(::Union{OrderedCollections.OrderedDict, OrderedCollections.OrderedSet}; args...)
@ OrderedCollections ~/.julia/packages/OrderedCollections/9C4Uz/src/dict_sorting.jl:34
sort(::AbstractIndices{I}; kwargs...) where I
@ Dictionaries ~/.julia/packages/Dictionaries/7aBxp/src/AbstractIndices.jl:376
sort(::AbstractUnitRange)
@ Base range.jl:1397
...

Stacktrace:
[1] permutedims_combine_output(T::NDTensors.BlockSparseTensor{Float64, 2, Tuple{Index{Vector{Pair{QN, Int64}}}, Index{Vector{Pair{QN, Int64}}}}, NDTensors.BlockSparse{Float64, Vector{Float64}, 2}}, is::Tuple{Index{Vector{Pair{QN, Int64}}}, Index{Vector{Pair{QN, Int64}}}}, perm::Tuple{Int64, Int64}, combdims::Tuple{Int64}, blockperm::Vector{Int64}, blockcomb::Vector{Int64})
@ NDTensors ~/.julia/dev/ITensors/NDTensors/src/blocksparse/blocksparsetensor.jl:439
[2] permutedims_combine(T::NDTensors.BlockSparseTensor{Float64, 2, Tuple{Index{Vector{Pair{QN, Int64}}}, Index{Vector{Pair{QN, Int64}}}}, NDTensors.BlockSparse{Float64, Vector{Float64}, 2}}, is::Tuple{Index{Vector{Pair{QN, Int64}}}, Index{Vector{Pair{QN, Int64}}}}, perm::Tuple{Int64, Int64}, combdims::Tuple{Int64}, blockperm::Vector{Int64}, blockcomb::Vector{Int64})
@ NDTensors ~/.julia/dev/ITensors/NDTensors/src/blocksparse/blocksparsetensor.jl:467
[3] contract(tensor::NDTensors.BlockSparseTensor{Float64, 2, Tuple{Index{Vector{Pair{QN, Int64}}}, Index{Vector{Pair{QN, Int64}}}}, NDTensors.BlockSparse{Float64, Vector{Float64}, 2}}, tensor_labels::Tuple{Int64, Int64}, combiner_tensor::NDTensors.Tensor{Number, 2, NDTensors.Combiner, Tuple{Index{Vector{Pair{QN, Int64}}}, Index{Vector{Pair{QN, Int64}}}}}, combiner_tensor_labels::Tuple{Int64, Int64})
@ NDTensors ~/.julia/dev/ITensors/NDTensors/src/blocksparse/combiner.jl:72

@mtfishman
Copy link
Member

Seems like maybe you have an outdated version of NDTensors, that should be fixed in more recent versions.

@b-kloss
Copy link
Contributor Author

b-kloss commented Jan 11, 2024

The tests on 1.10 are passing, and things also work on my machine locally on 1.9.3 . Should be good to merge.

@mtfishman mtfishman merged commit 0b72b7c into ITensor:main Jan 11, 2024
6 of 11 checks passed
@b-kloss b-kloss deleted the AutoTTNO branch February 2, 2024 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants