# ITensor Julia Questions

**URL:** https://itensor.discourse.group/c/itensor-julia-questions/5.md?page=1

[Latest](https://itensor.discourse.group/latest.md) · [Categories](https://itensor.discourse.group/categories.md) · [Tags](https://itensor.discourse.group/tags.md)

**Page:** 2

---

## [Error when using tdvp](https://itensor.discourse.group/t/error-when-using-tdvp/2549)

<div class="topic-metadata">

**Author:** [@oskar-novak](https://itensor.discourse.group/u/oskar-novak)\
**Replies:** 1\
**Last updated:** [December 5, 2025, 5:36am UTC](https://itensor.discourse.group/t/error-when-using-tdvp/2549 "2025-12-05T05:36:23Z")

</div>

I’m getting the following error when using this function: function linevolve(theta,p) # 1. Define L and capture the exact indices L operates on os,sites=build\_discrete\_dephasing\_channel\_opsum(6,p\*theta,theta) L\_mp…

---

## [Taking Itensor Gradients](https://itensor.discourse.group/t/taking-itensor-gradients/2507)

<div class="topic-metadata">

**Author:** [@oskar-novak](https://itensor.discourse.group/u/oskar-novak)\
**Replies:** 5\
**Last updated:** [December 5, 2025, 5:31am UTC](https://itensor.discourse.group/t/taking-itensor-gradients/2507 "2025-12-05T05:31:01Z")

</div>

As someone relatively new to using ITensor, is there a straightforward way to integrate ITensor with an auto-differentiation library, such as Zygote.jl?

---

## [Free Fermion Rotations on QN conserved state](https://itensor.discourse.group/t/free-fermion-rotations-on-qn-conserved-state/2545)

<div class="topic-metadata">

**Author:** [@andrewprojansky](https://itensor.discourse.group/u/andrewprojansky)\
**Replies:** 5\
**Last updated:** [December 1, 2025, 6:31pm UTC](https://itensor.discourse.group/t/free-fermion-rotations-on-qn-conserved-state/2545 "2025-12-01T18:31:06Z")

</div>

Hi all, I’m trying to understand how best to apply a Free Fermion rotation on a QN conserved state. For an example, assume I have previously defined an electronic Hamiltonian I would like to perform DMRG on, and that Ha…

---

## [Does ITensor support SU(3) fermion systems?](https://itensor.discourse.group/t/does-itensor-support-su-3-fermion-systems/2543)

<div class="topic-metadata">

**Author:** [@Sheng9807](https://itensor.discourse.group/u/Sheng9807)\
**Replies:** 2\
**Last updated:** [November 30, 2025, 3:11am UTC](https://itensor.discourse.group/t/does-itensor-support-su-3-fermion-systems/2543 "2025-11-30T03:11:25Z")

</div>

Hi everyone, I’m a beginner with ITensor and I’m trying to simulate an SU(3) fermionic Hubbard model. I wrote my own custom operators, but the results are clearly wrong and I don’t know where the problem is. I’ve attach…

---

## [Purifying MPO into MPS](https://itensor.discourse.group/t/purifying-mpo-into-mps/2534)

<div class="topic-metadata">

**Author:** [@oskar-novak](https://itensor.discourse.group/u/oskar-novak)\
**Replies:** 3\
**Last updated:** [November 26, 2025, 4:14am UTC](https://itensor.discourse.group/t/purifying-mpo-into-mps/2534 "2025-11-26T04:14:39Z")

</div>

I’m trying to take an MPO representing a density operator and turn it into a doubled MPS via contracting Bell states to the unprimed indexes. However, when I try to split the newly contracted tensors into two using SVD …

---

## [calculation time in using GPU tensor vs CPU tensor](https://itensor.discourse.group/t/calculation-time-in-using-gpu-tensor-vs-cpu-tensor/2535)

<div class="topic-metadata">

**Author:** [@vrushali.k](https://itensor.discourse.group/u/vrushali.k)\
**Replies:** 5\
**Last updated:** [November 22, 2025, 7:22pm UTC](https://itensor.discourse.group/t/calculation-time-in-using-gpu-tensor-vs-cpu-tensor/2535 "2025-11-22T19:22:48Z")

</div>

Hello, I am trying to use GPU for faster performance, but the GPU is currently slower than the CPU. Below is the relevant part of my code. t\_cTEBD=@elapsed begin for t in tau:tau:ttotal psi\_t\_cpu = apply(gate…

---

## [Custom OpName with int converted to string](https://itensor.discourse.group/t/custom-opname-with-int-converted-to-string/2533)

<div class="topic-metadata">

**Author:** [@colo4k](https://itensor.discourse.group/u/colo4k)\
**Replies:** 2\
**Last updated:** [November 20, 2025, 10:58pm UTC](https://itensor.discourse.group/t/custom-opname-with-int-converted-to-string/2533 "2025-11-20T22:58:28Z")

</div>

Hi, I am new to julia and itensor and got a problem in defining custom operators. I want to define a sequence of custom ITensors.op like function ITensors.op(::OpName"M1", ::SiteType"Boson", d::Int) function ITensors.o…

---

## [Multi threading in ITensor](https://itensor.discourse.group/t/multi-threading-in-itensor/2531)

<div class="topic-metadata">

**Author:** [@tamoghnaRay](https://itensor.discourse.group/u/tamoghnaRay)\
**Replies:** 10\
**Last updated:** [November 20, 2025, 3:41pm UTC](https://itensor.discourse.group/t/multi-threading-in-itensor/2531 "2025-11-20T15:41:53Z")

</div>

Hi, I am doing a TEBD computation on an HPC, and I want to understand how to use multithreading effectively. I am using QN conserving systems. Following the instructions in the multithreading page of the documentation, …

---

## [Large tensor network with extremely sparse tensors](https://itensor.discourse.group/t/large-tensor-network-with-extremely-sparse-tensors/2528)

<div class="topic-metadata">

**Author:** [@nimaser](https://itensor.discourse.group/u/nimaser)\
**Replies:** 4\
**Last updated:** [November 14, 2025, 3:42pm UTC](https://itensor.discourse.group/t/large-tensor-network-with-extremely-sparse-tensors/2528 "2025-11-14T15:42:48Z")

</div>

I have a PEPS tensor network where each tensor has 5^4 =625 entries, of which only 15 are nonzero. With 100 tensors in the network, there’d be 5^{100} entries in the contracted network, which is much more memory than I h…

---

## [Operator entanglement of an MPO](https://itensor.discourse.group/t/operator-entanglement-of-an-mpo/2117)

<div class="topic-metadata">

**Author:** [@benny19](https://itensor.discourse.group/u/benny19)\
**Replies:** 3\
**Last updated:** [November 12, 2025, 8:21pm UTC](https://itensor.discourse.group/t/operator-entanglement-of-an-mpo/2117 "2025-11-12T20:21:40Z")

</div>

Hi, I would like to compute the operator entanglement of an MPO, defined as S\_{op} = - \\sum\_{\\alpha} \\lambda\_\\alpha^2 \\log\_2{\\lambda\_\\alpha^2} where \\lambda\_\\alpha are the Schmidt values across a cut of the system (see t…

---

## [Finite Temperature for canonical ensembles](https://itensor.discourse.group/t/finite-temperature-for-canonical-ensembles/2491)

<div class="topic-metadata">

**Author:** [@lorenzocarfora2000](https://itensor.discourse.group/u/lorenzocarfora2000)\
**Replies:** 3\
**Last updated:** [November 12, 2025, 3:29am UTC](https://itensor.discourse.group/t/finite-temperature-for-canonical-ensembles/2491 "2025-11-12T03:29:47Z")

</div>

I am currently working on numerically calculating the effects of temperature in my system. I am currently testing my routine on a Bose-Hubbard chain. I am starting by encoding a purified maximally entangle state and runn…

---

## [Manually set MPS tensors with QN conservation features enabled](https://itensor.discourse.group/t/manually-set-mps-tensors-with-qn-conservation-features-enabled/2504)

<div class="topic-metadata">

**Author:** [@phx](https://itensor.discourse.group/u/phx)\
**Replies:** 1\
**Last updated:** [November 10, 2025, 3:51pm UTC](https://itensor.discourse.group/t/manually-set-mps-tensors-with-qn-conservation-features-enabled/2504 "2025-11-10T15:51:31Z")

</div>

Hi all, I need some help on the following problem. I have an MPS with the Fermion site type, representing the state \\psi of a many-body fermionic system, and I’d like to use it to create an Electron-type MPS where both …

---

## [MPS more than 1000 sites](https://itensor.discourse.group/t/mps-more-than-1000-sites/2525)

<div class="topic-metadata">

**Author:** [@cgh](https://itensor.discourse.group/u/cgh)\
**Replies:** 1\
**Last updated:** [November 10, 2025, 1:23pm UTC](https://itensor.discourse.group/t/mps-more-than-1000-sites/2525 "2025-11-10T13:23:36Z")

</div>

Hi everyone, I am trying to construct a 2D square system with function lattice = square\_lattice(Nx, Ny; yperiodic = false) and Nx\* Ny\>1000 like Nx=35;Ny=35. Although the program can run, the calculation resultes (like…

---

## [Hardcore two-species bosonic system implementable within tJ sitetype?](https://itensor.discourse.group/t/hardcore-two-species-bosonic-system-implementable-within-tj-sitetype/2479)

<div class="topic-metadata">

**Author:** [@kristianknakkergaard](https://itensor.discourse.group/u/kristianknakkergaard)\
**Replies:** 2\
**Last updated:** [November 9, 2025, 2:57am UTC](https://itensor.discourse.group/t/hardcore-two-species-bosonic-system-implementable-within-tj-sitetype/2479 "2025-11-09T02:57:21Z")

</div>

I wish to implement a hardcore boson model with two species. In particular, I am interested in dynamics of the Bose-Hubbard Hamiltonian in the large U/t limit with additional nearest neighbour Ising terms: \\hat{H} = -…

---

## [Computing Renyi entropy of a sub-system in the middle of a 1D chain](https://itensor.discourse.group/t/computing-renyi-entropy-of-a-sub-system-in-the-middle-of-a-1d-chain/2523)

<div class="topic-metadata">

**Author:** [@tamoghnaRay](https://itensor.discourse.group/u/tamoghnaRay)\
**Replies:** 3\
**Last updated:** [November 7, 2025, 2:57pm UTC](https://itensor.discourse.group/t/computing-renyi-entropy-of-a-sub-system-in-the-middle-of-a-1d-chain/2523 "2025-11-07T14:57:27Z")

</div>

Hi, I have a spin- 1/2 XXZ chain of length L. I have a sub-system of length L\_S, in the middle of the chain. Say L = 10 and the system goes from site 4 to 7 (L\_S = 4). I want to compute S\_n = \\frac{1}{1-n}\\log\[\\text{Tr} …

---

## [Large spin DMRG](https://itensor.discourse.group/t/large-spin-dmrg/2522)

<div class="topic-metadata">

**Author:** [@Lee](https://itensor.discourse.group/u/Lee)\
**Replies:** 6\
**Last updated:** [November 5, 2025, 1:24am UTC](https://itensor.discourse.group/t/large-spin-dmrg/2522 "2025-11-05T01:24:38Z")

</div>

Hi everyone! I’d like to ask a question about Julia 1.11. This version only supports spin-1 and spin-1/2 calculations and doesn’t work for antiferromagnetic one-dimensional chains with large spins. I’ve tried the custo…

---

## [Unexpected error with number-conserving MPO when result is zero](https://itensor.discourse.group/t/unexpected-error-with-number-conserving-mpo-when-result-is-zero/2521)

<div class="topic-metadata">

**Author:** [@phx](https://itensor.discourse.group/u/phx)\
**Replies:** 2\
**Last updated:** [November 1, 2025, 7:02pm UTC](https://itensor.discourse.group/t/unexpected-error-with-number-conserving-mpo-when-result-is-zero/2521 "2025-11-01T19:02:55Z")

</div>

The following code gives an error which I don’t understand. I set up two different states with number conservation active: using ITensors, ITensorMPS N = 3 s = siteinds("Electron", N; conserve\_nf=true) x = MPS(s, \["Emp…

---

## [“Eigen currently only supports block diagonal matrices.” when applying an MPO to a MPS with QNs](https://itensor.discourse.group/t/eigen-currently-only-supports-block-diagonal-matrices-when-applying-an-mpo-to-a-mps-with-qns/2520)

<div class="topic-metadata">

**Author:** [@phx](https://itensor.discourse.group/u/phx)\
**Replies:** 3\
**Last updated:** [November 1, 2025, 7:39am UTC](https://itensor.discourse.group/t/eigen-currently-only-supports-block-diagonal-matrices-when-applying-an-mpo-to-a-mps-with-qns/2520 "2025-11-01T07:39:27Z")

</div>

I’m trying to find a way to write the mixed state of a many-body system of spinless fermions as an MPS of the Electron site type. The idea is essentially to map the primed site index of each MPS tensor to the ↑ degree of…

---

## [Making ITensor merge arbitary tensors with named index values](https://itensor.discourse.group/t/making-itensor-merge-arbitary-tensors-with-named-index-values/2519)

<div class="topic-metadata">

**Author:** [@Ritvik1sharma](https://itensor.discourse.group/u/Ritvik1sharma)\
**Replies:** 1\
**Last updated:** [October 31, 2025, 2:08pm UTC](https://itensor.discourse.group/t/making-itensor-merge-arbitary-tensors-with-named-index-values/2519 "2025-10-31T14:08:39Z")

</div>

Hey I have two MPO objects that i created manually. The issue is I cant seem to merge these MPOs together properly whenever I call contract() In particular say I have: # Tensor for R\_0\_0\_ function build\_R\_0\_0\_(index\_m…

---

## [Implementing block Sparse MPOs and relation with Quantum Numbers](https://itensor.discourse.group/t/implementing-block-sparse-mpos-and-relation-with-quantum-numbers/2517)

<div class="topic-metadata">

**Author:** [@Ritvik1sharma](https://itensor.discourse.group/u/Ritvik1sharma)\
**Replies:** 1\
**Last updated:** [October 26, 2025, 12:39am UTC](https://itensor.discourse.group/t/implementing-block-sparse-mpos-and-relation-with-quantum-numbers/2517 "2025-10-26T00:39:07Z")

</div>

Hi I am trying to work with iTensor to support different types of block sparse MPOs. If I understand correctly, the only form of block sparse MPOs one can construct right now with iTensor is using Quantum Numbers. Howev…

---

## [Bose Hubbard model with cavity interaction](https://itensor.discourse.group/t/bose-hubbard-model-with-cavity-interaction/2494)

<div class="topic-metadata">

**Author:** [@SOURITRA](https://itensor.discourse.group/u/SOURITRA)\
**Replies:** 7\
**Last updated:** [October 20, 2025, 9:53am UTC](https://itensor.discourse.group/t/bose-hubbard-model-with-cavity-interaction/2494 "2025-10-20T09:53:10Z")

</div>

Hello everyone I trying to simulate bose hubbard model with cavity interaction for 2 label atom. I want to see the phase diagram using DMRG, for that my Hamiltonian is, where, using ITensors, ITensorMPS, LinearA…

---

## [Unexpected error in 2D quantum number conserving DMRG (with unusual "fractal" path)](https://itensor.discourse.group/t/unexpected-error-in-2d-quantum-number-conserving-dmrg-with-unusual-fractal-path/2511)

<div class="topic-metadata">

**Author:** [@amoghanakru](https://itensor.discourse.group/u/amoghanakru)\
**Replies:** 7\
**Last updated:** [October 18, 2025, 10:17pm UTC](https://itensor.discourse.group/t/unexpected-error-in-2d-quantum-number-conserving-dmrg-with-unusual-fractal-path/2511 "2025-10-18T22:17:04Z")

</div>

Hi All, I am trying to perform 2-D DMRG on a simple model (spinful free fermions) using a fractal “Hilbert curve” path as opposed to the more conventional “snake”. This strategy is proposed in \[2507.11820v1\] Fractal Pat…

---

## [denseblocks on dense tensor fails](https://itensor.discourse.group/t/denseblocks-on-dense-tensor-fails/2508)

<div class="topic-metadata">

**Author:** [@matanlotem](https://itensor.discourse.group/u/matanlotem)\
**Replies:** 2\
**Last updated:** [October 8, 2025, 12:46am UTC](https://itensor.discourse.group/t/denseblocks-on-dense-tensor-fails/2508 "2025-10-08T00:46:44Z")

</div>

denseblocks(A) where A is a dense tensor crashes. This is a funny end case, but I would simply expect it to return A. using ITensors, ITensorMPS for conserve\_qns in \[true, false\] i = siteind("S=1"; conserve\_qns) …

---

## [Hard Core Bose Hubbard model](https://itensor.discourse.group/t/hard-core-bose-hubbard-model/2477)

<div class="topic-metadata">

**Author:** [@SOURITRA](https://itensor.discourse.group/u/SOURITRA)\
**Replies:** 1\
**Last updated:** [September 30, 2025, 6:00pm UTC](https://itensor.discourse.group/t/hard-core-bose-hubbard-model/2477 "2025-09-30T18:00:33Z")

</div>

Hi everyone, I want to simulate the Hard-Core Bose-Hubbard model using an initial Mott-like state of alternating filled and unfilled sites, and study its evolution toward a superfluid state. As I am new here, I would app…

---

## [Converting Finite MPS to Infinite MPS](https://itensor.discourse.group/t/converting-finite-mps-to-infinite-mps/2503)

<div class="topic-metadata">

**Author:** [@amoghanakru](https://itensor.discourse.group/u/amoghanakru)\
**Replies:** 0\
**Last updated:** [September 29, 2025, 8:50pm UTC](https://itensor.discourse.group/t/converting-finite-mps-to-infinite-mps/2503 "2025-09-29T20:50:02Z")

</div>

Hi, I am trying to convert a finite qn-conserving MPS (whose natural unit cell is, say, 5 sites long) to an infinite MPS through the following procedure. I would like to select out the middle 5 tensors from the finite M…

---

## [How to set customed eltype for op() methods?](https://itensor.discourse.group/t/how-to-set-customed-eltype-for-op-methods/2502)

<div class="topic-metadata">

**Author:** [@Zephyr](https://itensor.discourse.group/u/Zephyr)\
**Replies:** 3\
**Last updated:** [September 29, 2025, 4:52pm UTC](https://itensor.discourse.group/t/how-to-set-customed-eltype-for-op-methods/2502 "2025-09-29T16:52:22Z")

</div>

Hello! I’m trying to reduce the memory cost of my program and want to use Float32 rather than Float64 as the major number type throughout my code. How can I assign the ITensor object generated by methods like ITensors.o…

---

## [Unit Cell Choice and interaction terms in VUMPS](https://itensor.discourse.group/t/unit-cell-choice-and-interaction-terms-in-vumps/2500)

<div class="topic-metadata">

**Author:** [@4nubh4v](https://itensor.discourse.group/u/4nubh4v)\
**Replies:** 0\
**Last updated:** [September 23, 2025, 11:09pm UTC](https://itensor.discourse.group/t/unit-cell-choice-and-interaction-terms-in-vumps/2500 "2025-09-23T23:09:30Z")

</div>

Hello there! I was playing around with the iTensorInfiniteMPS package and I am encountering an issue while trying to perform VUMPS with subspace expansion. Here is a code block with a very slight modification of the exa…

---

## [How to use Float64 with GPU backend](https://itensor.discourse.group/t/how-to-use-float64-with-gpu-backend/2490)

<div class="topic-metadata">

**Author:** [@Ang](https://itensor.discourse.group/u/Ang)\
**Replies:** 2\
**Last updated:** [September 11, 2025, 3:56am UTC](https://itensor.discourse.group/t/how-to-use-float64-with-gpu-backend/2490 "2025-09-11T03:56:54Z")

</div>

I need Float64 precision for high-accuracy computations on GPU, but I haven’t been able to find relevant documentation or discussions on how to switch from Float32 to Float64 in ITensor. For reference, here’s a minimal e…

---

## [Low GPU utilization (\<25%) when accelerating DMRG with GPU](https://itensor.discourse.group/t/low-gpu-utilization-25-when-accelerating-dmrg-with-gpu/2487)

<div class="topic-metadata">

**Author:** [@Ang](https://itensor.discourse.group/u/Ang)\
**Replies:** 4\
**Last updated:** [September 10, 2025, 2:14pm UTC](https://itensor.discourse.group/t/low-gpu-utilization-25-when-accelerating-dmrg-with-gpu/2487 "2025-09-10T14:14:50Z")

</div>

I’m currently using a GPU to accelerate DMRG computations. My MPS is not large, so the computational scale and memory usage are also small (less than 3GB), which are all within my expectations. However, the GPU utilizati…

---

## [Explicitly construct the reduced density matrix](https://itensor.discourse.group/t/explicitly-construct-the-reduced-density-matrix/2478)

<div class="topic-metadata">

**Author:** [@zhouzsh](https://itensor.discourse.group/u/zhouzsh)\
**Replies:** 2\
**Last updated:** [August 26, 2025, 7:28am UTC](https://itensor.discourse.group/t/explicitly-construct-the-reduced-density-matrix/2478 "2025-08-26T07:28:54Z")

</div>

Dear ITensor team, For my specific requirements, I need to explicitly construct the reduced density matrix. The basic procedure I have followed is to first shift the canonical center of the MPS to a particular site, and…

[Previous page](https://itensor.discourse.group/c/itensor-julia-questions/5.md)

[Next page](https://itensor.discourse.group/c/itensor-julia-questions/5.md?page=2)
