I am a professor emeritus of CS at Kanagawa Institute of Technology, Japan. Originally my specialty was parallel and distributed systems. My current interests include machine learning, natural language processing, creating mobile apps with MIT App Inventor, and quantum computing. In the web version of this blog, clicking the icon on the right (a plastic sphere) will take you to the "List of Quantum Computing Articles". - Fujio Yamamoto (for e-mail, add "@ieee.org" after "yamamotof")
2024年8月27日火曜日
Redesigned Mobile Quantum Circuit Simulators (V2)
2024年8月19日月曜日
Redesigned Mobile Quantum Circuit Simulators
Abstract: I have developed several quantum circuit simulator apps that run on mobile phones. Although my apps are not as good as well-known simulators such as Qiskit and Quirk, they are suitable for taking your mobile phone out of your pocket and learning the basics of quantum computing anytime, anywhere. No Internet connection is required. Until now, my simulators were for up to 3 qubits, but this time, I have made major design changes to enable it to handle any n qubits. (However, due to resource constraints on mobile phones, in reality, I am mainly assuming use of about 6 qubits.) These make it possible to run a large number of examples that are published in general quantum computing textbooks. These apps are currently unreleased, but I will provide them (.apk files for Android) immediately to anyone who is willing to try. Please contact me. (You can find my email address in the header of my blog.)
The app URL has changed, please contact me if you need it.
(▶️Please see the revised version V2 information here)
🔴Check out the introductory video for this simulator here!
🔴Two types of mobile phone apps developed
The following two quantum circuit simulators were developed.
(1) Simulator for n-qubit (app name: nQsim_9)
A new circuit description format similar to IBM's QASM was introduced. I also considered a GUI method in which qubits and quantum gates are set with buttons, but due to the limitations of mobile phone screen size and operability, I ultimately decided on a method in which quantum circuits are described in text. Fortunately, the description of quantum gates is very simple, and the number of qubits required for general learning is not very large, so I thought that there would be no major problems with this method. Rather, this method of creating a quantum circuit diagram by hand and writing (typing) quantum gates while looking at it would be more likely to deepen understanding.
(2) Simulator for one quantum bit (app name: sQ_b2)
This is an app specialized for one quantum bit, and the quantum state when various quantum gates are applied is graphically displayed on a disk-like image. The quantum bit state is also displayed on the Bloch sphere, which is useful for deepening understanding.
How to use the n-qubit simulator
(1) Overview of the simulator
See Fig.1 for an overview of this app. The user describes the quantum circuit in text format. For concrete examples, please refer to the built-in examples.
- Specify the number of qubits to be used and the quantum bits to be measured.
- Available quantum gates are I, X, Y, Z, H, T, S, √X , P, RX, RY, RZ, and SWAP.
(CNOT should be represented by X with control.) - (The next version will also include the following gates: T_dagger, S_dagger, QFT, IQFT)
- The phase (angle) should be given in radians. The number π is specified as "pi".
- Any quantum gate can be equipped with necessary number of control bits. (However, SWAP is excluded because it has a different description format.)
[example] X, 2, [0, 1] <- apply X to q2 controlled by q0 and q1
[example] RY(pi/3), 2 <- apply RY with angle π/3 to q2
[example] SWAP, state, 2, 3 <- swap q2 and q3 - Only one quantum gate can be specified per line. (->In the next version, this restriction will likely be removed.)
- Lines containing "//" are considered comment lines.
- Blank lines are not allowed. (->In the next version, this restriction will likely be removed.)
- Measurements are automatically performed on the specified qubits at the end. (If you do not want to perform a measurement, set the list of qubits to be measured to a null list.)
- Newly added quantum gates based on measurement results, can also be executed.
- The described quantum circuits can be saved and retrieved. (However, the current version only supports two circuits.)
- Six simple quantum circuit examples are built in. Namely, Toffoli, GHZ, QFT, 7k%15, Grover's Algorithm, and Error correction (bit-flip).
(2) Example: Bit-Flip Error Correction
This example is an application of quantum teleportation and is considered important, so the details are shown in Fig. 2. First, click ① to import the example circuit. In this example, 5-qubit is used, and a bit-flip error occurs in quantum bit q2. When the Go button is clicked in ②, a measurement result reflecting the error, that is, (q4q3=10) is obtained. Based on this result, in ③, a new quantum gate for error correction is provided. Next, when Go After Meas. button is clicked in ④, a new quantum state shown in ⑤ is obtained. Here, the error has certainly been corrected !
In this example, the following point is worth noting: namely, since the bottom two qubits (q3 and q4) are not entangled with the top three, measurements on the bottom two qubits make them collapsed, but will leave the top three unchanged.
[Note] When you use the "Go after meas" button, do not long-click the "clear" button. Doing so will cause the current quantum state to be completely lost. To clear the circuit description area, simply click the "clear" button.
(3) Other quantum circuit examples
Five examples other than the error correction above are shown in Fig. 3 to Fig. 5 for your reference. In the Fig.3, Grover's algorithm is demonstrated. The left hand side figure (a) shows flipping the phase of the target basis |01⟩ via the oracle. Then, amplitude amplification (b) is applied, and finally we can see the answer |01⟩.
In Fig.4(a), the GHZ circuit is illustrated which gives strong entanglement. A demonstration of applying QFT (Quantum Fourier Transform) is given in Fig.4(b).Toffoli gate is applied in Fig.5(a) and SWAP gate is applied in Fig.5(b) to perform a modulo calculation.[Notice 1] In the current version, error checking is not performed on the circuit description. If any strange results are obtained, please refer to the circuit description in the above example and review it. Also, the function to import handwritten circuit diagrams displayed to the right of the circuit is not supported.
[Notice 2] By using MIT App Inventor again, I was able to achieve significant efficiency in app development. The 1-qubit version of the simulator was developed using only App Inventor. The overall control and graphical parts of the n-qubit version were also developed using App Inventor, but most of the quantum state calculations (such as unitary matrix operations with complex coefficients) were created in Javascript (about 350 lines). The WebViewer function of App Inventor allowed us to call up the Javascript program smoothly.
How to use the single-qubit simulator
This is a graphical representation of operations on a single qubit using a disk and a Bloch sphere. In Fig. 6, a quantum state is set on the Bloch sphere using two sliders (θ and φ). In Fig. 7, the quantum state is changed using various quantum gates. Small disks on the right side of the Bloch sphere show the change in state before and after the application of the quantum gate. No detailed explanation might be necessary. Please try it out for yourself !
🔴 Other apps you might be interested in
2024年8月1日木曜日
量子コンピューティングの学びについて考える
まだまだ猛暑続きだが、8月に入ってしまった。ここで、改めて量子コンピューティングの学びについて述べたい。そのきっかけは、米国のある有名高校(多分、日本の超難関高校に相当)の先生からいただいたメールである。それは、彼がある別の米国人からの紹介で、私の量子コンピューティングの学びに関するこのブログを知ったことによる。彼は次のように述べているのだが、大いに共感できる。
彼は、この高校の数理系の教員だが、量子物理学で博士号を持つという素晴らしい人物である。物理学関係の研究所での勤務経験もある。この高校での来年度に向けて、「革新的テクノロジー」というパイロットクラスを編成し、高校低学年で、最初にAIと機械学習を教え、次に量子情報を教える予定とのこと。量子に関することをできるだけ早く教え始めることは可能であり、必要であると考えているようである。一般の大人は、ずっと古典物理学的な観点の世界で生きてきたので、量子の世界に入ることにはかなり抵抗があるが、若い生徒はそうではなく、量子の概念や論理に素直に入ることができると感じると述べている。
彼は、教育におけるゲームに関する教師向けのSEPTプログラムに参加し、同僚と一緒に量子コンピューティングを教えるためのカードゲームを作成している。さらに関連アプリも作成したいとのこと。その際に私(山本)の作成したアプリを利用したり、参考にしたいとのことであった。一方、私の量子関係アプリは、振り返ってみると、造りがかなり複雑になったり、冗長であるところも多い。もっと、シンプルで扱いやすい構造にして、生徒にも親しめるアプリに改造したいと考えているところである。
これまでに作ってきたブロッホ球模型と、量子関係アプリのいくつかの画面を、改めて以下に掲載する。これを眺めならが、どのように改善すべきかを考える。厳しい暑さが過ぎた頃には目処をつけたいのだが、保証はできない... だが、この分野で著名なMITの教授から頂いた以下のコメントが大いに励みになっている。
"I greatly enjoyed reading your blog post article. Your handmade plastic Bloch sphere is very appealing, and I appreciate how you are making such a kind effort to reach a new and young audience who may someday be important to the field.", by Prof. Isaac Chuang (MIT)
my Bloch sphere my quantum apps logo |