Thursday, August 18, 2022

My First Quantum Computer Program

I ran my first program on a quantum computer, today.

I've run programs on quantum computer simulators in the past, but today was the first time I ran a program on an actual quantum computer. It wasn't anything special – my program simply simulated a coin flip. I guess that's the Hello World equivalent on a quantum computer.

About a year and a half ago, I gave a presentation on quantum computing, which has always fascinated me. However, quantum computing is a lot like nuclear fusion or bitcoin in that it's not yet practical. We can see that these technologies are real and feasible, but they'll require some more engineering, both technically and socially, for them to be in widespread use.

Currently, quantum computers are at the stage that personal computers were in the early 1970s. The design and engineering involves circuits. Next step will be programs and then practical applications.

What I Did

Today's program emulated a coin flip by passing a qubit through a Hadamard gate which puts the qubit into a superposition state. A Hadamard gate takes a qubit as input and its output has a seemingly random 50/50 chance of being |0> or |1> when measured. But what's fascinating about a Hadamard gate is that, if you take the output of from a Hadamard gate and pass it through another Hadamard gate then the qubit will always return to its original state.

My code snippet: Simulating the flip of a coin on an actual quantum computer

How I Did It

Like a true script kiddie, I followed a YouTube tutorial. I literally stopped the video when Toby showed her code, took a screen shot, imported the screen shot into the Apple Photos app, and then I copied and pasted the code from the photo into my web based text editor on IBM's Quantum Lab. The code I wrote was in Python utilizing the Qiskit SDK and it was free to run on IBM's system; a bargain at twice the price.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.