# Advantage of density matrix over vector to form quantum kernel

In Maria Schuld, Supervised quantum machine learning models are kernel methods, Section III.A, on page 6, the third paragraph from the bottom states

While from a quantum physics perspective it seems natural – and has been done predominantly in the early literature – to think of $$x \rightarrow |\phi(x)\rangle$$ as the feature map that links quantum computing to kernel methods, we will see below that quantum models are not linear in the Hilbert space of the quantum system [5], which means that the apparatus of kernel theory does not apply elegantly. Instead, I will define $$x\rightarrow\rho(x)$$ as the feature map and call it the data-encoding feature map.

She does not specify what $$\rho(x)$$. Presumably it is $$\rho(x):=U(x)\rho U^\dagger(x)=\sum_k p_k U(x)|\psi_k\rangle\langle \psi_k|U^\dagger(x)$$.

I failed to find the place "below" where "we will see" "that quantum models are not linear in the Hilbert space of the quantum system". This leads to the quantum kernel being defined in Definition 2 not as $$\kappa(x,x'):=\langle \phi(x)|\phi(x')\rangle \tag1\label1$$ but rather $$\kappa(x,x'):=\text{tr}[\rho(x)|\rho(x')]=\big|\langle\phi(x')|\phi(x)\rangle\big|^2. \tag2\label2$$

What is the advantage of Equation $$\eqref2$$ over Equation $$\eqref1$$ she is talking about? One reason I can think of is $$\big|\langle\phi(x')|\phi(x)\rangle\big|^2$$ is a probability that can be measured while $$\langle\phi(x')|\phi(x)\rangle$$ has a phase that is not measurable. Is this it?

Comparing the ket feature map vs. the density matrix feature map is sometimes subtle. I have provided some commentary on the arguments that I have seen on this point, but the basic takeaway is that Eq. (1) is not physically observable and so we are mostly interested in Eq. (2), even though both definitions (mathematically) valid kernels.

### Defining the two kernels

For generality, we consider a feature map generically via $$\phi: \mathcal{X} \rightarrow \mathcal{H}$$ where $$\mathcal{H}$$ is some Hilbert space imbued with some inner product. Then, fixing a $$d$$-dimensional unitary $$U$$ gives rise to two different feature maps$$^1$$ in two different spaces: \begin{align} \phi_{ket} &: x\rightarrow U(x)|0\rangle = |\psi(x)\rangle \tag{1} \\ \phi_{\rho} &: x \rightarrow U(x)|0\rangle \langle 0 | U^\dagger(x) = \rho(x). \tag{2} \end{align} Both $$\phi_{\rho}(x)$$ and $$\phi_{ket}$$ live in a Hilbert space - a cone in $$\mathbb{C}^{d\times d}$$ (with Hilbert-Schmidt inner product $$\langle A, B\rangle_{HS} = \text{Tr}(A^\dagger B)$$) and on a complex sphere $$S^{2d-1}$$ with the standard $$\ell_2$$ inner product, respectively. Using the respective inner products of each feature map, we define the corresponding functions, \begin{align} k_{ket}(x, x') &= \langle \phi_{ket}(x), \phi_{ket}(x')\rangle = \langle \psi(x)|\psi(x')\rangle \tag{3} \\ k_{\rho}(x, x') &= \langle \phi_{\rho}(x), \phi_{\rho}(x')\rangle = \langle \rho(x), \rho(x')\rangle_{HS}. \tag{4} \end{align}

Furthermore Moore–Aronszajn tells us that these are both valid (symmetric, positive semidefinite) kernel functions. With this, we can consider different arguments comparing Eqs. (1) and (2).

#### 1. $$k_{ket}$$ cannot be physically estimated

The most straightforward argument is that $$k_{ket}$$ just isn't physically observable. As you mention, there's a global phase associated with $$\langle \psi (x) | \psi(x')\rangle$$ but this cannot be physically observed (e.g. this question).

#### 2. $$k_\rho$$ corresponds to a physical observable

One of the authors of (Huang, 2020) relayed this argument to me about a universality property of $$k_\rho$$ (see also Appendix C therein). Suppose we use $$k_\rho$$ and write down an optimization problem for the corresponding kernel classifier. Then this optimizer is also a solution to the optimization problem associated with a corresponding "quantum neural network". This is explained well in the appendix so you should read it there, but the conclusion is that a classifier using $$k_\rho$$ naturally associated with a model that uses an observable to learn a halfspace classifier for $$\{ \rho(x_i)\}$$. A similar argument is implied by (Kübler, 2021) and they also use properties of the "non-physical kernel" $$k_{ket}$$ in their proofs which is kind of neat - $$k_{ket}$$ can be a useful mathematical tool!

#### 3. Hyperplanes don't make sense for $$\phi_{ket}$$ feature map

To me this is one of the less compelling arguments I have seen, though I might be misinterpreting it. Around page 12 of the arXiv version, (Havlicek, 2018) makes an argument that $$\phi_\rho$$ is the correct feature map, stating

The equivalence of states up to a global phase would make it impossible to find a separating hyperplane, since both $$|\psi\rangle$$ and $$-|\psi\rangle$$ give rise to the same physical state but can lie on either side of a separating plane.

I don't fully grasp this argument. My best interpretation is, if we say $$|\mu\rangle \in \mathbb{C}^d$$ (no normalization constraint!) is a "hyperplane" normal, and if we treat $$|\phi\rangle := |\psi\rangle$$ and $$|\chi\rangle := -|\psi\rangle$$ as distinct vectors (i.e. from a purely mathematical perspective), then they "can lie on either side of a separating hyperplane" in the sense that $$\langle \mu |\phi\rangle = - \langle \mu | \chi \rangle$$. But since we identify $$|\phi\rangle$$ and $$|\chi\rangle$$ with the same ray in a projective Hilbert space, then we cannot physically observe this minus sign, therefore $$k_{ket}$$ doesn't make sense.

I don't think this follows though, since as soon as we identify "states" $$|\phi\rangle$$ and $$|\chi\rangle$$ with the same ray, we get rid of the notion that two states that "lie on either side of a separating hyperplane". I think a clearer version of this argument reads something like,

$$k_{ket}$$ is a valid kernel that can be applied to learn halfspaces involving complex vectors $$\phi_{ket}$$, but once we identify vectors $$\phi_{ket}$$ with physical states via projection then these halfspaces are no longer necessarily learnable.

Such halfspaces may still be learnable, for instance if we were somehow able to restrict our feature vectors $$\{\phi_{ket}(x)\}$$ to distinct rays in the first place. In these cases, $$k_{ket}$$ is equivalent to $$|k_{ket}| = k_{\rho}^{1/2}$$ so we can still use Eq. (2).

$$^1$$ Here I only consider the two functions of the form given in Eqs. (1)-(2). Using a broader definition of quantum kernel like "some positive semi-definite function $$k: \mathcal{X} \times \mathcal{X} \rightarrow \mathbb{C}$$ where $$k(x, x')$$ is evaluated using a quantum computer" would only make things more confusing.

• Thank you very much for your detailed answer. Please give me some time to respond since I am currently need to finish some work. But your upfront conclusion confirms my second last sentence in my question.
– Hans
Nov 1, 2022 at 4:33