tensor4all / TensorCrossInterpolation.jl

https://tensor4all.github.io/TensorCrossInterpolation.jl/
MIT License
11 stars 0 forks source link

Improvements for `compress!` function using SVD #17

Open sakurairihito opened 2 weeks ago

sakurairihito commented 2 weeks ago

There are several potential improvements for the compress! function, especially using SVD.

  1. Normalize singular values in _factorize: We need to consider normalizing these values by the maximum singular value, as we discussed about this issue with one of the developers.

    Proposed change:

    trunci = min(
       replacenothing(findlast(>(tolerance), factorization.S/maximum(factorization.S)), 1),
       maxbonddim
    )

I am not sure what the maximum values are when using CI.

  1. Avoid recompression during left canonicalization: When making tensor trains left canonical by sweeping from left to right using SVD, we should avoid recompressing the tensor train. The current implementation sets the tolerance or maximum bond dimensions to finite values, so these must be fixed.

  2. Contract singular values with left unitary matrix: In the right-to-left sweep in _factorize, that is, we move the canonical center from left to the right, we need to contract the singular value matrix with the left unitary matrix of SVD. This could improve the accuracy of the recompression of TT. However, current implementation contracts the singular value matrix with the right unitary matrix of SVD.

Proposed change in _factorize:

   trunci = min(replacenothing(findlast(>(tolerance), factorization.S/maximum(factorization.S)), 1), maxbonddim)
   return (
       factorization.U[:, 1:trunci] * Diagonal(factorization.S[1:trunci]),
       factorization.Vt[1:trunci, :],
       trunci
   )
shinaoka commented 2 weeks ago

@sakurairihito

Thank you.

Point 1: We should provide an option to choose whether or not we normalize the error in SVD/QR and CI. Point 2: This may be a bug. Point 3: This may be a bug.

@rittermarc What do you think?

shinaoka commented 2 weeks ago

@rittermarc

I am implementing a fix.

rittermarc commented 2 weeks ago

I agree with all of your points. I would consider 2. and 3. bugs, and we should fix them; thank you for pointing it out!