Quantum Pathfinder: Blast Through Beginning Roadblocks & Join the Revolution! Part 1

Vidur Jannapureddy
8 min readMar 23, 2024

--

Photo by Erik Mclean on Unsplash

If you find yourself feeling like our buddy WALL-E over here when you try to get started with quantum computing, don’t worry. We have you covered.

Kick back, grab a snack, and ditch the stress! We’re about to take you on a smooth ride through the wonders of this mind-bending technology, leaving all the confusion behind. So settle in, relax, and join me as we unravel the mysteries of quantum computing together.

Smooth Beginnings with IBM Quantum

IBM Quantum: This is the hardware side of the equation. IBM is a leading company developing actual quantum computers. These machines harness the bizarre laws of quantum mechanics to solve problems impossible for even the most powerful classical computers. They offer access to their fleet of quantum computers through the cloud, allowing anyone to experiment with this revolutionary technology

Qiskit: This is the software side of things. Qiskit is an open-source software development kit(SDK) created by IBM specifically for programming quantum computers. It provides all the tools you need to design, simulate, and run quantum programs on IBM’s quantum hardware or even on classical computers as simulators. Essentially, Qiskit is your bridge to communicating with and utilizing the power of IBM’s quantum machines.

Creating a Qiskit Account

1. Visit the [IBM Quantum Experience] (https://quantum-computing.ibm.com/) website.

2. Click on “Sign Up with IBMID” to create a Qiskit account.

3. Follow the registration instructions, providing the necessary information.

4. Once registered, log in to your Qiskit account.

5. When you click on the grid in the top right corner it will open the application switcher. When you log in you are already on the platform. Click on learning to access the IBM lab and utilize Qiskit.

6. You should now be on the IBM learning page. The catalog contains a variety of tutorials and courses for you to explore at your own desire. The composer is a graphical circuit builder. The lab is what we will be using and you can use it to make quantum programs. Click on lab.

7. When you are in the lab menu, you should see the page below. There are places for you to create different files. The widget you click to import files is circled below. Click the Python 3(ipykernel) with the white circle to create a new jupyter notebook with Qiskit imports.

8. You should see the image below. What you see below is called a Jupyter Notebook. Jupyter notebooks are used by engineers and scientists in fields like Data Science, AI, Quantum Computing, Machine learning, and Scientific Computing. Each section of code is called a cell. There are multiple kinds of cells including markdown(text) and code cells. You can choose which type of cell you want by using the dropdown menu which is circled below. To run a cell, hit shift and enter at the same time.

You can also access IBM quantum in a separate jupyter environment using pip. Here are the pip functions you need to run in your terminal or a code cell.

pip install qiskit
pip install qiskit-ibm-runtime
pip install qiskit[visualization]

You should now be able to import and utilize basic qiskit packages in your code.

Demystifying the Quantum Playground: Getting Started with qBraid Lab

qBraid Lab offers a powerful and user-friendly platform for exploring the exciting world of quantum computing. Here’s a breakdown of how to navigate this innovative environment:

1. Accessing qBraid Lab

Head over to the qBraid website and create an account (or log in if you already have one).

Once logged in, locate the “Launch Lab” option on the main dashboard. This will launch the qBraid Lab environment in your web browser.

2. Environments: Your Quantum Toolkit

The heart of qBraid Lab lies in its Environments. This section provides a curated selection of pre-configured virtual environments encompassing popular quantum software packages.

Think of them as pre-built toolboxes, each containing the necessary software (like Qiskit, Cirq, TensorFlow Quantum) for specific quantum computing tasks.

Explore the list of environments and their descriptions to find the one best suited for your project.

3. Installing and Activating Environments

Found the perfect environment? Click the “Install” button to download and set it up within qBraid Lab.

Once installed, you can activate the environment to start using the included software tools. This makes it your primary workspace for coding and running your quantum programs.

4. Exploring the Lab Interface

qBraid Lab offers a familiar interface similar to Jupyter notebooks. You can create new notebooks within the chosen environment to write your quantum code.

The interface provides features like code cells, markdown cells, and code completion to streamline your workflow.

5. Connecting to Quantum Hardware (For Standard/Pro Users)

If you have a Standard or Pro subscription, qBraid Lab allows you to connect directly to IBM Quantum hardware.

This enables you to run your quantum programs on real quantum computers and witness the power firsthand! (Check qBraid’s documentation for specific instructions on hardware access.)

6. Additional Resources:

qBraid Lab offers a comprehensive documentation section with detailed guides on using environments, writing quantum code, and utilizing other functionalities.

Don’t hesitate to explore these resources for a deeper understanding.

Unveiling the Quantum Toolbox: A Look at Popular Programming Languages

While qBraid Lab simplifies the environment setup, you’ll still need to choose the right language to write your quantum programs. Here’s a breakdown of some popular options, along with example scripts and their advantages and disadvantages:

1. Qiskit (IBM)

Focus: Open-source framework specifically designed for IBM Quantum hardware.

Pros:

  • Extensive documentation and tutorials.
  • Seamless integration with IBM Quantum cloud access.
  • User-friendly interface for writing quantum circuits.

Cons:

  • Primarily focused on IBM hardware, may require adjustments for other platforms.
  • Steeper learning curve compared to some other options.

Example Script (Creating a Bell State):

from qiskit import QuantumCircuit, Aer, execute
# Create a quantum circuit with 2 qubits
qc = QuantumCircuit(2)
# Apply Hadamard gate to the first qubit
qc.h(0)
# Apply CNOT gate controlled by the first qubit on the second qubit
qc.cx(0, 1)
# Simulate the circuit
simulator = Aer.get_backend('qasm_simulator')
job = execute(qc, simulator, shots=1024)
# Get the results
result = job.result()
counts = result.get_counts(qc)
print(counts)

2. Cirq (Google)

Focus: Open-source framework designed for flexibility across various quantum hardware platforms.

Pros:

  • Supports multiple hardware backends (Google Quantum AI, Rigetti Computing, IonQ etc.).
  • Offers a lower-level, Pythonic interface for fine-grained control.

Cons:

  • Requires a deeper understanding of quantum mechanics for effective use.
  • Documentation can be less beginner-friendly compared to Qiskit.

Example Script (Implementing a Grover’s Search Algorithm):

import cirq
# Define the oracle function
def oracle(qs):
# Implement your oracle logic here, targeting specific qubits
# Create the circuit
circuit = cirq.Circuit()
circuit += cirq.H(cirq.LineQubit(0)) # Apply Hadamard to first qubit
circuit += oracle(cirq.LineQubit(0), cirq.LineQubit(1)) # Apply your oracle
circuit += cirq.H(cirq.LineQubit(0)) # Apply Hadamard again
# Run the circuit on a simulator
simulator = cirq.Simulator()
results = simulator.run(circuit, repetitions=1000)
# Analyze the results based on bit strings
# …

3. PennyLane (Xanadu)

Focus: Python library designed for hardware-agnostic quantum programming.

Pros:

  • Integrates with various classical machine learning frameworks like TensorFlow and PyTorch.
  • Enables hybrid quantum-classical computations.
  • Relatively simpler syntax for expressing quantum operations.

Cons:

  • Limited support for specific hardware backends compared to Qiskit or Cirq.
  • Focus on machine learning applications might not suit all use cases.

Example Script (Variational Quantum Eigensolver):

import pennylane as ql
# Define a quantum device (simulator in this case)
dev = ql.device("default.qubit", wires=2)
# Define the ansatz (quantum circuit)
@ql.qml.qnode(dev)
def circuit(params):
# Apply parameterized quantum gates here based on 'params'
# Define the cost function (based on the problem)
cost_fn = ql.QAOAP(my_cost_function)
# Optimize the ansatz parameters
optimizer = ql.optimize.Adam()
opt_circuit = ql.qml.optimize(cost_fn, optimizer, circuit)
# Run the optimized circuit and get results
# …

These are just a few examples, and the best choice depends on your specific needs and hardware access. Remember to consider the trade-offs between ease of use, flexibility, and hardware compatibility when selecting your quantum programming language.

The world of quantum computing is vast and ever-evolving. But with the right tools and resources, you can take your first steps into this exciting realm. qBraid Lab provides a user-friendly platform to experiment and explore, while the diverse landscape of quantum programming languages empowers you to express your ideas in code. As you delve deeper, remember that the most important ingredient is curiosity. Don’t be afraid to ask questions, experiment with different approaches, and learn from the ever-growing quantum community. The future of computing awaits, and with perseverance, you can be a part of shaping it!

This is part 1 of this series on ‘Blasting through quantum roadblocks’. You can access part 2 of the article by checking out my friend Kathie’s post right here: https://medium.com/@qrst3721/introduction-to-quantum-computing-start-your-first-project-fa42cfb86c7c

--

--