-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add a new transformer that performs random pauli insertion #7558
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
base: main
Are you sure you want to change the base?
Conversation
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.
Thanks, Nour! This is great! A few comments:
- Can we have a clear, deterministic way of saying which qubit is which in the
probabilities
array? - For applications, we might need finer-grained pair-by-pair control over the probabilities.
- Also see the
error_mitigation/noise_adding.py
file in my user folder.
Eliott will chat with you at our chat |
67b69a1
to
0b6a9a4
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7558 +/- ##
========================================
Coverage 97.50% 97.50%
========================================
Files 1101 1103 +2
Lines 99411 99541 +130
========================================
+ Hits 96928 97058 +130
Misses 2483 2483 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
probabilities of sampling 2Q paulis. The order of the paulis is IXYZ. | ||
If at operation `op` a pair (i, j) is sampled then _PAULIS[i] is applied | ||
to op.qubits[0] and _PAULIS[j] is applied to op.qubits[1]. | ||
If None, assume uniform distribution. |
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.
A uniform distribution would completely depolarize the state, which is probably not what we want. I think probabilities
should be required.
probabilities: np.ndarray | Mapping[tuple[ops.Qid, ops.Qid], np.ndarray] | None = None, | ||
): | ||
"""Makes a pauli insertion transformer that samples 2Q paulis with the given probabilities. | ||
|
||
Args: | ||
target: The target gate, gatefamily, gateset, or type (e.g. ZZPowGAte). | ||
probabilities: Optional ndarray or mapping[qubit-pair, nndarray] representing the | ||
probabilities of sampling 2Q paulis. The order of the paulis is IXYZ. | ||
If at operation `op` a pair (i, j) is sampled then _PAULIS[i] is applied | ||
to op.qubits[0] and _PAULIS[j] is applied to op.qubits[1]. | ||
If None, assume uniform distribution. |
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.
Maybe we should require that probabilities
be a mapping from qubit pairs to numpy arrays and use the order in the qubit pair (not in the op, which is less easily accessible to the user) to determine which qubit is which in probabilities
.
assert np.isclose(probs.sum(), 1) | ||
assert probs.shape == (4, 4) |
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 you change these to ValueError
s and document them in a Raises
section of the docstring? Also check that none of them are negative.
|
||
Args: | ||
target: The target gate, gatefamily, gateset, or type (e.g. ZZPowGAte). | ||
probabilities: Optional ndarray or mapping[qubit-pair, nndarray] representing the |
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.
You should say more clearly that probabilities
contains 4x4 arrays and the [i,j] element is the probability of applying _PAULIS[i] to qubit 0 and _PAULIS[j] to qubit 1, where the two qubits now (if you make the other change I suggest) are in the order specified in the key of the dictionary.
implements the error mitigation technique described in appendix D of https://arxiv.org/abs/2503.20870