Hi @Tz_19 ,
This is actually due to the way mid-circuit measurements are performed. It’s a very common error! I recently explained it in Forum post #9102, so I would recommend checking it out for more details. In short, you need to add more wires to your device, so the easiest way to do it is to let the device automatically detect the number of wires it needs. You can do this by simply not setting a number of wires when you create an instance of default.qubit.
dev=qml.device("default.qubit")
Let me know if this solves your issue!