Skip to main content

Module quantum_kernel

Module quantum_kernel 

Source
Expand description

Phasor-feature classifier — the quantum kernel, deployed (wai.quantum.kernel).

A quantum kernel K(x,x') = |⟨ψ(x)|ψ(x')⟩|² is, by the Schuld–Sweke–Meyer identity, a shift-invariant kernel whose Fourier spectrum is set by the data encoding — and random Fourier features are its classical realization: draw random frequencies ω, map x ↦ φ(x) = √(2/D)·cos(ω·x + b) (a bank of phasors, the FHRR feature map), and ⟨φ(x),φ(x')⟩ ≈ K(x,x') (Rahimi–Recht). The dequantization theorems say this matches the quantum kernel whenever the spectrum is compact. So the “quantum kernel” ships as an ordinary phasor layer: train a linear model on the phasor features and it separates data a linear model cannot — the supervised counterpart to the generative Born machine, deployable on a laptop, and at qFHRR phase resolution for the edge.

Every phasor evaluation is a counted operation (feature_ops) — the hook for pricing interference computing in joules. Deterministic f64.

Structs§

Rff
A random-Fourier-feature (phasor) map approximating a Gaussian kernel exp(-γ·|x−x'|²).

Functions§

accuracy
Classification accuracy on (x, y).
accuracy_quantized
Accuracy using bits-bit qFHRR features (the edge-deployable path).
circles
Concentric circles: inner disc (−1) vs outer ring (+1). Not linearly separable.
feature_ops
Phasor operations to featurize n_samples: D · (dim + 1) per sample — the count a joule meter prices.
features
The phasor feature vector φ(x).
features_quantized
φ(x) with each phasor phase snapped to bits-bit qFHRR resolution.
fit_ridge
Fit a ridge classifier on phasor features: w = (ΦᵀΦ + λI)⁻¹ Φᵀ y. Labels y in {−1,+1}; predict sign(w·φ(x)).
sample_rff
Sample a phasor feature map: d_features frequencies ω ~ N(0, 2γ·I) and uniform phase biases. Deterministic in seed.
score
The raw decision score w·φ(x).
xor_data
XOR clusters at (±1,±1), label sign(x1·x2). Not linearly separable.