top of page

Qiskit: Your Gateway to Learning Quantum Computing

Updated: Feb 12, 2023


Quantum computing is an emerging field that is rapidly gaining interest due to its potential to solve problems that classical computers can't. But getting started with quantum computing can be a daunting task, especially if you don't have a strong background in mathematics or physics. Fortunately, Qiskit is a user-friendly, open-source software development kit that makes it easier to learn quantum computing and develop quantum algorithms. I have been learning the system for about 60 days. My first experience with the interface was a little challenging, but once you install the system and play with it, you can begin exploring it.



What is Qiskit?


Qiskit is an open-source software development kit (SDK) from IBM that provides a set of tools for working with quantum computers. It includes a set of high-level APIs for building and running quantum circuits, a set of low-level APIs for developing quantum algorithms, and a range of tools for simulating and executing quantum circuits on real hardware. Qiskit is designed to be easy to use, with a Python-based interface that makes it accessible to a wide range of users.


How can Qiskit help with learning quantum computing?

  1. Provides a user-friendly interface: Qiskit provides a user-friendly interface that makes it easy to get started with quantum computing. Its Python-based interface is intuitive and easy to use, even for beginners. Qiskit also includes a range of examples and tutorials that can help users get started with quantum computing and learn the basics of quantum algorithms.

  2. Offers simulation tools: Qiskit provides a range of simulation tools that allow users to simulate quantum circuits on classical hardware. This makes it easier to develop and test quantum algorithms before running them on real hardware. Qiskit also includes tools for benchmarking and optimizing quantum circuits, which can help users improve the performance of their algorithms.

  3. Access to real hardware: Qiskit provides access to real quantum hardware through IBM Quantum Experience. This allows users to run their quantum circuits on actual quantum computers and see the results. This provides a hands-on experience with quantum computing and helps users understand the challenges of working with real quantum hardware.

  4. Community support: Qiskit has a large and active community of developers and users who can provide support and guidance. The Qiskit community includes a range of resources, including forums, chat rooms, and tutorials, which can help users learn and solve problems. I use windows box and below is how to install on Windows 10:

Installation of Qiskit:


  1. Install Python 3: Go to the Python website (https://www.python.org/downloads/windows/) and download the latest version of Python 3 for Windows. Run the installer and follow the prompts to complete the installation.

  2. Open a command prompt: Click on the "Start" menu, search for "Command Prompt", and click on the app to open a command prompt.

  3. Install Qiskit: In the command prompt, enter the following command to install Qiskit: pip install qiskit. This command will download and install the latest version of Qiskit, along with its dependencies.

  4. Verify the installation: To verify that Qiskit is installed correctly, enter the following command in the command prompt:

python -c "import qiskit; qiskit.IBMQ.load_account()". This command will load the IBM Quantum Experience account that is used for running circuits on IBM's quantum hardware. If there are no errors, the installation was successful.


That's it! Qiskit is now installed on your Windows 10 machine, and you can start using it to develop and run quantum circuits.


You also need a free account with IBM quantum webpage.


Follow IBM system verification process.

Get an API token and you are ready to play with the system, kick the tire and run some sample code such as building gates and run circuits on a real machine or simulators, or both.


Here is a sample code to setup gates on IBM quantum system.


This code adds all single-qubit quantum gates to a quantum circuit with one qubit and executes the circuit on a local simulator using Qiskit's Aer module. Finally, it prints the measurement outcomes of the circuit. Similar code can be used to build multi-qubit gates as well.


What is Aer Module?


According to IBM documentation, Aer module in Qiskit is a high-performance simulator framework for quantum circuits. It allows for simulation of quantum circuits on classical hardware, providing a way to verify the behavior and correctness of quantum algorithms before running them on actual quantum hardware.


Aer provides a range of simulators that can simulate different types of quantum systems, including qubits, CV systems, and quantum-classical hybrid systems. These simulators can be used to run large-scale simulations, including noisy simulations that mimic the behavior of real-world quantum systems.


The Aer module also includes a set of tools for optimizing and benchmarking quantum circuits, as well as for developing new quantum algorithms and protocols.


Overall, the Aer module in Qiskit is an essential tool for quantum software developers, providing a range of powerful simulators and tools that enable the development and testing of quantum algorithms and protocols. Here is the explanation of each segment.


This line imports the necessary modules required to run the Grover algorithm using Qiskit. The QuantumCircuit module is used to create the quantum circuit, Aer is used to run the simulation of the quantum circuit, and plot_histogram is used to visualize the results of the simulation.


This line defines the number of qubits in the circuit (in this case, 3) and the target value we want to search for in the unsorted database (in this case, '010').


This line creates a new quantum circuit with n qubits and n classical bits.



This line applies the Hadamard gate to all qubits, which puts them in a superposition of all possible states.


This code defines an oracle function for the target value '010'. The oracle function is a quantum circuit that applies a phase flip to the target value. This code creates the oracle function by first initializing a new quantum circuit oracle, then applies an X gate to any qubit with a value of 0 in the target value, followed by a Controlled-Z gate between the first and second qubits, then applies another X gate to the qubits with a value of 0 in the target value. Finally, the oracle circuit is appended to the main grover_circuit by using the append method.


This code applies the diffuser operator to the circuit, which amplifies the amplitude of the target state. The diffuser operator is a combination of the Hadamard gate, the Pauli X gate, the controlled-not (CX) gate, and the Hadamard gate. This code applies the diffuser operator to the circuit by applying the Hadamard gate to all qubits, followed by the X gate to all qubits, then the Hadamard gate to the last qubit.

Let's talk about diffuser operator. The Diffuser operator is a quantum circuit that is used in the Grover's algorithm to amplify the amplitude of the target state, which is the state that contains the solution to the search problem. It is essentially a reflection about the mean amplitude of all states that are not the target state.

The Diffuser operator is composed of a sequence of quantum gates, which include the Hadamard gate, Pauli X gate, controlled-not (CX) gate, and another Hadamard gate. The circuit acts on all qubits, and the number of gates depends on the number of qubits in the circuit.

The action of the Diffuser operator is to amplify the amplitude of the target state while decreasing the amplitude of all other states. Repeated applications of the Diffuser operator, together with the oracle operator, allows the algorithm to converge to the target state with high probability.


This code measures the qubits in the circuit and stores the result in the classical bits.


This code sets the backend to be the QASM simulator, runs the grover_circuit on the simulator with 1024 shots, and retrieves the result counts using the get_counts() method.


This code prints the result counts to the console and then displays a histogram of the counts using the plot_histogram() method.

The histogram plot would show the probability of measuring each state after running the Grover's algorithm. Since the target state in this case is the state 110, the probability of measuring this state should be higher than the probabilities of measuring all other states.

Assuming the Grover's algorithm is implemented correctly, we would expect to see a histogram with a high probability for measuring the state 110, and low probabilities for measuring all other states.



The exact shape of the histogram would depend on the noise and errors present in the quantum hardware, as well as the number of shots used in the simulation. With more shots, the histogram would converge to the expected probabilities of measuring each state.

17 views

Recent Posts

See All

Comments


bottom of page