LinearMaps and ITensors incompatibility?

I am encountering strange incompatibility between LinearMaps and ITensors. I have LinearMaps v3.11.3 and ITensors v0.7.11. “using” hangs when I try to do both:

faraday% julia
_
_ _ ()_ | Documentation: https://docs.julialang.org
() | () () |
_ _ | | __ _ | Type “?” for help, “]?” for Pkg help.
| | | | | | |/ ` | |
| | |
| | | | (
| | | Version 1.11.3 (2025-01-21)
/ |_|||_’_| | Official https://julialang.org/ release
|__/ |

julia> using LinearMaps

julia>
faraday% julia
_
_ _ ()_ | Documentation: https://docs.julialang.org
() | () () |
_ _ | | __ _ | Type “?” for help, “]?” for Pkg help.
| | | | | | |/ ` | |
| | |
| | | | (
| | | Version 1.11.3 (2025-01-21)
/ |_|||_’_| | Official https://julialang.org/ release
|__/ |

julia> using ITensors

julia>
faraday% julia
_
_ _ ()_ | Documentation: https://docs.julialang.org
() | () () |
_ _ | | __ _ | Type “?” for help, “]?” for Pkg help.
| | | | | | |/ ` | |
| | |
| | | | (
| | | Version 1.11.3 (2025-01-21)
/ |_|||_’_| | Official https://julialang.org/ release
|__/ |

julia> using LinearMaps, ITensors

Hi Steve, that is really strange, I’m seeing the same thing. I’ve never seen anything like that, I don’t even know where to start in terms of debugging that… It seems to have something to do with the precompilation step, but I don’t know why that combination of packages is causing issues for that.

Have you been able to load both of those packages before with older versions?

Yes, I’ve had both included with using for years. When I first saw this, I thought it was because my ITensors package was not updating to the most recent version because of dependencies. It was at v0.6 something. So I resolved the dependencies to get the latest versions of both, but the issue was still there.

Does ITensors itself use LinearMaps?

It used to at some point, but not anymore.

On my machine in a clean project environment, I see the following:

julia> @time using ITensors, LinearMaps
253.731965 seconds (668.87 M allocations: 26.942 GiB, 0.99% gc time, 0.09% compilation time: 97% of which was recompilation)

(jl_UZZAhk) pkg> st
Status `/private/var/folders/qz/q22pzwm144z9fq57mpf1hfp40000gq/T/jl_UZZAhk/Project.toml`
  [9136182c] ITensors v0.7.11
  [7a12625a] LinearMaps v3.11.3

julia> versioninfo()
Julia Version 1.11.3
Commit d63adeda50d (2025-01-21 19:42 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin24.0.0)
  CPU: 10 × Apple M1 Max
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)

So they load eventually, but it takes over 4 minutes and it involves allocating an insane amount of memory.

Loading them separately is fine:

julia> @time using ITensors
  1.413191 seconds (2.45 M allocations: 193.174 MiB, 4.16% gc time, 14.81% compilation time: 97% of which was recompilation)

(jl_EKzBab) pkg> st
Status `/private/var/folders/qz/q22pzwm144z9fq57mpf1hfp40000gq/T/jl_EKzBab/Project.toml`
  [9136182c] ITensors v0.7.11

and:

julia> @time using LinearMaps
  0.009610 seconds (11.16 k allocations: 865.648 KiB)

(jl_7QvL25) pkg> st
Status `/private/var/folders/qz/q22pzwm144z9fq57mpf1hfp40000gq/T/jl_7QvL25/Project.toml`
  [7a12625a] LinearMaps v3.11.3

Definitely something very strange going on.

It looks like [WIP] [NDTensors] Excise libraries by mtfishman · Pull Request #1601 · ITensor/ITensors.jl · GitHub will fix this compilation issue. When I use the versions of NDTensors.jl and ITensors.jl on that branch I see:

julia> @time using ITensors, LinearMaps
Precompiling ITensors...
  3 dependencies successfully precompiled in 7 seconds. 117 already precompiled.
  8.408726 seconds (2.46 M allocations: 171.095 MiB, 0.40% gc time, 3.05% compilation time: 90% of which was recompilation)

We have to wait a few days to merge that since it relies on registering a new dependent package (New package: TypeParameterAccessors v0.2.2 by JuliaRegistrator · Pull Request #124121 · JuliaRegistries/General · GitHub), which has a mandatory 3 day waiting period.

@srwhite this issue should be fixed with the latest ITensors.jl v0.8 release:

julia> @time using LinearMaps, ITensors
  0.955740 seconds (1.36 M allocations: 80.760 MiB, 32.83% compilation time: 97% of which was recompilation)

(jl_SZhGpa) pkg> st
Status `/private/var/folders/qz/q22pzwm144z9fq57mpf1hfp40000gq/T/jl_SZhGpa/Project.toml`
  [9136182c] ITensors v0.8.0
  [7a12625a] LinearMaps v3.11.3

Fantastic! Thanks!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.