2023年11月27日月曜日

Developing the most basic app to understand Qubit state (2)

 Sometimes we need to go back to basics!

This is a major update to the previous app. The aim was to help students become familiar with the most basic elements of quantum computing using only their smartphones. The example below shows the results of (1) starting from the initial state, (2) applying the Pauli X gate, (3) then applying the Hadamard gate, and (4) applying the Hadamard gate again. 

The probability amplitude, probability, and relative phase of each basis |0>, |1> are shown numerically and on a disk. Additionally, the values of θ and φ can be set using text boxes and sliders, making it easy to understand the position of the quantum bit on the Bloch sphere.




2023年11月25日土曜日

Developing the most basic app to understand Qubit state (1)

Sometimes we need to go back to basics!

As I have already written several times, I was able to almost completely understand the basic concepts and ideas of quantum computing by reading the book [1]. Although this book does not explain the Bloch sphere or phases in detail, I would not have been able to write this article without the knowledge I gained from the book.

I developed an app to understand the state of qubits on the Bloch sphere. As shown in the figure below, set the two angular parameters θ and φ using the sliders for a single qubit on the Bloch sphere. This app uses it to calculate the probability amplitude and probability for each of the two basis (|0> and |1>). Probability and phase are also illustrated in the two disks at the top right. Note that since the global phase can be ignored, the phase of |0> is set to 0, and the phase of |1> is expressed as a relative phase to that.

As you can see, the current app specifies θ and φ manually. In the next version, it will also be possible to apply basic quantum gates (X, Y, Z, H, etc.).

References
[1] Chris Bernhardt: Quantum Computing for Everyone, The MIT Press, 2020.
https://www.chrisbernhardt.info/

2023年11月1日水曜日

Try solving 3-SAT using Qiskit's Quantum Algorithms Module

[Summary] Grover's algorithm circuit and its implementation have already been described in this article. One of the challenges was generating an oracle according to the search target. When the number of qubits was 2 or 3, it was possible to create it through trial and error, but as the number of qubits increases, it becomes difficult. Therefore, Qiskit provides the Quantum Algorithms Module[1]. This includes Grover. It consists of PhaseOracle, which generates oracles for phase inversion, and Amplification, which amplifies the probability amplitude. By using this, it becomes easy to create large-scale Grover circuits. Additionally, since PhaseOracle can generate oracles from logical expressions, it can be easily applied to 3-SAT problems, etc.[2] The implementation status will also be described.
There are various 3-SAT solvers that use classical computers. Although the content of this article cannot reach the performance of those systems, I would like to connect it to thinking about the potential possibilities for extremely large-scale problems. This is true for quantum computing in general.

Generate oracle from logical formula and amplify probability amplitude
As a simple 2-qubits example, let |10> be the state to be searched. Give a logical expression '(a&~b)' to PhaseOracle to generate an Oracle for it. Next, give the generated Oracle to AmplificationProblem, which has a probability amplitude amplification function. The generated Oracle circuit diagram is shown below. The two filled-in circles and their connections in the circuit diagram are the same as CZ (Controlled Pauli-Z).
Furthermore, draw the entire Grover circuit diagram as shown below. Here, the open circle means that the gate of the target bit is activated when the control bit is |0>.
The results of running this circuit with a simulator (ibmq_qasm) are shown below. As expected, '10' was observed with probability 1.0. In the display below, '01' is measured. This is because the order of the bits in the execution result on the actual machine is the reverse order compared to when they were given as input.

Solving 3-SAT problems using Grover's algorithm
Next, as an example, solve the 3-SAT shown below. If you give the logical formula of the problem to PhaseOracle as shown below, the corresponding Oracle will be generated. Furthermore, similar to the example above, you can create a circuit of the Grover algorithm that includes this Oracle. Below is the Oracle schematic and the entire algorithm schematic.

Next, as a backend, set up a quantum simulator or a real quantum computer, generate a Grover object, give the above Grover circuit to its method amplify, and run it. The number of repetitions was 1. In other words, iterations=1. The method for calculating the optimal value for Iterations has been clarified, and in this case (3 qubits and 3 solutions), 1 is optimal.
Finally, we show calculation results using a simulator (ibmq_qsam) and an actual quantum computer (brisbane with 127 qubits). Since a certain amount of errors occur on a real machine, the separation of solutions is a little less clear than in the case of a simulator, but it can be said that three correct solutions have been found. (Note) The bit order of the execution result is in the reverse order of the tensor product.
References
[1] James L. Weaver & Frank J. Harkins, “Qiskit Pocket Guide”, O’reilly, 2022.
[2] Grover's algorithm examples, 
https://github.com/Qiskit/qiskit-tutorials/blob/master/tutorials/algorithms/07_grover_examples.ipynb