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

Fix bug causing slices with depth > 1 to be forward-prop'd #62

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

Conversation

caleb-johnson
Copy link
Collaborator

Fixes #60

@caleb-johnson
Copy link
Collaborator Author

This is a bit tangential, but in adjusting the unit tests I realized this line should maybe be >=? We should be able to use 100% of the budget -- not strictly less, right?

@coveralls
Copy link

Pull Request Test Coverage Report for Build 13503277786

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 13182974064: 0.0%
Covered Lines: 432
Relevant Lines: 432

💛 - Coveralls

@BryceFuller
Copy link
Contributor

This is a bit tangential, but in adjusting the unit tests I realized this line should maybe be >=? We should be able to use 100% of the budget -- not strictly less, right?

I agree, it should be >= . While double checking, I also noticed that the condition of the while loop checks equality between two floats with !=, that should be using np.isclose()

Copy link
Contributor

@BryceFuller BryceFuller left a comment

Choose a reason for hiding this comment

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

These look good

Copy link
Member

@mrossinek mrossinek left a comment

Choose a reason for hiding this comment

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

Just some minor comments, other than that, this LGTM 👍

@@ -164,7 +164,8 @@ def handle_timeout(signum, frame):
# PERF: we will likely need to parallelize this loop
for i in range(num_observables):
non_trivial_slice = False
for op_idx, op_node in enumerate(circuit_to_dag(slice_).topological_op_nodes()):
op_nodes = reversed(list(circuit_to_dag(slice_).topological_op_nodes()))
Copy link
Member

Choose a reason for hiding this comment

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

Must we explicitly convert the iterator to a list? Or can we do the following instead?

Suggested change
op_nodes = reversed(list(circuit_to_dag(slice_).topological_op_nodes()))
op_nodes = reversed(circuit_to_dag(slice_).topological_op_nodes())

@@ -164,7 +164,8 @@ def handle_timeout(signum, frame):
# PERF: we will likely need to parallelize this loop
for i in range(num_observables):
non_trivial_slice = False
for op_idx, op_node in enumerate(circuit_to_dag(slice_).topological_op_nodes()):
op_nodes = reversed(list(circuit_to_dag(slice_).topological_op_nodes()))
for op_idx, op_node in enumerate(op_nodes):
Copy link
Member

Choose a reason for hiding this comment

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

Since this op_idx now indexes the gates in the layer in reverse, I wonder whether we should update the log message where this gets used. Just to be super clear about this.

---
fixes:
- |
Fixed a bug in :func:`qiskit_addon_obp.backpropagate` which caused slices with depth > 1 to be incorrectly forward-propagated.
Copy link
Member

Choose a reason for hiding this comment

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

Can we be more explicit and state that gates within a slice will from now on be backpropagated properly, that is, in reverse order.

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.

Operators are forward-propagated through depth >1 slices
4 participants