-
Notifications
You must be signed in to change notification settings - Fork 1
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
Refactor TensorNetwork
to new definition
#55
Conversation
Codecov Report
@@ Coverage Diff @@
## master #55 +/- ##
==========================================
- Coverage 84.89% 84.30% -0.59%
==========================================
Files 12 9 -3
Lines 748 599 -149
==========================================
- Hits 635 505 -130
+ Misses 113 94 -19
|
Co-authored-by: Jofre Vallès Muns <61060572+jofrevalles@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With these two changes we don't get errors with norm
and, in general, the contraction seems ok.
julia> ψ = rand(MatrixProduct{State,Open}, n = 4, p = 2, χ = 32)
TensorNetwork{MatrixProduct{State, Open}}(#tensors=4, #labels=7)
julia> norm(ψ)
0.9999999999999939
julia> A = Tensor(rand(2, 2, 2), (:i, :j, :k)); B = Tensor(rand(2, 2), (:j, :l))
2×2 Tensor{Float64, 2, Matrix{Float64}}:
0.433555 0.834031
0.459739 0.646734
julia> C = contract(A, B)
2×2×2 Tensor{Float64, 3, Array{Float64, 3}}:
[:, :, 1] =
0.559003 0.0637526
0.198716 0.576309
[:, :, 2] =
1.00909 0.107564
0.354096 1.01502
julia> labels(C)
(:i, :k, :l)
@jofrevalles would you mind writing a couple of tests of the errors you are finding? I'm unable to see where the problems are without code examples. |
…e` type (#57) * Refactor `TensorNetwork` metadata to new parametric definition * Test `merge`, `superansatzes` * Fix `TensorNetwork` tests * Replace `metadata` access with implicit `getproperty` calls * Fix `NamedTuple`'s field access on `getproperty(::TensorNetwork)` * Fix typos * Fix `NamedTuple` initialization with `Pairs` * Refactor `checkmeta(Quantum)` * Refactor `TensorNetwork` args and checks in constructors * Implement `fieldnames` for `TensorNetwork` object * Fix `plug` mutation * Move `hcat` test to `Quac` integration tests * Test `metadata`,`sites`,`labels`,`adjoint` on `Quantum` ansatz * Init `Composite` ansatz * Precompute `indices` mapping on `TensorNetwork`'s inner constructor * Refactor `Quantum` metadata to interlayers alas multi-layer graphs * Format code * Fix `hcat` method between `Quantum` TNs * Apply @mofeing suggestions from code review Co-authored-by: Sergio Sánchez Ramírez <15837247+mofeing@users.noreply.github.com> * Store `Plug` info in metadata * Update `Quac` extension to new `TensorNetwork` definition * Set `Bijections` compat constraint to v0.1 * Add `MPO` tests * Add `MPS` tests * Test `Quantum` code on `Operator` plug * Specialize `replace!` on Quantum TN * Fix `layers`, `hcat` * Fix `@invoke` call in Julia 1.8 * Fix `@invoke` call on ambiguous method --------- Co-authored-by: Sergio Sánchez Ramírez <sergio.sanchez.ramirez+github@bsc.es> Co-authored-by: Sergio Sánchez Ramírez <sergio.sanchez.ramirez+git@bsc.es> Co-authored-by: Jofre Vallès Muns <61060572+jofrevalles@users.noreply.github.com> Co-authored-by: Ema Puljak <ema.puljak@cern.ch>
This PR redefines the internals of the
TensorNetwork
type, removing the problematicIndex
type andlink
methods.The
TensorNetwork
fields now contain:Tensor
sTensor
sSince
Tensor
s contain the list of indices they are connected to, and so does the indices mapping, it is equally efficient to access aTensorNetwork
graph and its dual1 graph.This improves code complexity, composability, ...
Footnotes
Indices as nodes and tensors as (hyper)edges. ↩