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

Add cirq.StabilizerSampler #3355

Merged
merged 7 commits into from
Sep 29, 2020
Merged

Add cirq.StabilizerSampler #3355

merged 7 commits into from
Sep 29, 2020

Conversation

Strilanc
Copy link
Contributor

  • 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)
@googlebot googlebot added the cla: yes Makes googlebot stop complaining. label Sep 23, 2020
@@ -183,6 +183,17 @@ def __repr__(self) -> str:
def __str__(self) -> str:
return 'depolarize(p={!r})'.format(self._p)

def _act_on_(self, args):
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: missing type annotations

Copy link
Contributor Author

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):
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

Copy link
Contributor

@balopat balopat left a comment

Choose a reason for hiding this comment

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

LGTM with nits

cirq/sim/clifford/stabilizer_sampler.py Outdated Show resolved Hide resolved
cirq/ops/random_gate_channel.py Show resolved Hide resolved
…c_cliffords

# Conflicts:
#	cirq/ops/common_channels_test.py
@Strilanc Strilanc added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Sep 29, 2020
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Sep 29, 2020
@CirqBot
Copy link
Collaborator

CirqBot commented Sep 29, 2020

Automerge cancelled: A status check is failing.

@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Sep 29, 2020
@Strilanc Strilanc added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Sep 29, 2020
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Sep 29, 2020
@CirqBot CirqBot merged commit e852d58 into master Sep 29, 2020
@CirqBot CirqBot removed the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Sep 29, 2020
@CirqBot CirqBot deleted the probabilistic_cliffords branch September 29, 2020 18:35
@CirqBot CirqBot removed the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Makes googlebot stop complaining. pr/lgtm-with-nit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants