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

Fix index dimension mismatch in TensorNetwork construction #219

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

Conversation

Todorbsc
Copy link
Contributor

Closes #155

@Todorbsc Todorbsc added the bug Something isn't working label Oct 11, 2024
@Todorbsc Todorbsc self-assigned this Oct 11, 2024
@Todorbsc
Copy link
Contributor Author

@jofrevalles @mofeing the dimension mismatch seems to be fixed with the verification I implemented in TensorNetwork construction. I "uncommented" the TN dimension mismatch construction test and now it raises the proper exception as well as I tested the Chain example that Jofre commented in the issue, what raises an error now:

julia> mps = Chain(State(), Open(), [rand(2, 3), rand(2, 6, 4), rand(2, 5)])
ERROR: DimensionMismatch: Index D has inconsistent dimension: [3, 6]
Stacktrace:
 [1] TensorNetwork(tensors::Vector{Tensor{Float64, N, A} where {N, A<:AbstractArray{Float64, N}}})
   @ Tenet ~/QuanticGit/Tenet.jl/src/TensorNetwork.jl:58
 [2] Chain(::State, boundary::Open, arrays::Vector{Array{Float64}}; order::Tuple{Symbol, Symbol, Symbol})
   @ Tenet ~/QuanticGit/Tenet.jl/src/Ansatz/Chain.jl:99
 [3] Chain(::State, boundary::Open, arrays::Vector{Array{Float64}})
   @ Tenet ~/QuanticGit/Tenet.jl/src/Ansatz/Chain.jl:63
 [4] top-level scope
   @ REPL[3]:1

Also, let me know if there's something else needed, specially with what you commented in the issue about the unsafe_region.

Copy link
Member

@jofrevalles jofrevalles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, nice! Since we already have tests for @unsafe_region, and these are passing, we can merge this!

@mofeing
Copy link
Member

mofeing commented Oct 11, 2024

Do you mind benchmarking with and without the safe guards / checks for some large TNs? Like 100-1000 tensors

src/TensorNetwork.jl Outdated Show resolved Hide resolved
Co-authored-by: Sergio Sánchez Ramírez <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Quantum constructor does not error for inconsistent dimensions in tensor networks
3 participants