pysiglib.sig_kernel_backprop

pysiglib.sig_kernel_backprop#

Added in version v0.2.

Warning

Where possible, pysiglib.torch_api should be used rather than explicitly calling backpropagation functions. Explicit backpropagation can introduce subtle errors if called incorrectly. In addition, some pysiglib functions can only be backpropagated through using their pysiglib.torch_api variants and do not expose explicit backpropagation functions.

sig_kernel_backprop(derivs, path1, path2, dyadic_order, static_kernel=None, time_aug=False, lead_lag=False, end_time=1.0, left_deriv=True, right_deriv=False, k_grid=None, n_jobs=1)[source]#

This function is required to backpropagate through pysiglib.sig_kernel. Given the derivatives of a scalar function \(F\) with respect to a signature kernel, \(\partial F / \left< S(x), S(y) \right>\), returns the derivatives of \(F\) with respect to one or both of the underlying paths, \(\{\partial F / x_{t_i}\}_{i=0}^{L_1}\) and \(\{\partial F / y_{t_i}\}_{i=0}^{L_2}\).

Parameters:
  • derivs (numpy.ndarray | torch.tensor) – Derivatives with respect to a signature kernel or batch of signature kernels, \(\partial F / \left< S(x), S(y) \right>\).

  • path1 (numpy.ndarray | torch.tensor) – The first underlying path or batch of paths, given as a numpy.ndarray or torch.tensor. For a single path, this must be of shape (length_1, dimension). For a batch of paths, this must be of shape (batch_size, length_1, dimension).

  • path2 (numpy.ndarray | torch.tensor) – The second underlying path or batch of paths, given as a numpy.ndarray or torch.tensor. For a single path, this must be of shape (length_2, dimension). For a batch of paths, this must be of shape (batch_size, length_2, dimension).

  • dyadic_order (int | tuple) – The dyadic order(s) used to compute the signature kernels.

  • static_kernel (None | pysiglib.StaticKernel) – Static kernel. If None (default), the linear kernel will be used. For details, see the documentation on static kernels.

  • time_aug (bool) – If True, assumes the paths were time augmented.

  • lead_lag (bool) – If True, assumes the lead-lag transform was applied.

  • end_time (float) – End time for time-augmentation, \(t_L\).

  • left_deriv (bool) – If True, returns \(\{\partial F / x_{t_i}\}_{i=0}^{L_1}\). At least one of left_deriv and right_deriv must be True. If both are True, returns both derivatives as a tuple.

  • right_deriv (bool) – If True, returns \(\{\partial F / y_{t_i}\}_{i=0}^{L_2}\). At least one of left_deriv and right_deriv must be True. If both are True, returns both derivatives as a tuple.

  • k_grid (numpy.ndarray | torch.tensor) – Signature kernel PDE grid. If None, the grid will be recomputed.

  • n_jobs (int) – (Only applicable to CPU computation) Number of threads to run in parallel. If n_jobs = 1, the computation is run serially. If set to -1, all available threads are used. For n_jobs below -1, (max_threads + 1 + n_jobs) threads are used. For example if n_jobs = -2, all threads but one are used.

Returns:

Tuple of derivatives of \(F\) with respect to one or both of the underlying paths. If left_deriv is True, the first element of this tuple is \(\{\partial F / x_{t_i}\}_{i=0}^{L_1}\), otherwise it is None. Similarly for right_deriv and \(\{\partial F / y_{t_i}\}_{i=0}^{L_2}\).

Return type:

numpy.ndarray | torch.tensor | Tuple[numpy.ndarray | numpy.ndarray] | Tuple[torch.tensor | torch.tensor]


Citation#

If you found this library useful in your research, please consider citing the paper:

@article{shmelev2025pysiglib,
  title={pySigLib-Fast Signature-Based Computations on CPU and GPU},
  author={Shmelev, Daniil and Salvi, Cristopher},
  journal={arXiv preprint arXiv:2509.10613},
  year={2025}
}