bsc-quantic / optimizedeinsum.jl Goto Github PK
View Code? Open in Web Editor NEWJulia rewrite of opt_einsum Python package
License: Apache License 2.0
Julia rewrite of opt_einsum Python package
License: Apache License 2.0
When !isempty(output)
, target_inds_histogram
dictionary does not contain keys from output
indices due to line
OptimizedEinsum.jl/src/Solvers/Greedy.jl
Lines 75 to 79 in 9d52b4a
This makes the following code to crash.
OptimizedEinsum.jl/src/Solvers/Greedy.jl
Lines 112 to 118 in 9d52b4a
If we can be sure that output indices are gonna be open indices (not open hyperindices), then it could be easily solved by filtering output indices in [a..., b...]
and c
.
In Julia 1.9, Weak Dependencies and Package Dependencies are introduced. Functionality is similar to the one provided by Requires.jl
but has the advantage of support for precompilation.
Use PyCall.pytype_mapping
.
PathInfo
ContractExpression
contract
contract_expression
Currently, it is not possible to have 3D visualization with the following code,
julia> using Makie
julia> using OptimizedEinsum;
julia> using CairoMakie
julia> output, inputs, size_dict = rand_equation(25, 4)
(Symbol[], [[:u, :Q, :k, :g, :M], [:c, :W, :t, :r, :J, :L, :T], [:S, :d, :N, :V, :G, :D], [:b, :c, :d], [:v, :f, :g, :y, :N], [:o, :A], [:h, :i, :x, :t, :w], [:U, :f], [:x, :o], [:s, :i, :L, :q, :W] … [:u, :m, :G], [:A, :e, :a], [:l, :k, :I], [:K, :E, :B, :H], [:h, :C, :e, :B], [:C, :s, :a], [:m, :I, :v], [:w, :T, :j], [:n, :P, :H, :y, :F], [:U, :S, :D, :O]], Dict(:j => 3, :D => 8, :S => 2, :X => 9, :x => 9, :R => 8, :A => 6, :k => 6, :d => 7, :g => 6…))
julia> path = contractpath(RandomGreedy, inputs, output, size_dict)
ContractionPath([(9, 7), (3, 25), (16, 22), (17, 6), (5, 8), (11, 14), (10, 21), (27, 4), (28, 18), (29, 20) … (24, 13), (37, 32), (41, 2), (42, 19), (39, 33), (44, 12), (45, 31), (46, 40), (47, 15), (43, 48)], [[:u, :Q, :k, :g, :M], [:c, :W, :t, :r, :J, :L, :T], [:S, :d, :N, :V, :G, :D], [:b, :c, :d], [:v, :f, :g, :y, :N], [:o, :A], [:h, :i, :x, :t, :w], [:U, :f], [:x, :o], [:s, :i, :L, :q, :W] … [:u, :m, :G], [:A, :e, :a], [:l, :k, :I], [:K, :E, :B, :H], [:h, :C, :e, :B], [:C, :s, :a], [:m, :I, :v], [:w, :T, :j], [:n, :P, :H, :y, :F], [:U, :S, :D, :O]], Symbol[], Dict(:j => 3, :D => 8, :S => 2, :X => 9, :x => 9, :R => 8, :A => 6, :k => 6, :d => 7, :g => 6…))
julia> using NetworkLayout
julia> plot(path; layout=Spring(dim=3))
Instead, it produces a standard 2D plot. The problem seems that the kwargs
are not correctly passed to plot
.
For example, Tullio.jl
The visualization function plot
creates inadequate results for large contraction paths. Ideally, we would want the edges between the nodes to be further separated if the nodes are bigger.
julia> using OptimizedEinsum; using Makie; using CairoMakie
[ Info: Precompiling OptimizedEinsum [c9cfed12-e746-47c4-860d-affc68c43467]
julia> output = Symbol[]
inSymbol[]
julia> inputs = [[:ą, :p, :ċ, :é, :ñ, :ž, :ƶ], [:Ǟ, :ś, :Ɖ, :x, :Ş, :Ě, :õ, :ǩ, :j], [:ǟ, :Ņ, :H], [:ų, :ě, :S, :ƒ, :ǁ, :Ƅ, :Ŀ], [:ĸ, :ŀ, :Š, :Č, :ħ, :V, :ť, :ń], [:Þ, :Ū, :ą, :Ƨ, :i, :B], [:ũ, :U, :ĝ, :R, :ǖ, :í], [:ċ, :Ǩ, :Ĵ, :ƪ, :Ɛ, :ƍ, :n, :Ŗ], [:c, :W, :Á, :ƙ, :ƭ, :Ǒ], [:ǔ, :ư, :d, :C, :o, :Nj, :ł], [:Ç, :t, :Đ, :Ə, :ī, :Ǝ, :Ő, :nj], [:Ǔ, :ƃ, :J, :r, :ƅ, :ú, :ž, :û, :Ē], [:U, :Û, :Ń, :ţ, :Y, :ƣ, :à, :Ĩ, :Ţ], [:ǣ, :Ć, :ś, :ƚ], [:Ǚ, :ĩ, :ǀ], [:Ǜ, :ă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ə => 3, :ƅ => 9, :ħ => 6, :Ħ => 7, :È => 6, :ŋ => 9, :Õ => 8, :ď => 6, :Ǝ => 5, :ŧ => 8, :ť => 2, :ĉ => 9, :lj => 4, :Ǐ => 7, :Ɵ => 3, :ï => 8, :Ɨ => 2, :X => 5, :Ò => 2, :ĺ => 4, :Ǎ => 4, :x => 2, :ñ => 9, :ŗ => 5, :ă => 3, :A => 2, :ų => 4, :Ư => 3, :í => 7, :Ǒ => 8, :ą => 9, :œ => 9, :à => 9, :Ŀ => 2, :b => 9, :ż => 3, :ň => 9, :n => 2, :Ÿ => 9, :l => 7, :w => 9, :ì => 3, :Ƭ => 8, :ã => 9, :ģ => 2, :Ɗ => 3, :ł => 2, :Ñ => 2, :ĥ => 5, :ƫ => 3, :ž => 8, :Ĕ => 4, :f => 7, :ě => 8, :P => 5, :H => 8, :Ń => 6, :Ć => 3, :ĸ => 2, :ǥ => 3, :õ => 2, :ó => 2, :Dž => 9, :Ŭ => 6, :Ʃ => 7, :ī => 7, :ô => 2, :š => 7, :Ý => 8, :ƶ => 4, :d => 5, :ċ => 6, :Ņ => 5, :Ź => 5, :ƿ => 2, :Ě => 9, :y => 7, :ŝ => 6, :LJ => 9, :Œ => 3, :ƣ => 6, :Ē => 2, :ÿ => 3, :F => 6, :ŏ => 5, :ǟ => 8, :c => 2, :ū => 7, :Ä => 7, :ā => 3, :Ğ => 5, :Ƙ => 3, :Ǫ => 6, :Ċ => 7, :Æ => 3, :č => 3, :ŕ => 3, :M => 3, :Ă => 3, :s => 6, :Ɠ => 5, :Q => 3, :Ŧ => 8, :z => 6, :Ŗ => 6, :Å => 3, :Ĵ => 6, :Ƣ => 9, :ƥ => 6, :ğ => 9, :ƺ => 3, :ƛ => 8, :C => 6, :Ǖ => 3, :ı => 9, :j => 6, :û => 7, :Û => 8, :ơ => 6, :á => 6, :Ķ => 7, :ƒ => 7, :Ú => 2, :ƀ => 8, :Ŕ => 5, :ļ => 7, :ġ => 6, :Ɛ => 5, :Ő => 6, :Ʋ => 3, :r => 2, :Ų => 6, :ƍ => 3, :Ĩ => 7, :ư => 7, :Ƽ => 2, :ņ => 3, :Nj => 7, :Ʊ => 4, :Ƥ => 3, :h => 5, :Ø => 7, :× => 8, :K => 7, :ij => 6, : => 6, :ö => 7, :Ģ => 9, :ø => 7, :Ç => 4, :â => 7, :IJ => 2, :ƹ => 8, :Ĝ => 6, :ǝ => 5, :Ł => 9, :ź => 3, :À => 8, :ǜ => 3, :ù => 8, :dž => 5, :ƽ => 3, :É => 3, :Ƹ => 3, :Ļ => 5, :÷ => 7, :ǡ => 3, :ǒ => 3, :S => 3, :Ǜ => 2, :ƻ => 5, :R => 3, :Ĥ => 6, :ǘ => 8, :k => 6, :ŵ => 5, :Ƃ => 3, :ƪ => 5, :Í => 5, :Þ => 9, :Ĭ => 5, :W => 5, :Ġ => 8, :Ž => 9, :O => 6, :ē => 8, :ǁ => 9, :Į => 8, :ƨ => 7, :N => 5, :ð => 6, :ê => 2, :Ŵ => 3, :ę => 4, :Y => 2, :ƾ => 2, :å => 7, :ǔ => 3, :Ū => 2, :ǧ => 8, :Ą => 3, :ŷ => 3, :ő => 7, :ƚ => 9, :Ň => 2, :Ǧ => 3, :Ơ => 8, :nj => 9, :ä => 2, :Ɩ => 2, :T => 3, :Ʒ => 8, :a => 5, :ǣ => 7, :Ù => 4, :Ā => 9, :ç => 8, :Ţ => 2, :Lj => 3, :Ʈ => 7, :B => 4, :Ǘ => 5, :Ƅ => 2, :Ō => 6, :E => 9, :ƙ => 5, :q => 8, :ė => 3, :Ö => 8, :ǂ => 3, :Ď => 7, :Ɖ => 7, :t => 7, :ř => 2, :D => 7, :Ī => 9, :Ƴ => 9, :ĵ => 5, :Ƶ => 6, :ƭ => 5, :ũ => 3, :ú => 9, :Ů => 4, :Ǥ => 6, :Î => 5, :ý => 9, :ķ => 4, :Ť => 3, :ſ => 2, :o => 4, :p => 3, :ò => 5, :Ó => 4, :ƌ => 8, :Ś => 8, :é => 3, :ƕ => 5, :ń => 9, :Ê => 5, :Ǣ => 9, :ĩ => 8, :ë => 9, :Ƌ => 8, :è => 3, :v => 6, :İ => 9, :î => 9, :I => 5, :ü => 9, :G => 3, :Ǡ => 3, :ŭ => 8, :Ż => 2, :L => 5, :ŀ => 9, :ß => 6, :ǩ => 3, :ƴ => 2, :Ř => 2, :Ë => 9, :Ì => 9, :đ => 9, :ǖ => 9, :ľ => 7, :ǎ => 9, :ǀ => 7, :į => 9, :DŽ => 2, :Ŝ => 8, :Ɓ => 7, :Ŋ => 4, :g => 9, :u => 5, :Ɲ => 2, :Ş => 8, :U => 5, :ş => 6, :J => 3, :Č => 9, :i => 6, :ĕ => 9, :ţ => 3, :ƞ => 6, :V => 5, :ĭ => 6, :Ɯ => 8, :ǃ => 6, :Đ => 9, :ǐ => 8, :ů => 2, :Ũ => 8, :Ƒ => 5, :ƈ => 9, :Ʀ => 4, :Ï => 6, :ć => 7, :NJ => 7, :Ǚ => 4, :Ę => 6, :Ǩ => 5)
Dict{Symbol, Int64} with 350 entries:
:Á => 7
:Ű => 3
:Ɔ => 7
:ʼn => 9
:ǚ => 3
:Š => 6
:ƃ => 9
:Ǟ => 7
:Ė => 4
:ĝ => 3
:Ľ => 7
:Ŷ => 7
:m => 5
:ű => 4
:Ĉ => 5
:Ŏ => 5
:ś => 8
:Ƨ => 4
⋮ => ⋮
julia> path_greedy = contractpath(Greedy, inputs, output, size_dict)
ContractionPath(o[(92, 61), (79, 14), (52, 80), (62, 24), (58, 84), (56, 15), (35, 55), (87, 70), (7, 83), (16, 74) … (189, 65), (190, 113), (191, 115), (192, 47), (193, 54), (194, 31), (116, 26), (196, 195), (197, 13), (67, 198)], [[:ą, :p, :ċ, :é, :ñ, :ž, :ƶ], [:Ǟ, :ś, :Ɖ, :x, :Ş, :Ě, :õ, :ǩ, :j], [:ǟ, :Ņ, :H], [:ų, :ě, :S, :ƒ, :ǁ, :Ƅ, :Ŀ], [:ĸ, :ŀ, :Š, :Č, :ħ, :V, :ť, :ń], [:Þ, :Ū, :ą, :Ƨ, :i, :B], [:ũ, :U, :ĝ, :R, :ǖ, :í], [:ċ, :Ǩ, :Ĵ, :ƪ, :Ɛ, :ƍ, :n, :Ŗ], [:c, :W, :Á, :ƙ, :ƭ, :Ǒ], [:ǔ, :ư, :d, :C, :o, :Nj, :ł] … [:Õ, :û, :Ŧ, :Ŝ, :Lj, :ï], [:Ď, :ſ, :Ɲ], [:Ŷ, :ŷ, :E, :İ, :Ƹ, :É, :ƙ, :Ļ, :Ē, :lj, :ƃ], [:Û, :ǐ, :ǎ, :Ľ, :ʼn, :W, :Ư], [:ì, :ú, :i, :Ơ, :q, :ǃ, :Ĕ, :Ƹ], [:ŝ, :Ż, :ĉ, :á, :m, :Š, :ƶ], [:lj, :N, :ã, :ç, :Dž], [:Ƅ, :O, :Ʒ, :Ì, :Ƌ, :ý], [:Ç, :È, :Ł, :Ǜ, :Ǘ, :Ī, :Ų, :Ǥ, :ǂ, :Y, :ų, :ů], [:Ņ, :á, :ƹ, :Ũ, :p, :į, :ŋ, :ƌ, :ů, :Ċ, :Ò]], Symbol[], Dict(:Á => 7, :Ű => 3, :Ɔ => 7, :ʼn => 9, :ǚ => 3, :Š => 6, :ƃ => 9, :Ǟ => 7, :Ė => 4, :ĝ => 3…))
julia> plot(path_greedy)
This issue is used to trigger TagBot; feel free to unsubscribe.
If you haven't already, you should update your TagBot.yml
to include issue comment triggers.
Please see this post on Discourse for instructions and more details.
If you'd like for me to do this for you, comment TagBot fix
on this issue.
I'll open a PR within a few hours, please be patient!
Makie (and GraphMakie) allow registering interactive callbacks to plots such that nodes or edges are highlighted, a popup with more info gets displayed, ...
For this you need an interactive backend (i.e. GLMakie or WGLMakie).
I have been unsuccessful.
Wait for Package extensions on Julia 1.9
We can also use Requires.jl
if we need to support Julia <=1.8
Plots of ContractionPath
would look more awesome if we could get rid of the grid and the axis lines (do not apply to our plots), and add a color bar.
@jofrevalles could you take a look at this? We might want to do the same later in Tenet
.
to graft = injertar
https://en.wikipedia.org/wiki/Grafting
Sometimes, randomly, when I create a random tensor network (with rand_equation
) and find a contraction path using the Greedy solver, it crashes.
using OptimizedEinsum
output, inputs, size_dict = rand_equation(100, 3)
path = contractpath(Greedy, inputs, output, size_dict)
path = optimize(Greedy, inputs, output, size_dict)
ERROR: MethodError: Cannot `convert` an object of type Int64 to an object of type Set{Symbol}
Closest candidates are:
convert(::Type{T}, ::T) where T<:AbstractSet at set.jl:475
convert(::Type{T}, ::AbstractSet) where T<:AbstractSet at set.jl:476
convert(::Type, ::GeoInterface.AbstractGeometryTrait, ::Any) at ~/.julia/packages/GeoInterface/J298z/src/fallbacks.jl:112
...
Stacktrace:
[1] setindex!(h::Dict{Int64, Set{Symbol}}, v0::Int64, key::Int64)
@ Base ./dict.jl:382
[2] (::OptimizedEinsum.Optimizers.var"#4#10"{Dict{Int64, Set{Symbol}}, Vector{Tuple{Int64, Int64}}})(::Tuple{Int64, Set{Symbol}}, ::Tuple{Int64, Set{Symbol}})
@ OptimizedEinsum.Optimizers ~/Workspace/OptimizedEinsum.jl/src/Optimizers/Greedy.jl:70
[3] BottomRF
@ ./reduce.jl:81 [inlined]
[4] FilteringRF
@ ./reduce.jl:107 [inlined]
[5] _foldl_impl(op::Base.FilteringRF{ComposedFunction{Base.Fix2{typeof(isequal), Set{Symbol}}, typeof(last)}, Base.BottomRF{OptimizedEinsum.Optimizers.var"#4#10"{Dict{Int64, Set{Symbol}}, Vector{Tuple{Int64, Int64}}}}}, init::Base._InitialValue, itr::Base.Iterators.Enumerate{Vector{Set{Symbol}}})
@ Base ./reduce.jl:62
[6] foldl_impl
@ ./reduce.jl:48 [inlined]
[7] mapfoldl_impl(f::typeof(identity), op::OptimizedEinsum.Optimizers.var"#4#10"{Dict{Int64, Set{Symbol}}, Vector{Tuple{Int64, Int64}}}, nt::Base._InitialValue, itr::Base.Iterators.Filter{ComposedFunction{Base.Fix2{typeof(isequal), Set{Symbol}}, typeof(last)}, Base.Iterators.Enumerate{Vector{Set{Symbol}}}})
@ Base ./reduce.jl:44
[8] mapfoldl(f::Function, op::Function, itr::Base.Iterators.Filter{ComposedFunction{Base.Fix2{typeof(isequal), Set{Symbol}}, typeof(last)}, Base.Iterators.Enumerate{Vector{Set{Symbol}}}}; init::Base._InitialValue)
@ Base ./reduce.jl:170
[9] mapfoldl
@ ./reduce.jl:170 [inlined]
[10] #mapreduce#263
@ ./reduce.jl:302 [inlined]
[11] mapreduce
@ ./reduce.jl:302 [inlined]
[12] #reduce#265
@ ./reduce.jl:483 [inlined]
[13] reduce(op::Function, itr::Base.Iterators.Filter{ComposedFunction{Base.Fix2{typeof(isequal), Set{Symbol}}, typeof(last)}, Base.Iterators.Enumerate{Vector{Set{Symbol}}}})
@ Base ./reduce.jl:483
[14] ssa_greedy_optimize(inputs::Vector{Vector{Symbol}}, output::Vector{Symbol}, size::Dict{Symbol, Int64}, choose_fn::typeof(OptimizedEinsum.Optimizers.greedy_choose_simple!), cost_fn::typeof(removedsize))
@ OptimizedEinsum.Optimizers ~/Workspace/OptimizedEinsum.jl/src/Optimizers/Greedy.jl:65
[15] optimize(config::Greedy, inputs::Vector{Vector{Symbol}}, output::Vector{Symbol}, size::Dict{Symbol, Int64})
@ OptimizedEinsum.Optimizers ~/Workspace/OptimizedEinsum.jl/src/Optimizers/Greedy.jl:25
[16] optimize(::Type{Greedy}, ::Vector{Vector{Symbol}}, ::Vector{Symbol}, ::Dict{Symbol, Int64})
@ OptimizedEinsum.Optimizers ~/Workspace/OptimizedEinsum.jl/src/Optimizers/Greedy.jl:20
[17] top-level scope
@ REPL[3]:1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.