# Noisy circuits simulations for qml

**URL:** https://discuss.pennylane.ai/t/noisy-circuits-simulations-for-qml/1350
**Category:** PennyLane Help
**Created:** [September 14, 2021, 1:12pm UTC](https://discuss.pennylane.ai/t/noisy-circuits-simulations-for-qml/1350 "2021-09-14T13:12:11Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Zohim\_Chandani1](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/zohim_chandani1/32/584_2.png) [@Zohim\_Chandani1](https://discuss.pennylane.ai/u/Zohim_Chandani1)
#### Post date: [September 14, 2021, 1:12pm UTC](https://discuss.pennylane.ai/t/noisy-circuits-simulations-for-qml/1350/1 "2021-09-14T13:12:11Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![CatalinaAlbornoz](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/catalinaalbornoz/32/1196_2.png) [@CatalinaAlbornoz](https://discuss.pennylane.ai/u/CatalinaAlbornoz)
#### Post date: [September 14, 2021, 5:51pm UTC](https://discuss.pennylane.ai/t/noisy-circuits-simulations-for-qml/1350/2 "2021-09-14T17:51:40Z")

</div>

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!

This tutorial can help you learn more about noise in circuits. [https://pennylane.ai/qml/demos/tutorial\_noisy\_circuits.html](https://pennylane.ai/qml/demos/tutorial_noisy_circuits.html)

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!
