Getting Started with Quantum Computing Practically or ”How does Quantum look like?”

Dr. Alina Nizamutdinova

Starting with Quantum Computations

In the previous article we introduced quantum computing and where to start an exploration of the quantum world. In this article, we will give a short overview how to start practically. We will first give an introduction how to approach the design of quantum experiments. Then we will proceed with the overview of programming libraries. At the very end we will give an example of “Hello World” of quantum computing using two different Python packages.

Designing Quantum experiments

Quantum experiment process

All quantum experiments follow the same path. First, you encode your numerical data to quantum system. In the second step you design a quantum circuit with quantum gates taking advantages of quantum world properties. The circuit is then being executed (often multiple times). At the end you perform the measurement (collapse the wave function) and, if needed, repeat the procedure/redesign you circuit.

Libraries to work with Quantum Computation

Quantum frameworks

Imagine, you formulated quantum experiments: you have your input parameters, and you know which gates in which order you want to apply to which qubits and which qubits you want to measure at the end. Now it’s time to get your hands dirty and program/implement your experiment. There are several frameworks which will help you to do that on the high abstract level avoiding coding wave or laser pulses but rather specifying operational steps. Many of the frameworks provide quantum simulator as a backend so you can experiment safely on your laptop before renting quantum computing as a service in Cloud.

In the picture above we put most popular examples of open-source quantum computing libraries. As you might see, most of them are written in Python (good news for data scientists!), although you can start with QDK (Quantum Development Kit) if you are C-native. There are also some specific libraries aiming to close the gap between machine learning and quantum computing, e. g. Pennylane or Tensorflow Quantum.

Implementing “Hello Word” of Quantum Computing in Qiskit and Cirq

Ok, let’s get our hands dirty and do “Hello Word” experiments! In the snippets of code below we will be inverting the state of a qubit using X-gate (X-gate is similar to NOT gate in traditional computing). As you see, both Qiskit and Cirq are very intuitive and have similarities in defining a circuit, applying the gates and measuring the results. In both cases we used quantum simulator as a backend.

Quantum X-Gate effect visualization

Qiskit implementation:

import qiskit

# Initialize quantum circuit with one quantum and one classical bit
circ = qiskit.QuantumCircuit(1,1)

# Add "not" operator
circ.x(0)
# add measurement on the qubit
circ.measure(0,0)
# draw the circuit
circ.draw('mpl')

# get simulator backend to run
simulator = qiskit.Aer.get_backend('qasm_simulator')

# execute circuit with the simulator and save the results
result = qiskit.execute(
    circ,
    backend=simulator
).result()
Qiskit circuit visualization output

Cirq implementation:

import cirq

# Initialize quantum circuit with one quantum and one classical bit
qubit = cirq.GridQubit(0,0)

# add “not” operator and measurement
circuit = cirq.Circuit(
    cirq.X(qubit),
    cirq.measure(qubit, key='m')
)

# draw the circuit
print(circuit)

 
# Get simulator backend to run
simulator = cirq.Simulator()


# Execute the circuit with the simulator and save the results
result = simulator.run(circuit)
Cirq cirquit visualization output

Conclusion

I hope you now have an idea how quantum experiments are designed and performed! By using standard program languages, we can design circuits and experiment on quantum simulators locally. By using existing Cloud platforms and SDK (e. G. Braket von AWS) we can implement quantum solutions using quantum computers as a service. If you are a data scientist or developer, you might see some similarities in approaching computational problems. We hope, we motivated you a bit more to start your journey in quantum computing. We at Ginkgo love cutting edge-technologies and challenging problems. Feel free to connect!

Comments are closed.