Tools and Their Functions
The tools we are using are Python, Qiskit, Jupyter Notebook, VS Code, and GitHub. So, let’s get into what these tools actually are, what their function is, and how we will be using them. Click on each tool to learn more about it.
Python
Python is the backbone of modern quantum computing. It’s a versatile, beginner-friendly programming language that allows you to write, test, and run quantum circuits using frameworks like Qiskit. Here’s a breakdown of why it matters and how it integrates with your toolkit.
Function:
Python lets you create and manipulate quantum circuits programmatically.
Provides libraries for mathematical operations, data visualization, and hardware connectivity.
Acts as the bridge between you and quantum hardware or simulators.
Integration:
Jupyter Notebook: Python runs natively in notebooks for interactive coding, visualization, and explanation.
VS Code: Python scripts can be executed in VS Code for larger projects and debugging.
GitHub: Python code can be versioned, shared, and documented to show progression over time.
Qiskit: Python is the only language Qiskit supports, so mastering it is essential for building circuits, running simulations, and accessing IBM Quantum hardware.
Key Components:
Libraries: numpy for linear algebra, matplotlib for plotting, qiskit for quantum circuits.
Variables & Functions: Store quantum states and build reusable circuits.
Loops & Conditionals: Run experiments multiple times and analyze results efficiently.
Visualization: Plot measurement outcomes, Bloch spheres, and circuit diagrams.
Qiskit
Function:
Python-based framework for quantum computing. Lets you create, simulate, and run quantum circuits on both simulators and real IBM Quantum hardware via cloud service.
Integration:
Works inside Jupyter or VS Code notebooks.
Connects to IBM Quantum Experience for real-device execution.
Key Components:
QuantumCircuit – builds circuits.
Aer – simulator backend.
execute() – runs circuits on simulators or hardware.
IBMProvider – access to real quantum devices.
Jupyter Notebook
Function:
Interactive coding environment, great for tutorials, visualization, and step-by-step exploration.
Integration:
Runs Qiskit code in a readable format with Markdown explanations.
Supports inline plotting (histograms, Bloch spheres).
Key Components:
Cells: Code cells for executing Python/Qiskit code; Markdown cells for explanations, formulas, and visuals.
Interactive Execution: Run code in chunks, modify, and see outputs immediately.
Visualization Support: Inline plots (matplotlib, Qiskit visualization tools) and Bloch spheres.
Export Options: Can export notebooks as PDFs, HTML, or slides for sharing.
Extensions: Tools like nbextensions or qiskit.visualization enhance workflow and readability.
VS Code
Function:
Full-featured code editor, great for managing larger projects, debugging, and version control.
Integration:
Can run Jupyter notebooks directly.
Python scripts for Qiskit experiments.
GitHub integration for versioning and sharing code.
Key Components:
Integrated Terminal: Run Python scripts or Git commands directly.
Debugger: Step through code to find errors or understand execution flow.
Extensions: Python, Jupyter, GitHub, and Qiskit extensions for seamless workflow.
Workspace Management: Manage multiple notebooks, scripts, and projects efficiently.
Git Integration: Stage, commit, and push changes without leaving VS Code.
GitHub
Function:
Version control and portfolio hosting. Lets you track changes, share code, and collaborate.
Integration:
Connect your VS Code project or Jupyter notebooks.
Use Git commits to document project progression.
Share your Qiskit experiments publicly to demonstrate your skills.
Key Components:
Repositories: Organize projects with folders, scripts, notebooks, and documentation.
Commits & History: Track changes and maintain version control.
Branches: Test new ideas without affecting main codebase.
Issues & Discussions: Collaborate or document project notes.
GitHub Pages: Optional, for hosting blogs or interactive demos.
Qubits
What is a Qubit?
A qubit is the quantum version of a classical bit.
Unlike a classical bit, which is always 0 or 1, a qubit can exist in a superposition of states. It can also become entangled with other qubits, and when measured, it collapses into a definite classical state.
Superposition
Qubits can represent multiple states simultaneously. It lets quantum computers explore many possibilities simultaneously. Imagine a light switch that’s both on and off until you check it.
Functional programming application:
Apply a Hadamard (H) gate in Qiskit and measure outcomes. The result will vary between 0 and 1.
Entanglement
Multiple qubits can become correlated such that the state of one affects the other. This enables quantum systems to coordinate information in ways classical computers can’t. It’s instantaneous. Imagine two perfectly synchronized dice. When one rolls, the other always matches.
Functional programming application:
Create a Bell state in Qiskit and measure both qubits. They’ll always match.
Measurement
Observing a qubit forces it into a classical state (0 or 1). This is how we extract usable results from a quantum computer. Looking at Schrödinger’s cat: It’s either alive or dead once you open the box.
Bloch Sphere
A visual tool to understand qubit states in 3D space. This will help you understand how gates affect qubits and visualize superposition. Think of a globe with a north (0) and south (1) pole. Anywhere in-between those points is an ‘in-between’ state.
Functional programming application:
Use Qiskit’s visualization tools to plot your qubit before and after applying a gate.
Quantum States
What is a quantum state?
A quantum state is simply the description of what a quantum system looks like ‘right now’. A classical system is what we are traditionally used to dealing with, where 0 is false and 1 is true in binary. Think of a quantum state as the system’s condition before it is measured, existing in a state of flux. Once it is measured, it is forced into a definite classical state of 1s and 0s. We’ll next dive into state vectors, probability amplitudes, and measurement outcomes.
Note that the quantum states in an emulation environment like Qiskit are different than live quantum computing in the real world. This is because in live quantum computing, it is not possible to view the state of a qubit without collapsing it. It is also not possible to manually set probabilities. In live exercises, we simply get a distribution of results. Remember, we can only control circuit design and gate choice in live quantum computing. It’s important to keep this in mind when experimenting.
State Vectors
Think of a state vector as the internal data structure that tracks what is currently happening with your qubits. Compare this to binary, where we know a 1 is true and a 0 is false from beginning to end. After you build and run a quantum circuit, you can call the state vector in programming to see what state each qubit is in before it is measured. State vectors are the act of peeking under the hood, without actively measuring qubits and forcing their superposition to collapse into a 1 or a 0.
It is important to note that this is only possible in Qiskit or emulated quantum environments. It is not possible to view the state of a live qubit without causing collapse into a 1 or 0.
Probability Amplitudes
Probability amplitudes are behind the scenes numbers that tell a qubit how likely it is to end up as a 1 or a 0 once it is measured. It is not an actual probability, but gets converted into a probability when measured. The probability of observing a particular outcome is the magnitude squared of it’s amplitude.
Programming implications:
Imagine an array in programming with weights attached to them. Each array has a different weight:
qubit_state = {"0": 0.7, "1": 0.3} # weights, not final outcomes
These weights are theoretical or probabilistic in nature. They’re not fixed.
Probability amplitudes are necessary to understand when using quantum gates in programming, because different gates will distribute the probabilities differently. For example, in a Hadamard gate, the weight of probabilities will be distributed evenly between both the 1 and 0 values (i.e., .5 weight for both 1 and 0 outcome)
You can also chain gates together and this will alter the weight distribution again. This is similar to applying multiple functions to data structures in classical programming.
These weights will determine the likelihood of the value you see when the qubit is measured. With the example above, you’d have a 70% chance of seeing a 0 outcome and a 30% chance of seeing a 1 outcome when the qubit is measured.
Measurement Outcomes
When you measure a qubit, it will collapse from a quantum state into a classical result of either 1 or 0. This result is weighted by the amplitudes and probabilities that you will set up in your circuit. In other words, instead of sending an explicit instruction in programming, the result is determined by the probability distribution set by your gates. Think of it as designing a code “persona” that behaves differently depending on the probabilities defined by your circuit. In quantum emulation, we can inspect or set specific probabilities. However, this is not true on real quantum hardware.
In live quantum computing, you cannot always set or predict the outcome, but you can influence it by carefully crafting the circuit and choosing which quantum gates to use.
In the next part, we will go over more specifics of gates and how they impact probabilities and measurement outcomes. But first, we will conduct a hands-on experiment:
Project: Exploring Qubit Superposition and Measurement
Leave a Reply