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

Ease optimization by separately optimizing disconnected graph components #51

Open
mofeing opened this issue Feb 7, 2024 · 5 comments · May be fixed by #53
Open

Ease optimization by separately optimizing disconnected graph components #51

mofeing opened this issue Feb 7, 2024 · 5 comments · May be fixed by #53
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@mofeing
Copy link
Member

mofeing commented Feb 7, 2024

Currently, optimizers think all the TN graph is connected. Although rare, there are cases in which disconnected components coexist in the same TN.

The optimizers should be able to run on them without any problem (maybe there are some edge-cases, but I wouldn't care about them until someone finds them) but their optimization should run smoother if optimization is run separately on each component, and then finally sum together.

We should have something like TensorOperations.connectedcomponents but implemented as sumtraces; i.e. like a transformation of an EinExpr.

@mofeing mofeing added enhancement New feature or request good first issue Good for newcomers labels Feb 7, 2024
@mofeing
Copy link
Member Author

mofeing commented Feb 7, 2024

@lkdvos I've moved the discussion about disconnected components to here.

@lkdvos
Copy link

lkdvos commented Feb 7, 2024

Great!

@lkdvos
Copy link

lkdvos commented Feb 8, 2024

Let me quickly mention that it's not only an enhancement, it still just hangs: (this might be a good case to just add to the tests, it's easy to check that it produces the correct result :))

using EinExprs # master branch (134d7f07bbdfdd950df54a1680fcb0174a68ed38)
network = [[:a, :b], [:b, :c], [:A, :B], [:B, :C]]
expr = sum(EinExpr.(network))
optdata = Dict(key => 2 for key in unique(vcat(network...)))
einexpr(Exhaustive(), expr, optdata) # hangs

@mofeing mofeing added bug Something isn't working and removed enhancement New feature or request labels Feb 8, 2024
@Todorbsc
Copy link

Todorbsc commented Feb 8, 2024

network = [[:a, :b], [:b, :c], [:A, :B], [:B, :C]]
expr = sum(EinExpr.(network))
optdata = Dict(key => 2 for key in unique(vcat(network...)))
einexpr(Exhaustive(), expr, optdata) # hangs

This only happens with Exhaustive() optimizer, right?

Using Naive():

julia> expr_naive = einexpr(EinExprs.Naive(), expr, optdata)
EinExpr{Symbol}([:a, :c, :A, :C], EinExpr{Symbol}[EinExpr{Symbol}([:a, :c, :A, :B], EinExpr{Symbol}[EinExpr{Symbol}([:a, :c], EinExpr{Symbol}[EinExpr{Symbol}([:a, :b], EinExpr{Symbol}[]), EinExpr{Symbol}([:b, :c], EinExpr{Symbol}[])]), EinExpr{Symbol}([:A, :B], EinExpr{Symbol}[])]), EinExpr{Symbol}([:B, :C], EinExpr{Symbol}[])])

Using Greedy():

julia> expr_greedy = einexpr(Greedy(), expr, optdata)
EinExpr{Symbol}([:a, :c, :A, :C], EinExpr{Symbol}[EinExpr{Symbol}([:A, :B], EinExpr{Symbol}[]), EinExpr{Symbol}([:B, :C], EinExpr{Symbol}[]), EinExpr{Symbol}([:a, :c], EinExpr{Symbol}[EinExpr{Symbol}([:a, :b], EinExpr{Symbol}[]), EinExpr{Symbol}([:b, :c], EinExpr{Symbol}[])])])

@mofeing
Copy link
Member Author

mofeing commented Feb 8, 2024

As far as we know, it only hangs in Exhaustive, but all optimizers should benefit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants