Table of Contents
Fetching ...

Quantum Backtracking in Qrisp Applied to Sudoku Problems

Raphael Seidel, René Zander, Matic Petrič, Niklas Steinmann, David Q. Liu, Nikolay Tcholtchev, Manfred Hauswirth

TL;DR

This work systematically implements Montanaro's quantum backtracking algorithm within the Qrisp framework and demonstrates its applicability to Sudoku. By encoding backtracking as a quantum walk with accept/reject oracles, the authors provide a complete pipeline including psi_prep, qstep_diffuser, and phase-estimation-based search, together with Sudoku-specific encodings via graph coloring and batched checks. They show practical feasibility by simulating 4x4 Sudoku instances with up to 9 empty cells on IBM's MPS backend, using 91 qubits and a circuit depth of 3968 for the hardest case, and make the code publicly available. The combination of high-level software engineering, phase-tolerant synthesis, and modular backtracking primitives highlights a viable path toward scalable quantum optimization for CSPs and complex search problems.

Abstract

The quantum backtracking algorithm proposed by Ashley Montanaro raised considerable interest, as it provides a quantum speed-up for a large class of classical optimization algorithms. It does not suffer from Barren-Plateaus and transfers well into the fault-tolerant era, as it requires only a limited number of arbitrary angle gates. Despite its potential, the algorithm has seen limited implementation efforts, presumably due to its abstract formulation. In this work, we provide a detailed instruction on implementing the quantum step operator for arbitrary backtracking instances. For a single controlled diffuser of a binary backtracking tree with depth n, our implementation requires only $6n+14$ CX gates. We detail the process of constructing accept and reject oracles for Sudoku problems using our interface to quantum backtracking. The presented code is written using Qrisp, a high-level quantum programming language, making it executable on most current physical backends and simulators. Subsequently, we perform several simulator based experiments and demonstrate solving 4x4 Sudoku instances with up to 9 empty fields. This is, to the best of our knowledge, the first instance of a compilable implementation of this generality, marking a significant and exciting step forward in quantum software engineering.

Quantum Backtracking in Qrisp Applied to Sudoku Problems

TL;DR

This work systematically implements Montanaro's quantum backtracking algorithm within the Qrisp framework and demonstrates its applicability to Sudoku. By encoding backtracking as a quantum walk with accept/reject oracles, the authors provide a complete pipeline including psi_prep, qstep_diffuser, and phase-estimation-based search, together with Sudoku-specific encodings via graph coloring and batched checks. They show practical feasibility by simulating 4x4 Sudoku instances with up to 9 empty cells on IBM's MPS backend, using 91 qubits and a circuit depth of 3968 for the hardest case, and make the code publicly available. The combination of high-level software engineering, phase-tolerant synthesis, and modular backtracking primitives highlights a viable path toward scalable quantum optimization for CSPs and complex search problems.

Abstract

The quantum backtracking algorithm proposed by Ashley Montanaro raised considerable interest, as it provides a quantum speed-up for a large class of classical optimization algorithms. It does not suffer from Barren-Plateaus and transfers well into the fault-tolerant era, as it requires only a limited number of arbitrary angle gates. Despite its potential, the algorithm has seen limited implementation efforts, presumably due to its abstract formulation. In this work, we provide a detailed instruction on implementing the quantum step operator for arbitrary backtracking instances. For a single controlled diffuser of a binary backtracking tree with depth n, our implementation requires only CX gates. We detail the process of constructing accept and reject oracles for Sudoku problems using our interface to quantum backtracking. The presented code is written using Qrisp, a high-level quantum programming language, making it executable on most current physical backends and simulators. Subsequently, we perform several simulator based experiments and demonstrate solving 4x4 Sudoku instances with up to 9 empty fields. This is, to the best of our knowledge, the first instance of a compilable implementation of this generality, marking a significant and exciting step forward in quantum software engineering.
Paper Structure (31 sections, 19 equations, 10 figures, 5 algorithms)

This paper contains 31 sections, 19 equations, 10 figures, 5 algorithms.

