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

feat: option to disable legend #20

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

Conversation

boonware
Copy link

@boonware boonware commented Oct 2, 2024

Issue

#19

Description

  • Add a new parameter to each visualization function to disable showing the legend in plots. Defaults to True.
  • Style changes were made via tox -e style.

@BryceFuller

@CLAassistant
Copy link

CLAassistant commented Oct 2, 2024

CLA assistant check
All committers have signed the CLA.

BryceFuller pushed a commit to BryceFuller/qiskit-addon-obp that referenced this pull request Oct 2, 2024
* refactor: replace max_gates with max_layers

* poc: error budgeting for observable truncation

* Cache previous iteration to avoid exceeding error budget (Qiskit#20)

* Cache previous iteration to avoid exceeding error budget

* Update comment

* Update comment

* Update comment

* Remove no-op

* perf: partitioning implementation idea

This simply adds a note for a higher performance implementation based on
iteratively partitioning the array of coefficients during truncation.
Originally I had thought that an implementation based on sorting
followed by a `numpy.cumsum` might be better than the while loop.
However, a binary search as implemented currently is likely to be faster
for the array sizes that we will be dealing with here (since it does not
have the initial overhead of sorting; thanks to Minh for pointing this
out, too).

If this does ever become a bottleneck, we could gain some performance
with the suggestion of this commit. Here are some additional resources:

- https://numpy.org/doc/stable/reference/generated/numpy.partition.html
- https://stackoverflow.com/a/46043964/21957877

* refactor: merge all gates in a layer before back-propagating

Since our observable `SparsePauliOp` is the object which will grow fast,
we should avoid as many `compose` operations with it as possible. Thus,
this commit refactors the back-propagating implementation to:

1. First compose all gates in a layer which intersect with our current
   observable. Since all gates inside any layer are disjoint, these
   compositions should be fairly fast since they can be combined
   trivially.
2. Only now perform the possibly expensive composition with our current
   observable.

This is mathematically equivalent to back-propagating each gate
one-by-one but should be more performant.

* refactor: minor clean-up

* refactor: rename truncate_legacy to truncate_binary_search

* refactor: start from correct upper truncation bounds

* refactor: updates the entire error thresholding logic

* Apply suggestions from code review

* Fix inputs to funcs in tests

---------
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