quantum icon indicating copy to clipboard operation
quantum copied to clipboard

How to run `tfq.layers` on simulators?

Open Shuhul24 opened this issue 2 years ago • 5 comments

I have got circuits that I have built using tfq.layers.ControlledPQC. But now I want to use simulators such as cirq.Simulator() to run the train these tfq.layers on quantum hardware and check the results. How is it done?

Shuhul24 avatar Feb 08 '23 10:02 Shuhul24

Do you want to run on a simulator or hardware? Your question says you want to use simulators to train on hardware (which doesn't make sense). I assume you want to run on hardware (since you can pretty much just directly replace cirq.Simulator as a backend), which would depend on what hardware you want to use. Here is an example for IonQ hardware: https://ionq.com/docs/get-started-with-tensorflow-quantum.

lockwo avatar Feb 08 '23 19:02 lockwo

How does replacing backend=cirq.Simulator() change the training of tfq.layers.ControlledPQC? I mean like I need to train on pure and mixed states, but could not get the way to do it. Can you figure this out?

Shuhul24 avatar Feb 09 '23 07:02 Shuhul24

How does replacing backend=cirq.Simulator() change the training of tfq.layers.ControlledPQC? It makes it run on cirq instead of qsim. It also runs a lot slower, but there is more customization you can do in cirq. If you want to do noisy simulations you can just use a noisy qsim backend via NoisyControlledPQC. See for more info on noise: https://www.tensorflow.org/quantum/tutorials/noise

lockwo avatar Feb 09 '23 07:02 lockwo

How can I run my code on qsim? Is it inherent?

Shuhul24 avatar Feb 09 '23 08:02 Shuhul24

Yes, qsim is just the default

lockwo avatar Feb 09 '23 16:02 lockwo