Skip to content

Conversation

@daxfohl
Copy link
Collaborator

@daxfohl daxfohl commented May 28, 2022

Infrastructure for third-parties to easily create custom Cirq-compatible simulators.

This PR makes it easy to create custom simulators that support all the advanced Cirq features such as

  • subcircuits
  • classical controls (sympy conditions, indexed conditions)
  • repeat_until loops
  • noise models
  • param resolvers
  • parameterized repetitions
  • product-state mode

As an example in the tests, a ComputationalBasisState simulator supporting all the above can be implemented in under 20 LOC.

@daxfohl daxfohl marked this pull request as ready for review May 29, 2022 15:56
@daxfohl daxfohl requested review from a team, cduck and vtomole as code owners May 29, 2022 15:56
@daxfohl daxfohl requested a review from MichaelBroughton May 29, 2022 15:56
@daxfohl
Copy link
Collaborator Author

daxfohl commented May 31, 2022

@95-martin-orion wdyt here? Useful, not useful? Now or post-1.0?

@95-martin-orion
Copy link
Collaborator

@95-martin-orion wdyt here? Useful, not useful? Now or post-1.0?

Yeah, I think this is potentially interesting pre-1.0. The set of simulators it supports is rather limited [1], but there's a good number of simulators in that space and as the test shows it's quite powerful for that subset. I'll give a more detailed review in a bit.

[1] The stepwise structure rules out tensor-network simulators like quimb, and the tight Cirq coupling (simulation uses act_on methods and requires read/write access to the classical data during simulation) would be difficult to implement in non-Python simulators like qsim without a performance overhead.

@CirqBot CirqBot added the size: L 250< lines changed <1000 label May 31, 2022
Copy link
Collaborator

@95-martin-orion 95-martin-orion left a comment

Choose a reason for hiding this comment

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

I think contrib is the right place for this so that it's clearly separate from the core simulator API, but it's a nicely encapsulated example for using the simulator internals.

@95-martin-orion 95-martin-orion added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jun 1, 2022
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Jun 1, 2022
@CirqBot CirqBot merged commit 2f9162e into quantumlib:master Jun 1, 2022
@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 Jun 1, 2022
@daxfohl daxfohl deleted the basic-sim branch June 2, 2022 01:32
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
Infrastructure for third-parties to easily create custom Cirq-compatible simulators.

This PR makes it easy to create custom simulators that support all the advanced Cirq features such as
* subcircuits
* classical controls (sympy conditions, indexed conditions)
* repeat_until loops
* noise models
* param resolvers
* parameterized repetitions
* product-state mode

As an example in the tests, a ComputationalBasisState simulator supporting all the above can be implemented in under 20 LOC.
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this pull request Oct 31, 2024
Infrastructure for third-parties to easily create custom Cirq-compatible simulators.

This PR makes it easy to create custom simulators that support all the advanced Cirq features such as
* subcircuits
* classical controls (sympy conditions, indexed conditions)
* repeat_until loops
* noise models
* param resolvers
* parameterized repetitions
* product-state mode

As an example in the tests, a ComputationalBasisState simulator supporting all the above can be implemented in under 20 LOC.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: L 250< lines changed <1000

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants