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

Noise Scaling for LRE #2347

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Noise Scaling for LRE #2347

wants to merge 6 commits into from

Conversation

purva-thakre
Copy link
Contributor

Fixes #2307

Description


License

  • I license this contribution under the terms of the GNU GPL, version 3 and grant Unitary Fund the right to provide additional permissions as described in section 7 of the GNU GPL, version 3.

Before opening the PR, please ensure you have completed the following where appropriate.

The required specific pattern for multivariate extrapolation does not allow
a user to provide a choice of which layers to fold. If you would prefer to
use a multivariate extrapolation method for unitary
folding, use the functions available in `mitiq/lre` instead.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When this PR is close to being merged, replace mitiq/lre with the seealso directive from Sphinx.

https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive-seealso

Copy link

codecov bot commented May 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.25%. Comparing base (b58f029) to head (f6885cc).
Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2347      +/-   ##
==========================================
+ Coverage   98.22%   98.25%   +0.02%     
==========================================
  Files          87       89       +2     
  Lines        4056     4115      +59     
==========================================
+ Hits         3984     4043      +59     
  Misses         72       72              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

degree: int,
fold_multiplier: int,
num_chunks: int = 1,
) -> list[tuple[int]]:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To do: Understand this List comprehension has incompatible type List[Tuple[Any, ...]]; expected List[Tuple[int]]

https://realpython.com/python-type-checking/
https://mypy.readthedocs.io/en/stable/kinds_of_types.html#tuple-types
https://mypy.readthedocs.io/en/stable/builtin_types.html

Copy link
Contributor

@cosenal cosenal May 14, 2024

Choose a reason for hiding this comment

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

  1. tuple[int] is the type of a tuple with only one element. If you want the tuple to have an arbitrary number of integer elements, then you want to type it as tuple[int, ...]
  2. The Any is because mypy can't infer that the tuple elements generated here are integer. It should go away after fix 1.
  3. Instead of built-in types list and tuple, it's recommended to use List and Tuple from the typing module, i.e., from typing import List, Tuple and then List[Tuple[int, ...]]

input_circuit: cirq.Circuit,
degree: int,
fold_multiplier: int,
num_chunks: int = 1,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be better to use the default value as None for the parameter num_chunks. Making changes to this currently leads to the circuit getting chunked into 1 layer when I use the default value . Figure this out; make changes.

folding_method: Callable[
[QPROGRAM, float], QPROGRAM
] = fold_gates_at_random,
):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

forgot the return type for this function. mypy caught this as well.

mitiq/lre/multivariate_scaling/layerwise_folding.py:128: error: Function is missing a return type annotation [no-untyped-def]

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.

LRE Functions: Noise Scaling
2 participants