Update ClassicalSimulator to use simulation infrastructure
Update Classical Simulator to use https://github.com/quantumlib/Cirq/pull/5417
What is the urgency from your perspective for this issue? Is it blocking important work? P2 - we should do it in the next couple of quarters
Hi @NoureldinYosri, I'm interested in working on this issue and have been looking through the related information.
Started work on class based on the ComputationalBasisState and ComputationalBasisSimState classes shown in custom_state_simulator_test.py from #5417.
@shef4 The classical simulator is already implemented https://github.com/quantumlib/Cirq/blob/master/cirq-core/cirq/sim/classical_simulator.py
The goal of this issue is align the implementation with that of other simulators using the infrastructure introduced in the linked PR.
@NoureldinYosri Thanks for clarification. The code I sent is on based on example of infrastructure in custom_state_simulator_test.py. (ComputationalBasisSimState)
I changed the _act_on_fallback_ to include the behaviour and gates described in classical_simulator and comments mentioned in #6124 .
Honestly not sure if using _act_on_fallback_ was the correct thing to do and based it off of ComputationalBasisSimState.
Hi @NoureldinYosri, I see why the test is failing now. They are based on the abstract method in the SimulatesSamples class, _run(program, repetitions, param_resolver).
There's a formatting mismatch between:
- ClassicalStateSimulator
.run(circuit, param_resolver=None, repetitions=1).records= {'key': array([[[1, 0]]], dtype=uint8)} CustomStateSimulator(ClassicalStateSimulator).simulate(circuit).measurements= {'key': array([1, 0], dtype=uint8)}
Thanks for the help!
q0, q1 = cirq.LineQubit.range(2)
circuit = cirq.Circuit()
circuit.append(cirq.X(q0))
circuit.append(cirq.X(q1))
circuit.append(cirq.X(q1))
circuit.append(cirq.measure((q0, q1), key='key'))
completed in https://github.com/quantumlib/Cirq/pull/6432