-
Notifications
You must be signed in to change notification settings - Fork 30
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 extrapolation in ZNE function #1213
base: main
Are you sure you want to change the base?
Conversation
Need to extrapolate against scale factors rather than folding numbers.
@@ -273,6 +273,10 @@ | |||
|
|||
<h3>Bug fixes</h3> | |||
|
|||
* Fix a bug in the extrapolation part of the `catalyst.mitigate_with_zne` function that would lead |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: the sentence reads a bit redundant. A bug in extrapolation code leads to..incorrect extrapolated result"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Fix a bug in the extrapolation part of the `catalyst.mitigate_with_zne` function that would lead | |
* Fix a bug in `catalyst.mitigate_with_zne` that would lead |
@@ -164,14 +162,14 @@ class ZNECallable(CatalystCallable): | |||
def __init__( | |||
self, | |||
fn: Callable, | |||
num_folds: jnp.ndarray, | |||
scale_factors: Sequence, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can type them more strictly as [int]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scale_factors: Sequence, | |
scale_factors: Sequence[int], |
@@ -209,16 +207,18 @@ def __call__(self, *args, **kwargs): | |||
callable_fn | |||
), "expected callable set as param on the first operation in zne target" | |||
|
|||
results = zne_p.bind( | |||
*args_data, self.num_folds, folding=folding, jaxpr=jaxpr, fn=callable_fn | |||
fold_numbers = (jnp.asarray(self.scale_factors, dtype=int) - 1) // 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice that they became element-wise ops 🤙🏻
Extrapolation was done against the folding numbers instead of the scale factors. Since the folding numbers start at 0, extrapolation would always yield a result very close to the first data point.