-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add cirq.StabilizerSampler #3355
Conversation
Strilanc
commented
Sep 23, 2020
- Minimal interface
- Supports some random operations (depolarize, probabilistic gates)
- This is a potential replacement for cirq.CliffordSimulator (which is in a bad state right now, tracking two redundant state objects in a fashion observable to callers)
- Minimal interface - Supports some random operations (depolarize, probabilistic gates) - This is a potential replacement for cirq.CliffordSimulator (which is in a bad state right now, tracking two redundant state objects in a fashion observable to callers)
cirq/ops/common_channels.py
Outdated
@@ -183,6 +183,17 @@ def __repr__(self) -> str: | |||
def __str__(self) -> str: | |||
return 'depolarize(p={!r})'.format(self._p) | |||
|
|||
def _act_on_(self, args): |
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: missing type annotations
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.
Done.
} | ||
axes_map = {q: i for i, q in enumerate(circuit.all_qubits())} | ||
|
||
for _ in range(repetitions): |
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.
Question: Why not propagate the stabilizer once and sample from the resulting stabilizer state at the end? I suppose it's simply deferred to a follow-up?
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.
Measurements can return random results which play out in different ways. In principle we could check if all measurements are terminal, or translate the circuit into a graph dataflow form that was faster to sampler from (assuming all classically controlled operations were Paulis). I wasn't planning to do these optimizations.
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.
The optimization would mostly target circuits with terminal measurements. We could also support measurements commuting with stabilizer, but that may be excessive and not useful. Finally, in some applications you want probability of a prescribed (Pauli) measurement result and in this case there is a unique update to the stabilizer generators consistent with the 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.
LGTM with nits
…c_cliffords # Conflicts: # cirq/ops/common_channels_test.py
Automerge cancelled: A status check is failing. |