qp.labs.tcdq.MMDConfig

class MMDConfig(bandwidth=None, n_ops=None, wires=None, sqrt_loss=False, return_per_bandwidth=False, bootstrap_target_data=True)[source]

Bases: object

Hyperparameters for the qubit Maximum Mean Discrepancy (MMD) loss.

The MMD measures how well the model’s output distribution matches a target dataset.

Parameters:
  • bandwidth (float | Sequence[float]) – The bandwidth \(\sigma^2\) of the kernel. If a sequence is provided, the loss is evaluated for each value and then averaged, unless return_per_bandwidth=True.

  • n_ops (int) – Number of sampled observables per bandwidth. Larger values reduce estimator variance.

  • wires (Sequence[int] | None) – Subset of qubit indices to include in the loss. If None (default), all qubits are used.

  • sqrt_loss (bool) – If True, return \(\sqrt{|\text{MMD}^2|}\) instead of \(\text{MMD}^2\). Defaults to False.

  • return_per_bandwidth (bool) – If True, return a list of per-bandwidth loss values instead of their scalar average. Defaults to False.

  • bootstrap_target_data (bool) – If True, resample target_data with replacement before computing the loss. This makes the target-target U-statistic unbiased with respect to the empirical target distribution. Defaults to True.

Example

>>> from pennylane.labs.tcdq import MMDConfig, median_heuristic
>>> import numpy as np
>>> target_data = np.random.binomial(1, 0.5, size=(200, 6))
>>> bw = median_heuristic(target_data)
>>> config = MMDConfig(bandwidth=bw, n_ops=64)

bandwidth

Width of the RBF kernel (scalar or sequence for multi-bandwidth).

bootstrap_target_data

If True, bootstrap the target data before computing the loss.

n_ops

Number of sampled observables per bandwidth.

return_per_bandwidth

If True, return per-bandwidth losses instead of their average.

sqrt_loss

If True, return sqrt(|MMD²|) instead of MMD².

wires

Subset of qubit indices to include, or None for all qubits.

bandwidth = None

Width of the RBF kernel (scalar or sequence for multi-bandwidth).

bootstrap_target_data = True

If True, bootstrap the target data before computing the loss.

n_ops = None

Number of sampled observables per bandwidth.

return_per_bandwidth = False

If True, return per-bandwidth losses instead of their average.

sqrt_loss = False

If True, return sqrt(|MMD²|) instead of MMD².

wires = None

Subset of qubit indices to include, or None for all qubits.