Add a new transformer that performs random pauli insertion#7558
Add a new transformer that performs random pauli insertion#7558NoureldinYosri wants to merge 8 commits intoquantumlib:mainfrom
Conversation
eliottrosenberg
left a comment
There was a problem hiding this comment.
Thanks, Nour! This is great! A few comments:
- Can we have a clear, deterministic way of saying which qubit is which in the
probabilitiesarray? - For applications, we might need finer-grained pair-by-pair control over the probabilities.
- Also see the
error_mitigation/noise_adding.pyfile 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.
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.
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.
Can you change these to ValueErrors 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.
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.
|
This pull request has been automatically labeled as stale because 90 days have passed without comments or other activity. If no further activity occurs and the If you have questions or feedback about this process, we welcome your input. You can open a new issue to let us know (please also reference this issue there, for continuity), or reach out to the project maintainers at quantum-oss-maintainers@google.com. |
implements the error mitigation technique described in appendix D of https://arxiv.org/abs/2503.20870