# Noisy circuits simulations for qml

Just trying to understand how noise modelling works with Pennylane.

If I have a wire with a bunch of gates ending with `qml.RY(2, wires=1)` followed by `qml.BitFlip(0.1, wires=1)`, does this mean that a bitflip error would be applied to all the gates on the wire or just following the application of the `RY` gate?

If the answer is the latter, is there a way to define a bitflip error model which acts globally on the whole circuit rather than having to add it after each gate on each qubit?

Given a noisy simulation, one has to use the `default.mixed` device. Behind the scenes, is this using the `lightning.qubit` device for a given shot, probabilistically applying the noise and then collapsing the wavefunction to build up the density matrix? I ask because the exact simulation with the `ligthning.qubit` device is much much faster that the noisy simulation with the `mixed` device. Any way to speed up my noisy simulations?

Thanks a lot.

Hi @Zohim_Chandani1!
Very good question.

What `qml.BitFlip(0.1, wires=1)` does is that it applies a “probabilistic X gate” which means that it will apply an X gate on your wire with probability p which in this case is 0.1.

This is useful in the sense that you don’t have to apply it after every gate, instead it is a global probability that you will have a bit flip on that wire. If you have many gates then you can make this probability higher. This is almost exactly what you proposed so congrats on the good intuition!

Regarding the question about default.mixed, it actually inherits from `qml.QubitDevice`, which in turn inherits from `qml.device`. The `lightning.qubit`, which is still in beta, is written in a C++ backend so this is why it runs faster.

Speeding-up simulations is always a big question. There are some techniques that you can use, which won’t solve the problem completely but they can help you. For instance, running small problems before you go to the big one. This will help you troubleshoot and make sure that you’re getting the answer you want. Once you’re confident that everything’s working you can simulate the larger problem, and let it run during the night or during the weekend.

Please let me know if this helped!