Put on your Avengers Quantum suit and let's spin some atoms !!
Edited Royalty free stock photos

Put on your Avengers Quantum suit and let's spin some atoms !!

Atos publicly released its Quantum Learning Machine simulator and like many colleagues, I did my bit by announcing on my Linkedin, after all its a proud moment for us and especially me where I have a deep curiosity about quantum realm, its spookiness, and the fact that we absolutely don't know anything about how it works. I made a note on my desk to try it sometime, its publicly available so why not, fast forward a few weeks from that point till a Friday evening, and am looking forward to the weekend, just as I was ready to sign off I see a sticky pad peeking at me that read "Try myQLM", with the new inspiration I jumped on the website and clicked install to soon realize how hands off I may have gotten, until a couple of years ago I used to love to code for fun, but this appeared alien to me, Quantum programming was nothing like I have ever experienced... 30 minutes into it and I was ready to walk away, just when I saw this neat little link on our website that pulled me right back by offering me a ready to use cloud test environment.

To be upfront, Math was never my favorite subject and from what I can gather, the current iteration of Quantum programming concepts appears to be math-heavy, there is a reasonable amount of literature available but if you are like me after reading the first few lines you will move on. With the amazing toolkit and tutorials at Atos myQLM I can probably say now that I know a little bit about Quantum Computing and more specifically about Qbits, Circuits, a couple of gates, simulator, backend, result, visualization, interoperability and also got acquainted to other popular quantum SDKs like Qiskit and OpenQASM and a few more that I have trouble spelling, the real ah-ha moment was when I was able to execute this very simple program on Atos Quantum Simulator and also on actual Quantum Machine at IBM (yes a real Quantum computer).

For starters, this "Hello World" is not the foo bar Hello World's we see, this is rather a very elementary quantum manipulation using python and the Atos myQLM and Qiskit. Let's understand the key items that I think are closest to traditional programming.

If you get confused reading the below, don't worry and read it as a general reference, the actual code is relatively easy.

Qbit - Quantum bit is a quantum version of our classical binary bits with a big difference that a traditional bit can exist either as 0 or 1 while a Qbit can be both (don't ask why please, even Einstein didn't know this spookiness), a Qbit is the fundamental unit in quantum computation. Best to think of them as Atoms, protons etc.

Circuit - similar to physical circuits where routines and data can be stored, a Circuit is a mechanism where various computational routines and quantum data can be compartmentalized.

Gates - these are quantum logical operators that operate on Qbits, I believe I can naively compare them to the AND, OR logical gates in traditional computing platforms however Quantum gates are quite complex, I barely understood the "H" (Hadamard) gate and the CNOT gate. H gates does a 90-degree rotation to a state of the Qbit and the CNOT gates can perform entanglement or disentanglement.

Let's look at the code now using the Atos myQLM, in this hello world, we will create a program, qbits, circuit, gates and execute it on Atos myQLM simulator.

#import required libs 
from qat.lang.AQASM import Program, H, CNOT
from qat.qpus import get_default_qpu

# Create a program
qprog = Program()
# Allocate 2 qbits
qbits = qprog.qalloc(2)
# Add a H Gate
H(qbits[0])
# entagle using CNOT
CNOT(qbits[0], qbits[1])
# Create a circuit
circuit = qprog.to_circ()
# Create a job
job = circuit.to_job() # parameters"nbshots=0" replace 0 with number of times you want the simulation to run

# Instantiate a QPU (simulator)
qpu = get_default_qpu()

# Execute
result = qpu.submit(job)
for sample in result:
    print("State %s: probability %s" % (sample.state, sample.probability))        

The above code will run on the cloud test environment and once executed it will spit out a state of the entangled Qbits.

You can run a similar program on an actual IBM Quantum computer (free to create an account and use) and there are few ways to do this and I didn't find them difficult

  1. Atos myQLM interoperates with Qiskit SDK that allows pushing this job to IBM Quantum experience.
  2. Run Qiskit standalone and execute on IBM Quantum computer.
  3. Code the above (using either QISKIT or QASM SDK ) directly on IBM Quantum console.

At the time of writing this, I am can write code in Atos myQLM to interop with IBM Quantum computer, a simpler version of this code can be found here and clicking tutorials->interoperability->interoperations->Qiskit connect to IBM Backend.

My myQLM to IBM Quantum Interop code looks like this.

from qat.interop.qiskit import BackendToQPU


# Declare your IBM token
MY_IBM_TOKEN = "YOUR IBM TOKEN, ITS FREE AND EASY TO GET GOOGLE IT"

# Wrap a Qiskit backend in a QPU, IBMQ Manila is one of the many options
qpu = BackendToQPU(token=MY_IBM_TOKEN, ibmq_backend="ibmq_manila")

# Submit a job to IBMQ
result = qpu.submit(job)

# Execute
result = qpu.submit(job)        

That's pretty much it, took me all about 6 hours to figure all this out. If you are curious what the results are, they are just the states of the Qbits represented as the number and to be honest I will have a hard time explaining it, try it and find out for yourself.

So, as I sign off from my brief yet exciting experience coding on Atos myQLM and on IBM Quantum computer, I take comfort in knowing that I started learning something new, reinforced my confidence that I still got this and in the process had the pleasure of spinning a few atoms and electrons.
Amit Sanghvi

I help architect your database and data architecture. I love automating your database related operations. Specialise in Oracle and PostgreSQL

2y

Very well written Manish. Simple and clear. Enjoyed reading it. Will chat about it offline sometime.

Amitava Paul

Healthcare Consulting | Project & Program Management | SAFe Agilist | Learner | Listener

2y

Very nicely articulated, You have surely raised my interest to learn more about the topic 👍

Suresh Behera

Software Developer Expert | Entrepreneurs | AI Enthusiast | Investor

2y

Nice intro , love it.

To view or add a comment, sign in

Insights from the community

Others also viewed

Explore topics