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

Greedy router #3360

Merged
merged 14 commits into from
Sep 30, 2020
Merged

Greedy router #3360

merged 14 commits into from
Sep 30, 2020

Conversation

yourball
Copy link
Contributor

Fixes issue #3056. Fixes hanging greedy router on some circuit instances by partially reverting changes from 6d81ddb.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@yourball
Copy link
Contributor Author

@googlebot I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes Makes googlebot stop complaining. and removed cla: no labels Sep 24, 2020
Copy link
Contributor

@balopat balopat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for taking the time digging this out!! The fix looks good to me, as it is covered by tests. However, it would be great to put a test around it so that we can prevent regression (like what we have now).

The test would run a minimal instance where we can prove that the algorithm would run on infinite loops without this fix, but fast (<1s) with the fix. The algorithm would run in a separate process that we should measure if it finishes within the expected time. Can you find a graph instance like that?

Copy link
Contributor

@balopat balopat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - One more nit
Thanks for adding the test, I just tried it out and it works nicely! :)
We should make the timeout 5 seconds to avoid flakes, on my Mac it runs just above 2 seconds.

process.join(timeout=1)
alive = process.is_alive()
if alive:
process.terminate()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would do something like this instead - this takes care of the coverage issue as well

    try:
        assert not process.is_alive(), "Greedy router timeout"
    finally:
        process.terminate()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks! Was happy to contribute. It looks like all tests passed now.:)

@balopat balopat added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Sep 30, 2020
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Sep 30, 2020
@CirqBot CirqBot merged commit be1d024 into quantumlib:master Sep 30, 2020
@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Sep 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Makes googlebot stop complaining.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants