-
Couldn't load subscription status.
- Fork 213
Add quantum kernel pre-screening demo based on Huang et al. #1569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add quantum kernel pre-screening demo based on Huang et al. #1569
Conversation
this is for validation and make a preview
Your preview is ready 🎉!You can view your changes here
|
|
Hi @daniela-angulo , I checked the preview and some things did not render properly, do I need to do anything? |
|
Hi @andynader, yeah, I saw that. |
|
Hi @andynader, I think I addressed all the formatting issues. Could you verify that for me? Is the demo looking the way it is intended to? |
|
Hi Daniela, thank you for your hard work. I changed the code as you recommended; should we also make some figures such as the scatter plot and embedding circuit plots smaller or do you think they're good? |
|
Yes, I think we could probably do that. |
Hi Daniela, yes he told me you have an in house graphic designer who can make them, how should I move forward? Should I contact Ben? |
|
I will also work on making the figures smaller this weekend and push the changes |
|
Hi! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Such a cool demo, the main idea is clearly well presented.
I only added a few comments. Thanks!
| @@ -0,0 +1,773 @@ | |||
| r"""Is a Quantum Kernel Worth Exploring? A ‘:math:`g`-first’ Reality Check | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this your preferred title or the on in the metadata file? they are different
| From a practitioner’s perspective, such a **pre-screening test** is invaluable: it lets us rule out | ||
| quantum kernels that don’t offer any potential quantum advantage right from the start. | ||
|
|
||
| Huang *et al.* (https://arxiv.org/abs/2011.01938) introduced exactly this test. Their proposed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should have a reference section at the end, before the appendix. It doesn't matter if all we cite is the same article several times.
You can take a look at other demos in the open PRs in the repo #1577
|
|
||
| 3. **Our approach**: Calculate :math:`g` values between the classical kernel and each quantum | ||
| kernel—giving us an immediate assessment of which quantum approaches might be worth pursuing | ||
| across any kernel-based method |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| across any kernel-based method | |
| across any kernel-based method. |
| Demonstration setup: | ||
| -------------------- | ||
|
|
||
| 1. **Dataset**: Synthetic two-moons data generated with ``scikit-learn`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 1. **Dataset**: Synthetic two-moons data generated with ``scikit-learn`` | |
| 1. **Dataset**: Synthetic two-moons data generated with ``scikit-learn``. |
| # :math:`K_{\text{RBF}}` obtained from: | ||
| # | ||
| # .. math:: k_{\text{RBF}}(x, x') = \exp(-\gamma \|x - x'\|^2) | ||
| # | ||
| # :math:`K_{\text{QK-E1}}` obtained from: | ||
| # | ||
| # .. math:: k_{\text{QK-E1}}(x, x') = |\langle \psi_{\text{E1}}(x) \mid \psi_{\text{E1}}(x') \rangle|^2 | ||
| # | ||
| # :math:`K_{\text{QK-E2}}` obtained from: | ||
| # | ||
| # .. math:: k_{\text{QK-E2}}(x, x') = |\langle \psi_{\text{E2}}(x) \mid \psi_{\text{E2}}(x') \rangle|^2 | ||
| # | ||
| # :math:`K_{\text{PQK-E1}}` obtained from: | ||
| # | ||
| # .. math:: k_{\text{PQK-E1}}(x, x') = \exp\left( -\gamma \|v_{\text{E1}}(x) - v_{\text{E1}}(x')\|^2 \right) | ||
| # | ||
| # :math:`K_{\text{PQK-E2}}` obtained from: | ||
| # | ||
| # .. math:: k_{\text{PQK-E2}}(x, x') = \exp\left( -\gamma \|v_{\text{E2}}(x) - v_{\text{E2}}(x')\|^2 \right) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might leave this out since it is repeated from the above equations. Just to shorten up the demo a bit.
| # Each entry :math:`K_{ij}` measures how similar two data points are, and the full matrix :math:`K` | ||
| # provides a **global view** of the data in the kernel’s feature space. | ||
| # | ||
| # We compute five such matrices, one for each kernel defined above: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # We compute five such matrices, one for each kernel defined above: | |
| # We compute five such matrices, one for each kernel defined above. |
| # | ||
| # This intuition is understandable — after all, a larger :math:`g` suggests that the quantum kernel | ||
| # perceives the data very differently from a classical one. | ||
| # But as we’ll see, **a higher :math:`g` doesn’t always translate into better accuracy, it just |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # But as we’ll see, **a higher :math:`g` doesn’t always translate into better accuracy, it just | |
| # But as we’ll see, **a higher** :math:`g` **doesn’t always translate into better accuracy, it just |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the math mode doesn't render within bolded font
| # - The role of :math:`g` is *not* to predict which kernel will perform best on a given task, but | ||
| # rather to obtain a collection of kernels that have the *potential* to offer an advantage. | ||
| # | ||
| # Here, PQK-E1 and PQK-E2 both had the potential for an advantage over classical, but PQK-E2 is the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
over classical kernels or classical ...?
| # potential solution because it offers a potential for an improvement on our classification problem. | ||
| # This way, we have an important diagnostic tool to filter out bad quantum kernels for our data. | ||
| # | ||
| # 🧠 Conclusion: A practical perspective on the Geometric difference :math:`g` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # 🧠 Conclusion: A practical perspective on the Geometric difference :math:`g` | |
| # 🧠 Conclusion: A practical perspective on the Geometric difference g |
| # **Can we anticipate, before training, whether a quantum kernel might outperform a classical | ||
| # one?** | ||
| # | ||
| # To address this, we used the **geometric difference :math:`g`**, a pre-training metric introduced by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # To address this, we used the **geometric difference :math:`g`**, a pre-training metric introduced by | |
| # To address this, we used the **geometric difference** :math:`g`, a pre-training metric introduced by |
Title:
Before You Train: Pre-screening Quantum Kernels with Geometric Difference
Summary:
This demo implements the geometric difference metric (g) from Huang et al. (2021) for pre-screening quantum kernels before training. The metric quantifies how differently a quantum kernel's geometry represents data compared to a classical kernel, allowing practitioners to identify promising quantum approaches early and avoid wasting time on kernels with no potential advantage. Using synthetic two-moons data, we demonstrate how to calculate g for multiple quantum kernel variants (fidelity-based and projected) and interpret the results to guide kernel selection.
Relevant references:
Possible Drawbacks:
None
Related GitHub Issues:
None
GOALS — Why are we working on this now?
Provide practitioners with a practical tool for quantum kernel evaluation. Address a common pain point where researchers spend significant time tuning quantum kernels that fundamentally cannot outperform classical ones.
AUDIENCE — Who is this for?
QML researchers and practitioners working with quantum kernels, ML engineers exploring quantum advantages, and anyone interested in practical quantum machine learning workflows.
KEYWORDS:
quantum kernels, geometric difference, pre-screening, kernel methods, SVM, quantum machine learning, quantum advantage
Which type of documentation?