pysiglib.prepare_log_sig#
Added in version v1.0.0.
- prepare_log_sig(dimension, degree, method, *, time_aug=False, lead_lag=False, use_disk=False, device='both')[source]#
Prepares for log signature computations. For details concerning the
methodparameter, see the page Computing Log Signatures. This function is not thread safe.This function populates in-memory caches for the CPU and/or GPU, controlled by the
deviceparameter. The CPU cache stores Lyndon words and projection matrices in host memory, while the GPU cache (if CUDA is available) stores Lyndon indices, level indices, and sparse matrices in device memory.When
use_disk=True, both the CPU and GPU libraries read from and write to a shared disk cache in the same binary format. If the disk cache already exists (e.g. from a previous run), the data is loaded from disk instead of being recomputed. Formethod=0, no preparation is needed and this function returns immediately.- Parameters:
dimension (int) – Dimension of the underlying path(s).
degree (int) – Truncation degree of the log signature.
method (int) – Method for the log signature computation. Must be one of 0, 1, 2 or 3. Methods 1 and 2 require preparation; methods 0 and 3 do not.
time_aug (bool) – Whether time augmentation will be used in the computation.
lead_lag (bool) – Whether the lead lag transform will be used in the computation.
use_disk (bool) – If
False, will cache prepared objects in memory only. IfTrue, will also save these objects in a shared disk cache to be re-used for future runs. The CPU and GPU libraries share the same disk cache format and directory. See additionally the documentation forpysiglib.set_cache_dir.device (str) – Which device caches to prepare. Must be one of
"cpu","cuda", or"both"(default). Use"cpu"to prepare only the CPU cache,"cuda"to prepare only the GPU cache, or"both"to prepare both.
Example usage:#
import pysiglib pysiglib.prepare_log_sig(5, 3, lead_lag=True, method=2, use_disk=True) X = torch.rand((32,100,5)) X_log_sig = pysiglib.log_sig(X, 3, lead_lag=True, method=2)
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}
}