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

Update backtrack_path() to use one less lookup in back_map. #888

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gopinath-vasalamarri
Copy link

The initial inputs to (cur_state, prev_state) map to (next, curr) --> which are already computed. This lets us bypass calling the back_map.at(next) by passing in curr.

Update backtrack_path to use one less lookup in back_map.
Copy link
Collaborator

@Strilanc Strilanc left a comment

Choose a reason for hiding this comment

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

Thanks for the submission, but I'm not going to accept this.

First, the backtracking method isn't on the hot path. This has essentially 0 performance impact. Second, the impact would be negative because now you are making copies of the search state (due to using auto instead of const auto & for the type), and this is causing allocations. I also don't like that it's increasing the coupling between the backtracking method and the search method (by requiring a redundant argument to be passed).

A useful version of this change would be to refactor SearchState to use a uint64_t mask, so that no allocations were needed to copy it. This would accelerate the searching process, which is the hot path. Ironically this is how the method used to work, but it was changed because it didn't work for circuits with more than 64 observables. That could be fixed by iterating over the observables 64 at a time and invoking the search for each group of 64. This would be much faster due to not allocating during the hot loop of expanding the search region. If you're interested in speeding up the method, that's what you should do.

That change I would definitely accept.

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.

2 participants