Skip to content

Refactor TensorNetwork to class-based OOP organization #504

Refactor TensorNetwork to class-based OOP organization

Refactor TensorNetwork to class-based OOP organization #504

Triggered via pull request October 9, 2023 12:33
@mofeingmofeing
synchronize #103
refactor/oop
Status Failure
Total duration 16m 46s
Artifacts

CI.yml

on: pull_request
Matrix: Documentation
Matrix: test
Fit to window
Zoom out
Zoom in

Annotations

2 errors and 6 warnings
Julia 1.9 - ubuntu-latest - x64 - pull_request
Process completed with exit code 1.
Documentation (1.9, ubuntu-latest, x64)
Process completed with exit code 1.
Documentation (1.9, ubuntu-latest, x64): ../../../.julia/packages/Documenter/9kOxY/src/utilities/utilities.jl#L46
failed to run `@example` block in src/examples/ad-tn.md:10-25 ```@example autodiff using Tenet using Zygote using Random: seed! # hide rng = seed!(4) # hide ψ = rand(MPS{Open}, n = 4, p = 2, χ = 2) ϕ = rand(MPS{Open}, n = 4, p = 2, χ = 4) ψ = rand(rng, MPS{Open}, n = 4, p = 2, χ = 2) # hide ϕ = rand(rng, MPS{Open}, n = 4, p = 2, χ = 4) # hide tn = hcat(ψ, ϕ) plot(tn) # hide ``` exception = PlotMethodError: no plot method for arguments (::Matrix{MPS{Open}}). To support these arguments, define plot!(::Combined{Any, S} where S<:Tuple{Matrix{MPS{Open}}}) Available methods are: Stacktrace: [1] _plot!(p::Combined{Any, Tuple{Matrix{MPS{Open}}}}) @ Makie ~/.julia/packages/Makie/NrrbP/src/interfaces.jl:321 [2] plot!(p::Combined{Any, Tuple{Matrix{MPS{Open}}}}) @ Makie ~/.julia/packages/Makie/NrrbP/src/interfaces.jl:316 [3] plot!(scene::Scene, P::Type{Combined{Any, Tuple{Matrix{MPS{Open}}}}}, attributes::Attributes, input::Tuple{Observable{Matrix{MPS{Open}}}}, args::Observable{Tuple{Matrix{MPS{Open}}}}) @ Makie ~/.julia/packages/Makie/NrrbP/src/interfaces.jl:398 [4] plot!(scene::Scene, P::Type{Any}, attributes::Attributes, args::Matrix{MPS{Open}}; kw_attributes::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}) @ Makie ~/.julia/packages/Makie/NrrbP/src/interfaces.jl:310 [5] plot!(scene::Scene, P::Type{Any}, attributes::Attributes, args::Matrix{MPS{Open}}) @ Makie ~/.julia/packages/Makie/NrrbP/src/interfaces.jl:275 [6] get_axis(fig::Any, P::Any, axis_kw::Dict, plot_attr::Any, plot_args::Any) @ Makie ~/.julia/packages/Makie/NrrbP/src/figureplotting.jl:43 [7] plot(P::Type{Any}, args::Matrix{MPS{Open}}; axis::NamedTuple{(), Tuple{}}, figure::NamedTuple{(), Tuple{}}, kw_attributes::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}) @ Makie ~/.julia/packages/Makie/NrrbP/src/figureplotting.jl:62 [8] plot(P::Type{Any}, args::Matrix{MPS{Open}}) @ Makie ~/.julia/packages/Makie/NrrbP/src/figureplotting.jl:55 [9] plot(args::Matrix{MPS{Open}}; attributes::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}) @ MakieCore ~/.julia/packages/MakieCore/7iPhv/src/recipes.jl:35 [10] plot(args::Matrix{MPS{Open}}) @ MakieCore ~/.julia/packages/MakieCore/7iPhv/src/recipes.jl:34 [11] top-level scope @ ad-tn.md:24 [12] eval @ ./boot.jl:370 [inlined] [13] #54 @ ~/.julia/packages/Documenter/9kOxY/src/expander_pipeline.jl:738 [inlined] [14] cd(f::Documenter.var"#54#56"{Module, Expr}, dir::String) @ Base.Filesystem ./file.jl:112 [15] (::Documenter.var"#53#55"{Documenter.Page, Module, Expr})() @ Documenter ~/.julia/packages/Documenter/9kOxY/src/expander_pipeline.jl:737 [16] (::IOCapture.var"#3#5"{DataType, Documenter.var"#53#55"{Documenter.Page, Module, Expr}, Task, IOContext{Base.PipeEndpoint}, IOContext{Base.PipeEndpoint}, IOContext{Base.PipeEndpoint}, IOContext{Base.PipeEndpoint}})() @ IOCapture ~/.julia/packages/IOCapture/8Uj7o/src/IOCapture.jl:119 [17] with_logstate(f::Function, logstate::Any) @ Base.CoreLogging ./logging.jl:514 [18] with_logger @ ./logging.jl:626 [inlined] [19] capture(f::Documenter.var"#53#55"{Documenter.Page, Module, Expr}; rethrow::Type, color::Bool) @ IOCapture ~/.julia/packages/IOCapture/8Uj7o/src/IOCapture.jl:116 [20] runner(#unused#::Type{Documenter.Expanders.ExampleBlocks}, node::MarkdownAST.Node{Nothing}, page::Documenter.Page, doc::Documenter.Document) @ Documenter ~/.julia/packages/Documenter/9kOxY/src/expander_pipeline.jl:736
Documentation (1.9, ubuntu-latest, x64): ../../../.julia/packages/Documenter/9kOxY/src/utilities/utilities.jl#L46
failed to run `@example` block in src/examples/ad-tn.md:44-69 ```@example autodiff η = 0.01 @time losses = map(1:200) do it # compute gradient loss, ∇ = withgradient(Params(arrays(ψ))) do ((contract(tn) |> first) - 1)^2 end # direct gradient descent for array in arrays(ψ) array .-= η * ∇[array] end # normalize state normalize!(ψ) return loss end f = Figure() # hide ax = Axis(f[1, 1], yscale = log10, xscale = identity, xlabel="Iterations") # hide lines!(losses, label="Loss") # hide lines!(map(x -> 1 - sqrt(x), losses), label="Overlap") # hide f[1,2] = Legend(f, ax, framevisible=false) # hide f # hide ``` exception = MethodError: no method matching contract(::Matrix{MPS{Open}}) Closest candidates are: contract(::Union{AbstractArray{T, 0}, T}, !Matched::Tensor{T, N, A} where {N, A<:AbstractArray{T, N}}) where T @ Tenet ~/work/Tenet.jl/Tenet.jl/src/Numerics.jl:67 contract(!Matched::Tensor; dims) @ Tenet ~/work/Tenet.jl/Tenet.jl/src/Numerics.jl:56 contract(!Matched::Tensor, !Matched::Tensor; dims) @ Tenet ~/work/Tenet.jl/Tenet.jl/src/Numerics.jl:40 ... Stacktrace: [1] macro expansion @ ~/.julia/packages/Zygote/XJ8pP/src/compiler/interface2.jl:101 [inlined] [2] _pullback(ctx::Zygote.Context{true}, f::typeof(contract), args::Matrix{MPS{Open}}) @ Zygote ~/.julia/packages/Zygote/XJ8pP/src/compiler/interface2.jl:101 [3] _pullback @ ./ad-tn.md:49 [inlined] [4] _pullback(::Zygote.Context{true}, ::Main.__atexample__named__autodiff.var"#2#4") @ Zygote ~/.julia/packages/Zygote/XJ8pP/src/compiler/interface2.jl:0 [5] pullback(f::Function, ps::Zygote.Params{Zygote.Buffer{Array{Float64}, Vector{Array{Float64}}}}) @ Zygote ~/.julia/packages/Zygote/XJ8pP/src/compiler/interface.jl:414 [6] withgradient(f::Function, args::Zygote.Params{Zygote.Buffer{Array{Float64}, Vector{Array{Float64}}}}) @ Zygote ~/.julia/packages/Zygote/XJ8pP/src/compiler/interface.jl:154 [7] (::Main.__atexample__named__autodiff.var"#1#3")(it::Int64) @ Main.__atexample__named__autodiff ./ad-tn.md:48 [8] iterate @ ./generator.jl:47 [inlined] [9] _collect(c::UnitRange{Int64}, itr::Base.Generator{UnitRange{Int64}, Main.__atexample__named__autodiff.var"#1#3"}, #unused#::Base.EltypeUnknown, isz::Base.HasShape{1}) @ Base ./array.jl:802 [10] collect_similar(cont::UnitRange{Int64}, itr::Base.Generator{UnitRange{Int64}, Main.__atexample__named__autodiff.var"#1#3"}) @ Base ./array.jl:711 [11] map(f::Function, A::UnitRange{Int64}) @ Base ./abstractarray.jl:3263 [12] top-level scope @ ./timing.jl:273 [13] eval @ ./boot.jl:370 [inlined] [14] #54 @ ~/.julia/packages/Documenter/9kOxY/src/expander_pipeline.jl:738 [inlined] [15] cd(f::Documenter.var"#54#56"{Module, Expr}, dir::String) @ Base.Filesystem ./file.jl:112 [16] (::Documenter.var"#53#55"{Documenter.Page, Module, Expr})() @ Documenter ~/.julia/packages/Documenter/9kOxY/src/expander_pipeline.jl:737 [17] (::IOCapture.var"#3#5"{DataType, Documenter.var"#53#55"{Documenter.Page, Module, Expr}, Task, IOContext{Base.PipeEndpoint}, IOContext{Base.PipeEndpoint}, IOContext{Base.PipeEndpoint}, IOContext{Base.PipeEndpoint}})() @ IOCapture ~/.julia/packages/IOCapture/8Uj7o/src/IOCapture.jl:119 [18] with_logstate(f::Function, logstate::Any) @ Base.CoreLogging ./logging.jl:514 [19] with_logger @ ./logging.jl:626 [inlined] [20] capture(f::Documenter.var"#53#55"{Documenter.Page, Module, Expr}; rethrow::Type, color::Bool) @ IOCapture ~/.julia/packages/IOCapture/8Uj7o/src/IOCapture.jl:116 [21] runner(#unused#::Type{Documenter.Expanders.ExampleBlocks}, node::MarkdownAST.Node{Nothing}, page::Documenter.Page, doc::Documenter.Document) @ Documenter ~/.julia/packages/Documenter/9kOxY/src/expander_pipeline.jl:736
Documentation (1.9, ubuntu-latest, x64): ../../../.julia/packages/Documenter/9kOxY/src/utilities/utilities.jl#L46
failed to run `@example` block in src/examples/google-rqc.md:37-48 ```@example circuit using QuacIO using Tenet _sites = [5, 6, 14, 15, 16, 17, 24, 25, 26, 27, 28, 32, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 61, 62, 63, 64, 65, 66, 67, 72, 73, 74, 75, 76, 83, 84, 85, 94]; # load circuit and convert to `TensorNetwork` circuit = QuacIO.parse(joinpath(@__DIR__, "sycamore_53_10_0.qasm"), format = QuacIO.Qflex(), sites = _sites); tn = TensorNetwork(circuit) tn = view(tn, [i => 1 for i in inds(tn, set=:open)]...) plot(tn) # hide ``` exception = MethodError: no method matching inds(::Quac.Gate{Quac.Hz, 1, NamedTuple{(:θ, :ϕ), Tuple{Float64, Float64}}}) Closest candidates are: inds(!Matched::Tensor) @ Tenet ~/work/Tenet.jl/Tenet.jl/src/Tensor.jl:25 inds(!Matched::Tenet.AbstractQuantumTensorNetwork, !Matched::Val{:virtual}) @ Tenet ~/work/Tenet.jl/Tenet.jl/src/Quantum/Quantum.jl:21 inds(!Matched::Tenet.AbstractQuantumTensorNetwork, !Matched::Val{:physical}) @ Tenet ~/work/Tenet.jl/Tenet.jl/src/Quantum/Quantum.jl:20 ... Stacktrace: [1] (::Tenet.var"#65#68")(dict::Dict{Symbol, Vector{Int64}}, ::Tuple{Int64, Quac.Gate{Quac.Hz, 1, NamedTuple{(:θ, :ϕ), Tuple{Float64, Float64}}}}) @ Tenet ~/work/Tenet.jl/Tenet.jl/src/TensorNetwork.jl:22 [2] BottomRF @ ./reduce.jl:81 [inlined] [3] _foldl_impl @ ./reduce.jl:58 [inlined] [4] foldl_impl(op::Base.BottomRF{Tenet.var"#65#68"}, nt::Dict{Symbol, Vector{Int64}}, itr::Base.Iterators.Enumerate{Quac.Circuit}) @ Base ./reduce.jl:48 [5] mapfoldl_impl @ ./reduce.jl:44 [inlined] [6] #mapfoldl#288 @ ./reduce.jl:170 [inlined] [7] mapfoldl @ ./reduce.jl:170 [inlined] [8] #mapreduce#292 @ ./reduce.jl:302 [inlined] [9] mapreduce @ ./reduce.jl:302 [inlined] [10] #reduce#294 @ ./reduce.jl:485 [inlined] [11] reduce @ ./reduce.jl:485 [inlined] [12] TensorNetwork(tensors::Quac.Circuit) @ Tenet ~/work/Tenet.jl/Tenet.jl/src/TensorNetwork.jl:21 [13] top-level scope @ google-rqc.md:45 [14] eval @ ./boot.jl:370 [inlined] [15] #54 @ ~/.julia/packages/Documenter/9kOxY/src/expander_pipeline.jl:738 [inlined] [16] cd(f::Documenter.var"#54#56"{Module, Expr}, dir::String) @ Base.Filesystem ./file.jl:112 [17] (::Documenter.var"#53#55"{Documenter.Page, Module, Expr})() @ Documenter ~/.julia/packages/Documenter/9kOxY/src/expander_pipeline.jl:737 [18] (::IOCapture.var"#3#5"{DataType, Documenter.var"#53#55"{Documenter.Page, Module, Expr}, Task, IOContext{Base.PipeEndpoint}, IOContext{Base.PipeEndpoint}, IOContext{Base.PipeEndpoint}, IOContext{Base.PipeEndpoint}})() @ IOCapture ~/.julia/packages/IOCapture/8Uj7o/src/IOCapture.jl:119 [19] with_logstate(f::Function, logstate::Any) @ Base.CoreLogging ./logging.jl:514 [20] with_logger @ ./logging.jl:626 [inlined] [21] capture(f::Documenter.var"#53#55"{Documenter.Page, Module, Expr}; rethrow::Type, color::Bool) @ IOCapture ~/.julia/packages/IOCapture/8Uj7o/src/IOCapture.jl:116 [22] runner(#unused#::Type{Documenter.Expanders.ExampleBlocks}, node::MarkdownAST.Node{Nothing}, page::Documenter.Page, doc::Documenter.Document) @ Documenter ~/.julia/packages/Documenter/9kOxY/src/expander_pipeline.jl:736
Documentation (1.9, ubuntu-latest, x64): ../../../.julia/packages/Documenter/9kOxY/src/utilities/utilities.jl#L46
failed to run `@example` block in src/examples/google-rqc.md:52-56 ```@example circuit # simplify Tensor Network by preemptively contracting trivial cases tn = transform(tn, Tenet.RankSimplification) plot(tn, layout=Stress()) # hide ``` exception = UndefVarError: `tn` not defined Stacktrace: [1] top-level scope @ google-rqc.md:54 [2] eval @ ./boot.jl:370 [inlined] [3] #54 @ ~/.julia/packages/Documenter/9kOxY/src/expander_pipeline.jl:738 [inlined] [4] cd(f::Documenter.var"#54#56"{Module, Expr}, dir::String) @ Base.Filesystem ./file.jl:112 [5] (::Documenter.var"#53#55"{Documenter.Page, Module, Expr})() @ Documenter ~/.julia/packages/Documenter/9kOxY/src/expander_pipeline.jl:737 [6] (::IOCapture.var"#3#5"{DataType, Documenter.var"#53#55"{Documenter.Page, Module, Expr}, Task, IOContext{Base.PipeEndpoint}, IOContext{Base.PipeEndpoint}, IOContext{Base.PipeEndpoint}, IOContext{Base.PipeEndpoint}})() @ IOCapture ~/.julia/packages/IOCapture/8Uj7o/src/IOCapture.jl:119 [7] with_logstate(f::Function, logstate::Any) @ Base.CoreLogging ./logging.jl:514 [8] with_logger @ ./logging.jl:626 [inlined] [9] capture(f::Documenter.var"#53#55"{Documenter.Page, Module, Expr}; rethrow::Type, color::Bool) @ IOCapture ~/.julia/packages/IOCapture/8Uj7o/src/IOCapture.jl:116 [10] runner(#unused#::Type{Documenter.Expanders.ExampleBlocks}, node::MarkdownAST.Node{Nothing}, page::Documenter.Page, doc::Documenter.Document) @ Documenter ~/.julia/packages/Documenter/9kOxY/src/expander_pipeline.jl:736
Documentation (1.9, ubuntu-latest, x64): ../../../.julia/packages/Documenter/9kOxY/src/utilities/utilities.jl#L46
failed to run `@example` block in src/examples/google-rqc.md:60-64 ```@example circuit using EinExprs path = einexpr(tn, optimizer = Greedy) plot(path, layout=Stress()) # hide ``` exception = UndefVarError: `tn` not defined Stacktrace: [1] top-level scope @ google-rqc.md:62 [2] eval @ ./boot.jl:370 [inlined] [3] #54 @ ~/.julia/packages/Documenter/9kOxY/src/expander_pipeline.jl:738 [inlined] [4] cd(f::Documenter.var"#54#56"{Module, Expr}, dir::String) @ Base.Filesystem ./file.jl:112 [5] (::Documenter.var"#53#55"{Documenter.Page, Module, Expr})() @ Documenter ~/.julia/packages/Documenter/9kOxY/src/expander_pipeline.jl:737 [6] (::IOCapture.var"#3#5"{DataType, Documenter.var"#53#55"{Documenter.Page, Module, Expr}, Task, IOContext{Base.PipeEndpoint}, IOContext{Base.PipeEndpoint}, IOContext{Base.PipeEndpoint}, IOContext{Base.PipeEndpoint}})() @ IOCapture ~/.julia/packages/IOCapture/8Uj7o/src/IOCapture.jl:119 [7] with_logstate(f::Function, logstate::Any) @ Base.CoreLogging ./logging.jl:514 [8] with_logger @ ./logging.jl:626 [inlined] [9] capture(f::Documenter.var"#53#55"{Documenter.Page, Module, Expr}; rethrow::Type, color::Bool) @ IOCapture ~/.julia/packages/IOCapture/8Uj7o/src/IOCapture.jl:116 [10] runner(#unused#::Type{Documenter.Expanders.ExampleBlocks}, node::MarkdownAST.Node{Nothing}, page::Documenter.Page, doc::Documenter.Document) @ Documenter ~/.julia/packages/Documenter/9kOxY/src/expander_pipeline.jl:736
Documentation (1.9, ubuntu-latest, x64): ../../../.julia/packages/Documenter/9kOxY/src/utilities/utilities.jl#L46
undefined binding 'Quantum' in `@docs` block in src/quantum/index.md:3-5 ```@docs Quantum ```