This is done using quantum error-correction codes (QECCs).
Quantum error correction (QEC) is a way to mitigate these errors and ensure that the data stored on a quantum computer is error-free, thus improving the reliability and accuracy of quantum computers. The principle of QEC is to encode the data stored on a quantum computer such that the errors can be detected and corrected without disrupting the computation being performed on it. This is done using quantum error-correction codes (QECCs). QECCs work by encoding the information onto a larger state space. They further correct the error without measuring the quantum state, thereby preventing the collapse of the quantum state.