Figures (10)

  • Figure 1: Unsolved 4x4 Sudoku problem: A solution to this Sudoku with 9 empty fields is found on a simulator utilizing the Qrisp implementation of Montanaro's algorithm with 91 qubits and a circuit depth of 3968.
  • Figure 2: Visualisation of a depth 3 QuantumBacktrackingTree initialized in the state $\ket{r}$ (green).
  • Figure 3: Visualisation of a depth 3 QuantumBacktrackingTree, initialized in the state $\ket{r}$, for successive applications of the operators $R_A$ and $R_B$. The colors of the nodes (green, purple) indicate the sign of their non-zero amplitudes in the node state $\ket{x}$. Fig. \ref{['fig:TreeDepthThree_1A']}: $\ket{x}=R_A\ket{r}$. Fig. \ref{['fig:TreeDepthThree_1B']}: $\ket{x}=R_BR_A\ket{r}$. The branches originating from the rejected node [0] are not explored, as the diffuser $R_B$ acts as $-\mathbb I$ on the associated node state $\ket{x}=\ket{[0,0,0]}\ket{2}$. Fig. \ref{['fig:TreeDepthThree_2A']}: $\ket{x}=R_AR_BR_A\ket{r}$. Fig. \ref{['fig:TreeDepthThree_2B']}: $\ket{x}=(R_BR_A)^2\ket{r}$.
  • Figure 4: Visualisation of a depth 4 QuantumBacktrackingTree. Fig. \ref{['fig:before']}: The state $\ket{x}=\ket{[0,0,0,1]}\ket{3}$ is initialized. Fig. \ref{['fig:after']}: After applying psi_prep, we can observe the resulting state $\ket{\psi_x}$ as a superposition of $\ket{x}$ and its child states $\ket{y_0}=\ket{[0,0,0,1]}\ket{2}$, and $\ket{y_1}=\ket{[0,0,1,1]}\ket{2}$. Fig. \ref{['fig:cXXYYswap']}: The resulting quantum circuit applied by psi_prep. First the height $\ket{\texttt{h}}=\ket{3}$ and $\ket{b}=\ket{\texttt{branch\_qa}}=\ket{[0,0,0,1]}$ are initialized. Then, two controlled $\mathrm{XX+YY}$ gates (with $\beta=\pi/2$) are applied to maneuver the position of bit $1$ into a superposition of $\ket{3}\rightarrow\ket{3}+\ket{2}$. It is worth mentioning that one should pay attention to the knob of the controlled gate - the circle denotes that, contrary to a regular controlled gate, this one activates if the control qubit is in state $\ket{0}$. Lastly, two controlled Hadamard gates are applied in order to set up the superposition in $\texttt{branch\_qa}$.
  • Figure 5: Examples for four of the five different situations for a quantum-quantum comparison that can appear. The first and second column represent the state of the node (h is one-hot encoded). The path (from the root) is therefore [3,0,3]. The third column indicates on which qubit the comparison evaluation is controlled and the final column indicates which operands participate in the comparison. Note that the control qubit is always at the index of the lower operand. Fig. \ref{['fig:tablea']}: Both operands are already assigned but not recently. The comparison has to yield False because otherwise the algorithm would have previously taken a path that is not compliant with the rules of Sudoku. Fig. \ref{['fig:tableb']}: Both operands are assigned and one of them recently. The comparison returns True because both q_assignments entries are in the $\ket{3}$ state. Since one of the operands has been recently assigned, the control qubit is active in this situation. Therefore the comparison will be evaluated and the result is True. Fig. \ref{['fig:tablec']}: One of the two operands is assigned and the other one is not assigned. The comparison would yield true, because both entries of q_assignments are in the $\ket{0}$ state. However the comparison is controlled on a qubit of h that is not in the $\ket{1}$ state. Therefore the comparison result is False. Fig. \ref{['fig:tabled']}: The comparison would yield True but only because both operands are not assigned yet and therefore carry the value 0. The result of the controlled comparison is still False because the control qubit h[0] is in the $\ket{0}$ state.
  • ...and 5 more figures