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

lightweight random greedy optimization #34

Merged
merged 2 commits into from
Apr 19, 2024
Merged

lightweight random greedy optimization #34

merged 2 commits into from
Apr 19, 2024

Conversation

jcmgray
Copy link
Owner

@jcmgray jcmgray commented Apr 16, 2024

This adds support for lightweight random greedy optimization (no hyper parameter tuning or ContractionTree construction), with the following:

  • optimize_random_greedy_track_flops, with a cotengrust version to follow.
  • RandomGreedyOptimizer, a stateful optimizer which wraps the python or rust version above, with parallelization etc.

TODO:

  • maybe a ReusableRandomGreedyOptimizer

cc @CSNWEB

@pep8speaks
Copy link

pep8speaks commented Apr 16, 2024

Hello @jcmgray! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 795:80: E501 line too long (82 > 79 characters)

Comment last updated at 2024-04-19 20:20:05 UTC

@CSNWEB
Copy link

CSNWEB commented Apr 16, 2024

Awesome that was fast, thanks! I will have a look at it later this week.

@jcmgray
Copy link
Owner Author

jcmgray commented Apr 16, 2024

Rust counterpart is here: jcmgray/cotengrust@f3a3e50.

With the overall performance increase (and memory decrease), pretty big contractions are now amenable:

import cotengra as ctg

# 10,000 nodes
inputs, output, shapes, size_dict = ctg.utils.lattice_equation([100, 100])
opt = ctg.RandomGreedyOptimizer(max_repeats=128)

%%timeit
ssa_path = opt.ssa_path(inputs, output, size_dict)
# 1.75 s ± 48.4 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

@jcmgray
Copy link
Owner Author

jcmgray commented Apr 19, 2024

Merging for the moment, but open to any additional suggestions before releasing it.

@jcmgray jcmgray merged commit f6250a0 into main Apr 19, 2024
15 checks passed
@CSNWEB
Copy link

CSNWEB commented Apr 20, 2024

Thanks again, looked through the code and it looks very good to me. Seems to contain everything I mentioned and could need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants