# LinearMaps and ITensors incompatibility?

**URL:** <https://itensor.discourse.group/t/linearmaps-and-itensors-incompatibility/2216>\
**Category:** ITensor Development\
**Created:** [January 28, 2025, 1:24am UTC](https://itensor.discourse.group/t/linearmaps-and-itensors-incompatibility/2216 "2025-01-28T01:24:37Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![srwhite](https://avatars.discourse-cdn.com/v4/letter/s/d9b06d/32.png) [@srwhite](https://itensor.discourse.group/u/srwhite)\
**Post date:** [January 28, 2025, 1:24am UTC](https://itensor.discourse.group/t/linearmaps-and-itensors-incompatibility/2216/1 "2025-01-28T01:24:37Z")

</div>

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](https://docs.julialang.org)  
(_) | (_) (_) |  
\_ \_ | | \_\_ \_ | Type “?” for help, “]?” for Pkg help.  
| | | | | | |/ ` | |  
| | || | | | (_| | | Version 1.11.3 (2025-01-21)  
_/ |\ __‘_|_|_|\__ ’\_| | Official [https://julialang.org/](https://julialang.org/) release  
|\_\_/ |

julia\> using LinearMaps

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

julia\> using ITensors

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

julia\> using LinearMaps, ITensors

---

<div class="post-metadata">

**Author:** ![mtfishman](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/mtfishman/32/11_2.png) [@mtfishman](https://itensor.discourse.group/u/mtfishman)\
**Post date:** [January 28, 2025, 2:57pm UTC](https://itensor.discourse.group/t/linearmaps-and-itensors-incompatibility/2216/2 "2025-01-28T14:57:44Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![srwhite](https://avatars.discourse-cdn.com/v4/letter/s/d9b06d/32.png) [@srwhite](https://itensor.discourse.group/u/srwhite)\
**Post date:** [January 28, 2025, 5:41pm UTC](https://itensor.discourse.group/t/linearmaps-and-itensors-incompatibility/2216/3 "2025-01-28T17:41:53Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![mtfishman](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/mtfishman/32/11_2.png) [@mtfishman](https://itensor.discourse.group/u/mtfishman)\
**Post date:** [January 28, 2025, 5:55pm UTC](https://itensor.discourse.group/t/linearmaps-and-itensors-incompatibility/2216/4 "2025-01-28T17:55:57Z")

</div>

> [@srwhite](#):
>
> Does ITensors itself use LinearMaps?

It used to at some point, but [not anymore](https://github.com/search?q=repo%3AITensor%2FITensors.jl+LinearMaps&type=code).

---

<div class="post-metadata">

**Author:** ![mtfishman](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/mtfishman/32/11_2.png) [@mtfishman](https://itensor.discourse.group/u/mtfishman)\
**Post date:** [January 28, 2025, 6:54pm UTC](https://itensor.discourse.group/t/linearmaps-and-itensors-incompatibility/2216/5 "2025-01-28T18:54:44Z")

</div>

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

```julia
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
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
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.

---

<div class="post-metadata">

**Author:** ![mtfishman](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/mtfishman/32/11_2.png) [@mtfishman](https://itensor.discourse.group/u/mtfishman)\
**Post date:** [January 31, 2025, 7:21pm UTC](https://itensor.discourse.group/t/linearmaps-and-itensors-incompatibility/2216/6 "2025-01-31T19:21:15Z")

</div>

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

```julia
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](https://github.com/JuliaRegistries/General/pull/124121)), which has a mandatory 3 day waiting period.

---

<div class="post-metadata">

**Author:** ![mtfishman](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/mtfishman/32/11_2.png) [@mtfishman](https://itensor.discourse.group/u/mtfishman)\
**Post date:** [February 4, 2025, 4:18am UTC](https://itensor.discourse.group/t/linearmaps-and-itensors-incompatibility/2216/7 "2025-02-04T04:18:47Z")

</div>

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

```julia
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

```

---

<div class="post-metadata">

**Author:** ![srwhite](https://avatars.discourse-cdn.com/v4/letter/s/d9b06d/32.png) [@srwhite](https://itensor.discourse.group/u/srwhite)\
**Post date:** [February 7, 2025, 4:05pm UTC](https://itensor.discourse.group/t/linearmaps-and-itensors-incompatibility/2216/8 "2025-02-07T16:05:41Z")

</div>

Fantastic! Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/itensor/original/1X/d3072b13e047cd06df7f3981547c0917d940dfa4.png) [@system](https://itensor.discourse.group/u/system)\
**Post date:** [February 17, 2025, 4:06pm UTC](https://itensor.discourse.group/t/linearmaps-and-itensors-incompatibility/2216/9 "2025-02-17T16:06:43Z")

</div>

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