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

Refactoring remove_y_operators_from_circuit #184

Closed
alexnguyenn opened this issue Dec 6, 2021 · 2 comments · Fixed by #185
Closed

Refactoring remove_y_operators_from_circuit #184

alexnguyenn opened this issue Dec 6, 2021 · 2 comments · Fixed by #185
Assignees
Labels
enhancement New feature or request refactor Restructuring the codebase testing All things test-related

Comments

@alexnguyenn
Copy link
Member

alexnguyenn commented Dec 6, 2021

remove_y_operators_from_circuit is a critical component for our compiler. Right now it contains too many moving parts which makes it hard for us to write tests.

It also uses the pop mechanism that we previously decided against. It was meant to move the newly generated pi/4 rotation on the RHS towards the end of the circuit so we don't have to run apply_transformation again:

# Commute the right (new) pi/4 rotations towards the end of the circuit
for right_block_index in right_block_indices:
while right_block_index + 1 < len(self.ops):
self.swap_adjacent_blocks(right_block_index)
right_block_index += 1
if circuit_has_measurements:
self.ops.pop()

So I am planning to:

  • Divide the whole thing into smaller parts - starting with the Y op removing logic for a single block.
  • Add test. Will use examples from Litinski's but might need help with verification.
  • Remove pop logic.

This is opened for discussion. LMK if I am missing anything here.

@alexnguyenn alexnguyenn added enhancement New feature or request refactor Restructuring the codebase testing All things test-related labels Dec 6, 2021
@alexnguyenn alexnguyenn self-assigned this Dec 6, 2021
@alexnguyenn alexnguyenn pinned this issue Dec 6, 2021
@gwwatkin
Copy link
Member

gwwatkin commented Dec 6, 2021

Sounds good. I think we can avoid commuting the RHS corrective terms to the end. It's an extra level of complexity, which without the popping, which we need to remove to preserve state vectors, doesn't buy us anything.

Having this commutation loop was a bit more subtle than just avoiding one more call of the Litinski transform. Y op removal is only correct if run after the Litinski transform, because as we move corrective terms along, they may cause more Y operators to arise. So just calling Y removal and then Litinski might not remove all Y operators.

@alexnguyenn
Copy link
Member Author

alexnguyenn commented Dec 7, 2021

@gwwatkin thanks for pointing that out. Just updated the description.

Y op removal is only correct if run after the Litinski transform

Just want to refresh my memories for this, but is there a situation where we need to run this even without Litinski being called prior? Seems like the Y operators are brought out during the process of Litinski transform.

@alexnguyenn alexnguyenn unpinned this issue Jan 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactor Restructuring the codebase testing All things test-related
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants