Skip to content

Conversation

@andynader
Copy link

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?

  • Tutorial
  • Demo
  • How-to

@github-actions
Copy link

github-actions bot commented Oct 6, 2025

Your preview is ready 🎉!

You can view your changes here

Deployed at: 2025-10-20 21:45:50 UTC

@andynader
Copy link
Author

Hi @daniela-angulo , I checked the preview and some things did not render properly, do I need to do anything?

@daniela-angulo
Copy link
Contributor

Hi @andynader, yeah, I saw that.
Not for now, let me try to fix a few things and I'll loop you in when I have finished the demo so you can address all the suggestions and/or changes at once.
Thanks.

@daniela-angulo
Copy link
Contributor

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?
I have not yet reviewed it, but I will this week. However, I noted a few things in the PR as comments regarding two figures. We can start with these two things and then move forward to the review when I get to it.
Thank you!

@andynader
Copy link
Author

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?

@daniela-angulo
Copy link
Contributor

Yes, I think we could probably do that.
Have you started discussing the graphics with Ben?
Thanks @andynader !

@andynader
Copy link
Author

Yes, I think we could probably do that. Have you started discussing the graphics with Ben? Thanks @andynader !

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?

@andynader
Copy link
Author

I will also work on making the figures smaller this weekend and push the changes

@daniela-angulo
Copy link
Contributor

Hi!
yes, please. You can contact Ben over email and he'll help us with that.
Thank you.
I will review the demo from a more content/science perspective next week.

Copy link
Contributor

@daniela-angulo daniela-angulo left a 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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
across any kernel-based method
across any kernel-based method.

Demonstration setup:
--------------------

1. **Dataset**: Synthetic two-moons data generated with ``scikit-learn``
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
1. **Dataset**: Synthetic two-moons data generated with ``scikit-learn``
1. **Dataset**: Synthetic two-moons data generated with ``scikit-learn``.

Comment on lines +237 to +255
# :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)
Copy link
Contributor

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:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# 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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# 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

Copy link
Contributor

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
Copy link
Contributor

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`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# 🧠 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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants