Qiskit
The Qiskit Software Development Kit (SDK) is developed by IBM and is the most widely adopted SDK currently with many methods and tutorials. It provides a good simulator (Qiskit-aer
) which can be executed on CPUs and GPUs. Qiskit is one of the highest performing quantum SDK for building and transpilation quantum circuits.
One noteworthy feature that Qiskit offers is Benchpress. This is an open-source tool for benchmarking quantum software which would help evaluate and compare the performance of different quantum algorithms. Benchmarking circuits gives us a sense of how well our hardware is actually working.
Getting Started
If you’re new to Qiskit, there are many great introductory resources available. One of the most well-known is IBM’s own Qiskit documentation. To get started with the quantum simulator that we provide you can follow Qiskit-aer.
Here, we’ll provide a basic introduction to help you get started and guide you through the initial steps for GWDG’s Qiskit simulator.
Below is a base example for creating and running the Qiskit-aer (CPU & GPU)
simulator:
# Import necessary libraries from Qiskit
from qiskit import QuantumCircuit
from qiskit_aer import AerSimulator # Import simulator from qiskit-aer
from qiskit.circuit.library import * # Import circuit libraries (pre-built quantum gates and circuits)
# Initialize the simulator with the 'statevector' method and specify CPU as the device
simulator = AerSimulator(method='statevector', device='CPU')
# Create a quantum circuit (for example, a 2-qubit circuit)
circuit = QuantumCircuit(2)
# Apply a Hadamard gate on the first qubit (creates superposition)
circuit.h(0)
# Apply a CNOT gate on the second qubit, controlled by the first qubit (creates entanglement)
circuit.cx(0, 1)
# Add measurement to all qubits in the circuit (collapse the quantum states)
circuit.measure_all()
# Execute the circuit on the simulator with 100 shots and a fixed random seed
# No need for transpile, we use `run` method from the simulator directly
result = simulator.run(circuit, shots=100, seed_simulator=123).result()
# Print the simulation results
print(result)
# Draw the quantum circuit (matplotlib output)
circuit.draw(output='mpl')
Code Insights:
Import the necessary dependencies. Check if you have the necessary dependencies from the supplementary modules. It can vary in terms of the need and with updates.
Define the simulator and testing method. Pay attention to the environment you’re using, and switch between GPU and CPU if needed.
Build and execute the circuit. Once you’ve selected the appropriate simulator for your purpose, you can measure the circuit, which will collapse the quantum state into classical bits.
Hint between the lines:
- Execute the circuit on the simulator with
shots=100
and a fixed random seed. There is no need for transpilation, we usesimulator.run
method from the simulator directly. The execute function has been deprecated since version 0.46.0 see notice here and it was removed in the 1.0 release.
- Execute the circuit on the simulator with
Final step: Print and visualize the results to aid in understanding the output.
Follow up on the GWDG Updates:
- Qiskit
- The version of GPU supported Qiskit provided by GWDG: 1.1.1v
- The version of only CPU supported Qiskit provided by GWDG: 1.0.2v
Key Features
Qiskit Aer provides high-performance simulators for testing and experimenting with quantum algorithms, eliminating the need for real quantum hardware. It offers various tools for simulating quantum circuits, including statevector simulation, unitary matrix extraction, noise modeling, and error mitigation.
Fundamental Circuit Execution: Qiskit Aer allows for quick and precise modeling of quantum circuits. Using the
qasm_simulator
, individuals are able to replicate the performance of quantum gates and receive outcomes from measurements, similar to the scenario where the circuit had operated on real quantum equipment.Statevector Simulation: The
statevector_simulator
enables monitoring of the complete quantum state of your circuit at any time, offering understanding of qubits’ superposition and entanglement prior to measurement. Understanding the development of quantum algorithms at the state level is extremely valuable.Unitary Simulation: The
unitary_simulator
provides a method for individuals interested in examining the entire unitary transformation implemented by a quantum circuit to obtain the circuit’s matrix representation. This is beneficial for verifying quantum gate operations and confirming that the circuit is accurately created.Quantum Noise Simulation: Quantum noise is a crucial part of practical quantum computing. Using Qiskit Aer, you have the ability to simulate noisy quantum circuits by incorporating noise models tailored to custom or actual devices. This aids in grasping the impact of mistakes on quantum calculations and readies algorithms for real-world use.
Quantum Error Mitigation: Qiskit Aer also offers ways of reducing noise errors in quantum calculations. By utilizing methods like measurement error mitigation, you can enhance the precision of noisy simulations and achieve a closer approximation to results obtained from ideal quantum hardware.
Supplementary Modules
The following functions and libraries can be implemented in the latest version of Qiskit (v1.2.4), which can be also found on the IBM Qiskit. The ability of Qiskit is expanding day by day, and some of the important functions are as following:
Command | Description |
---|---|
SparsePauliOp(Observable_labels=["IZ","XX"]) | Creates two-qubit Pauli operators (‘XX’ = X⊗X ). |
mcx_gate = MCXGate(QubitNumber) | Imports a multi-controlled-X gate. |
two_local = TwoLocal(3, 'rx', 'cz') | Alternates layers of single-qubit rotation gates with layers of multi entangling gates. |
feature_map = ZZFeatureMap(feature_dimension=len(features)) | Sets each number in the data as a rotation angle in a parametrized circuit. |
evolution = PauliEvolutionGate(hamiltonian, time=1) | Simulates a quantum state evolving in time. |
CCXGate(*args[, _force_mutable]) | CCX gate, also known as Toffoli gate. |
CHGate(*args[, _force_mutable]) | Controlled-Hadamard gate. |
CPhaseGate(theta[, label, ctrl_state, ...]) | Controlled-Phase gate. |
SwapGate(*args[, _force_mutable]) | The SWAP gate. |
Diagonal(diag) | Diagonal circuit. |
UnitaryGate(data[, label, check_input, ...]) | Class quantum gates specified by a unitary matrix. |
UCPauliRotGate(angle_list, rot_axis) | Uniformly controlled Pauli rotations. |
The Qiskit community of IBM can be the most active one in terms of the updates and also in content production, more detailed module overview can be found on Qiskit.