Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 54 additions & 7 deletions docs/tutorials/projected-quantum-kernels.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,28 @@
"\n",
"*Usage estimate: 80 minutes on a Heron r3 processor (NOTE: This is an estimate only. Your runtime might vary.)*\n",
"\n",
"## Learning outcomes\n",
"\n",
"After going through this tutorial, users should understand:\n",
"- How projected quantum kernels (PQK) work and when they offer a potential quantum advantage.\n",
"- How to run a PQK on hardware using a real-world dataset.\n",
"\n",
"## Prerequisites\n",
"\n",
"We suggest that users are familiar with the following topics before going through this tutorial:\n",
"- [Quantum kernels](/learning/courses/quantum-machine-learning/quantum-kernel-methods) from the [quantum machine learning course](/learning/courses/quantum-machine-learning) in IBM Quantum® Learning\n",
"\n",
"## Background\n",
"\n",
"*Usage estimate: 80 minutes on a Heron r3 processor (NOTE: This is an estimate only. Your runtime might vary.)*\n",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate?

"\n",
"In this tutorial, we demonstrate how to run a [projected quantum kernel](https://www.nature.com/articles/s41467-021-22539-9) (PQK) with Qiskit on a real-world biological dataset, based on the paper [Enhanced Prediction of CAR T-Cell Cytotoxicity with Quantum-Kernel Methods](https://arxiv.org/abs/2507.22710) [[1]](#references).\n",
"\n",
"PQK is a method used in quantum machine learning (QML) to encode classical data into a quantum feature space and project them back into the classical domain, by using quantum computers to enhance feature selection. It involves encoding classical data into quantum states using a quantum circuit, typically through a process called feature mapping, where the data is transformed into a high-dimensional Hilbert space. The \"projected\" aspect refers to extracting classical information from the quantum states, by measuring specific observables, to construct a kernel matrix that can be used in classical kernel-based algorithms like support vector machines. This approach leverages the computational advantages of quantum systems to potentially achieve better performance on certain tasks compared to classical methods.\n",
"\n",
"This tutorial also assumes general familiarity with QML methods. For further exploration of QML, refer to the [Quantum machine learning](/learning/courses/quantum-machine-learning) course in IBM Quantum Learning."
"The main building blocks of PQKs are reduced density matrices (RDMs), obtained through projective measurements of the quantum feature map. In particular, one typically computes the single-qubit reduced density matrices (1 RDMs) for each qubit. These measured quantities are then used as inputs to a classical kernel function, such as an exponential kernel, to construct the final kernel matrix.\n",
"\n",
"PQKs offer potential advantages over standard [quantum kernels](/docs/tutorials/quantum-kernel-training), particularly for near-term quantum hardware. Standard quantum kernels typically rely on estimating global state overlaps, which become increasingly difficult to measure accurately as the number of qubits grows and are highly sensitive to noise. In contrast, PQKs use local observables such as single-qubit reduced density matrices (1 RDMs), leading to lower sampling overhead, improved robustness to hardware noise, and better scalability. By projecting quantum states onto local measurement features before applying a classical kernel function, PQKs can retain useful quantum correlations while remaining more practical for near-term devices."
]
},
{
Expand Down Expand Up @@ -95,12 +112,29 @@
"warnings.filterwarnings(\"ignore\")"
]
},
{
"cell_type": "markdown",
"id": "bd92ba56-e9eb-4841-b751-7627f47d756c",
"metadata": {},
"source": [
"## Small-scale simulator example\n",
"We omit the small-scale simulator example in this tutorial, as our primary goal is to demonstrate how projected quantum kernels can scale to larger systems and real hardware."
]
},
{
"cell_type": "markdown",
"id": "0fb8a2fa-64b4-434f-8848-e89a098ba73d",
"metadata": {},
"source": [
"## Large-scale hardware example"
]
},
{
"cell_type": "markdown",
"id": "2f8775c8-81b5-4732-8325-3f12dc96b45d",
"metadata": {},
"source": [
"## Step 1: Map classical inputs to a quantum problem"
"### Step 1: Map classical inputs to a quantum problem"
]
},
{
Expand Down Expand Up @@ -414,7 +448,7 @@
"id": "0c828dc0-9bd1-44bc-b299-303766ae3d37",
"metadata": {},
"source": [
"## Step 2: Optimize problem for quantum hardware execution"
"### Step 2: Optimize problem for quantum hardware execution"
]
},
{
Expand Down Expand Up @@ -540,7 +574,7 @@
"id": "8b27a3f8-5ee9-41b5-a430-25247545cbb9",
"metadata": {},
"source": [
"## Step 3: Execute using Qiskit primitives"
"### Step 3: Execute using Qiskit primitives"
]
},
{
Expand All @@ -549,8 +583,7 @@
"metadata": {},
"source": [
"### Measure 1-RDMs\n",
"\n",
"The main building blocks of projected quantum kernels are the reduced density matrices (RDMs), which are obtained though projective measurements of the quantum feature map. In this step, we obtain all single-qubit reduced density matrices (1-RDMs), which will later be provided into the classical exponential kernel function."
"In this step, we obtain all single-qubit reduced density matrices (1-RDMs) through projective measurements of the quantum feature map, which will later be provided into the classical exponential kernel function."
]
},
{
Expand Down Expand Up @@ -1108,7 +1141,7 @@
"id": "b87be787-8751-4093-9547-57315fa13c88",
"metadata": {},
"source": [
"## Step 4: Post-process and return result in desired classical format"
"### Step 4: Post-process and return result in desired classical format"
]
},
{
Expand Down Expand Up @@ -1461,6 +1494,20 @@
"print(f\"Quantum model complexity is {s_q:.4f}\")"
]
},
{
"cell_type": "markdown",
"id": "e29581c7-ec49-4a03-837f-ee1fe9178846",
"metadata": {},
"source": [
"## Next steps\n",
"\n",
"<Admonition type=\"tip\" title=\"Recommendations\">\n",
"If you found this work interesting, you might be interested in the following material:\n",
"- In-depth [quantum machine learning course](/learning/courses/quantum-machine-learning) from IBM Quantum Learning\n",
"- [Quantum kernel training](/docs/tutorials/quantum-kernel-training) tutorial\n",
"</Admonition>"
]
},
{
"cell_type": "markdown",
"id": "f082899c-b763-4df0-a81c-5efb3ca43451",
Expand Down
Loading