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

Start using ITensorMPS.jl #7

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mtfishman
Copy link

No description provided.

@mtfishman
Copy link
Author

Looks like testing CI isn't set up, but locally I see a lot of test failures when using the latest NDTensors and ITensors which are unrelated to the introduction of ITensorMPS in this PR.

@mtfishman
Copy link
Author

mtfishman commented May 10, 2024

Looks like the function ITensorMPOCompression.get_subtensor_wrapper(::DenseTensor, inds, ::UnitRange{Int}...) defined here:

function get_subtensor_wrapper(
T::DenseTensor{ElT,N}, new_inds, rs::UnitRange{Int64}...
) where {ElT,N}
return ITensor(T[rs...], new_inds)
end

is hitting this bug in NDTensors.jl:

using ITensors: Index, ITensor, randomITensor
using NDTensors: Tensor
i, j = Index.((4, 4))
it = randomITensor(i, j)
t = Tensor(it)
t_sub = t[1:2, 1:2]
i_sub, j_sub = Index.((2, 2))
ITensor(t_sub, (i_sub, j_sub))

which outputs:

ERROR: LoadError: Type parameter position not defined for type `NDTensors.DenseTensor{Float64, 2, Tuple{Int64, Int64}, NDTensors.Dense{Float64, Base.ReshapedArray{Float64, 1, SubArray{Float64, 2, Matrix{Float64}, Tuple{UnitRange{Int64}, UnitRange{Int64}}, false}, Tuple{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64}}}}}` and position name `eltype`.
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] position(type::Type, pos::Function)
    @ NDTensors.TypeParameterAccessors ~/.julia/packages/NDTensors/IQ76r/src/lib/TypeParameterAccessors/src/position.jl:8
  [3] _broadcast_getindex_evalf
    @ ./broadcast.jl:709 [inlined]
  [4] _broadcast_getindex
    @ ./broadcast.jl:692 [inlined]
  [5] (::Base.Broadcast.var"#31#32"{Base.Broadcast.Broadcasted{}})(k::Int64)
    @ Base.Broadcast ./broadcast.jl:1118
  [6] ntuple
    @ ./ntuple.jl:49 [inlined]
  [7] copy
    @ ./broadcast.jl:1118 [inlined]
  [8] materialize
    @ ./broadcast.jl:903 [inlined]
  [9] set_type_parameters(type::Type, positions::Tuple{…}, params::Tuple{…})
    @ NDTensors.TypeParameterAccessors ~/.julia/packages/NDTensors/IQ76r/src/lib/TypeParameterAccessors/src/set_parameters.jl:42
 [10] set_eltype(::Type{NDTensors.TypeParameterAccessors.IsWrappedArray{…}}, type::Type{NDTensors.DenseTensor{…}}, param::Type)
    @ NDTensors.TypeParameterAccessors ~/.julia/packages/NDTensors/IQ76r/src/lib/TypeParameterAccessors/src/base/abstractarray.jl:62
 [11] set_eltype
    @ ~/.julia/packages/SimpleTraits/l1ZsK/src/SimpleTraits.jl:331 [inlined]
 [12] ITensor(as::NDTensors.NeverAlias, eltype::Type{…}, A::NDTensors.DenseTensor{…}, inds::Tuple{…}; kwargs::@Kwargs{})
    @ ITensors ~/.julia/packages/ITensors/Gg1Hv/src/itensor.jl:360
 [13] ITensor(as::NDTensors.NeverAlias, eltype::Type{…}, A::NDTensors.DenseTensor{…}, inds::Tuple{…})
    @ ITensors ~/.julia/packages/ITensors/Gg1Hv/src/itensor.jl:348
 [14] ITensor(as::NDTensors.NeverAlias, A::NDTensors.DenseTensor{…}, is::Tuple{…}; kwargs::@Kwargs{})
    @ ITensors ~/.julia/packages/ITensors/Gg1Hv/src/itensor.jl:414
 [15] ITensor(as::NDTensors.NeverAlias, A::NDTensors.DenseTensor{…}, is::Tuple{…})
    @ ITensors ~/.julia/packages/ITensors/Gg1Hv/src/itensor.jl:411
 [16] ITensor(A::NDTensors.DenseTensor{…}, is::Tuple{…}; kwargs::@Kwargs{})
    @ ITensors ~/.julia/packages/ITensors/Gg1Hv/src/itensor.jl:424
 [17] ITensor(A::NDTensors.DenseTensor{Float64, 2, Tuple{…}, NDTensors.Dense{…}}, is::Tuple{Index{…}, Index{…}})
    @ ITensors ~/.julia/packages/ITensors/Gg1Hv/src/itensor.jl:423
 [18] top-level scope
    @ ~/Simons Foundation Dropbox/Matthew Fishman/Documents/workdir/ITensors.jl/issues/itensor_slicing_bug/itensor_slicing_bug.jl:8
 [19] include(fname::String)
    @ Base.MainInclude ./client.jl:489
 [20] top-level scope
    @ REPL[4]:1
in expression starting at /Users/mfishman/Simons Foundation Dropbox/Matthew Fishman/Documents/workdir/ITensors.jl/issues/itensor_slicing_bug/itensor_slicing_bug.jl:8
Some type information was truncated. Use `show(err)` to see complete types.

with versions:

julia> versioninfo()
Julia Version 1.10.3
Commit 0b4590a5507 (2024-04-30 10:59 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 10 × Apple M1 Max
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)

julia> using Pkg; Pkg.status()
Status `.../Project.toml`
  [9136182c] ITensors v0.6.1
  [23ae76d9] NDTensors v0.3.4

@JanReimers @kmp5VT

@mtfishman
Copy link
Author

I raised an issue here: ITensor/ITensors.jl#1431

@mtfishman
Copy link
Author

I've confirmed locally that with the fix in ITensor/ITensors.jl#1441 and the ITensor constructor in get_subtensor_wrapper changed over to using the TensorStorage instead of the Tensor the error I reported above goes away.

Not all tests pass, I believe because this codebase is relying on this PR: ITensor/ITensors.jl#1099. So this PR is stalled for the time being.

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.

1 participant