-
Notifications
You must be signed in to change notification settings - Fork 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 classical simulator #6124
Add classical simulator #6124
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
…i/Cirq into add_classical_simulator
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.
Glad to see the pull request appear! Now time to get the tests to pass.
You will also need to get the CLA (contributor license agreement) signed.
…i/Cirq into add_classical_simulator
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 for helping with this project. Please address only the remaining comments and we will be able to merge your PR :)
@@ -64,7 +64,7 @@ def _unitary_(self) -> np.ndarray: | |||
return m1 | |||
|
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 don't need to make any changes to this file or to the .gitignore
file. please do
git checkout master cirq-core/cirq/protocols/unitary_protocol_test.py
git checkout master .gitignore
git add cirq-core/cirq/protocols/unitary_protocol_test.py .gitignore
git commit -m "restore unrelated files to their original state"
match="Can not simulate gates other than " | ||
+ "cirq.XGate, cirq.CNOT, cirq.SWAP, and cirq.CCNOT", | ||
): | ||
sim.run(circuit, param_resolver=resolver, repetitions=1).records |
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.
add _ =
before sim.run
inorder to pass the pylint
tests
|
||
|
||
class ClassicalStateSimulator(SimulatesSamples): | ||
"""basic simulator that only accepts cirq.X, cirq.ISwap, and cirq.CNOT gates |
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.
please replace the docstring with
"""A simulator that only accepts only gates with classical counterparts.
This simulator evolves a single state, using only gates that output a single state for each
input state. The simulator runs in linear time, at the cost of not supporting superposition.
It can be used to estimate costs and simulate circuits for simple non-quantum algorithms using
many more qubits than fully capable quantum simulators.
The supported gates are:
- cirq.X
- cirq.CNOT
- cirq.SWAP
- cirq.TOFFOLI
- cirq.measure
Args:
circuit: The circuit to simulate.
param_resolver: Parameters to run with the program.
repetitions: Number of times to repeat the run. It is expected that
this is validated greater than zero before calling this method.
Returns:
A dictionary mapping measurement keys to measurement results.
Raises:
ValueError: If one of the gates is not an X, CNOT, SWAP, TOFFOLI or a measurement.
"""
@naerabati thanks for your help with this project. I fixed the failing style CI and removed unrelated files. |
thanks so much! I'm glad to see this merged. |
No description provided.