Fast Gradient-Based Approximation of Continuous Dynamic Time Warping

Pierre Houedry, Romain Tavenard, Nicolas Courty, Romaric GaudelarXiv 2026

TL;DR

FastCDTW is a new, GPU-friendly approximation for Continuous Dynamic Time Warping (CDTW) that replaces slow, non-differentiable dynamic programming with efficient gradient descent. By optimizing a parametrized warping function, it achieves up to a 50x speedup in deep learning pipelines while maintaining high accuracy and avoiding the "blurring" artifacts common in other differentiable alignment methods.

What Problem Does This Paper Address?

Measuring the similarity between two time series is tricky because signals rarely align perfectly in time—one might be stretched, delayed, or sampled at a different rate. The classic solution is Dynamic Time Warping (DTW), which finds an optimal alignment by "warping" the time axis.

However, DTW has three major headaches for modern machine learning:

  1. Discreteness: It treats time series as sequences of indices rather than continuous signals, making it sensitive to sampling rates.
  2. Non-Differentiability: You can't easily plug standard DTW into a neural network as a loss function because you can't backpropagate through its "min" operation.
  3. Computational Cost: DTW scales quadratically ($O(N^2)$) with sequence length, which is too slow for long sequences or large datasets.

While variants like Soft-DTW (differentiable) and Continuous-DTW (continuous) exist, they either introduce a "denoising" bias that blurs sharp features or remain computationally impractical for large-scale deep learning.

Methods

The authors introduce FastCDTW, which shifts the paradigm from solving a global optimization problem via dynamic programming to solving a local one via gradient descent.

Key components include:

  • Parametrization: Instead of searching through all possible discrete paths, they represent the warping as a continuous function $\phi$ defined on a grid. They use a SoftPlus activation to ensure the warping is strictly increasing (monotonic).
  • Two Evaluation Schemes:
    • Piecewise-Linear (PL): An exact, closed-form solution for the alignment cost when the input signals and the warping function are piecewise-linear.
  • Monte Carlo (MC): An unbiased estimator that uses random sampling to calculate the cost. This is particularly useful for "Implicit Neural Representations" (INRs), where time series are represented as neural networks rather than arrays of samples.
  • Differentiability: The authors prove that CDTW is differentiable with respect to the input curves when the warping is restricted to a parametrized family, allowing it to be used as a drop-in loss function.

The complexity of a single evaluation is reduced from $O(N^2)$ to $O(N)$, as shown in the comparison table below:

Complexity comparison of different alignment methods.

Datasets

The researchers evaluated FastCDTW across several tasks:

  • Synthetic Families: Three datasets (accel, ecg, and rate) designed to test time-series averaging (barycenter computation).
  • UCR Archive: A subset of 95 univariate datasets used to benchmark 1-Nearest-Neighbor classification accuracy.
  • Domain Adaptation: Two real-world benchmarks:
  • TarnBrittany (TB): Satellite image time series for land-cover classification.
  • miniTimeMatch (mTM): A crop-classification benchmark spanning different geographical regions.

Key Insights and Ideas

  • Trading Global Optimality for Speed: By using gradient descent, FastCDTW loses the guarantee of finding the absolute best alignment (global minimum). However, the experiments show that the "good enough" local minimum found by gradient descent is actually more useful in practice because it is differentiable and much faster.
  • Preserving Sharp Features: Soft-DTW often "erodes" peaks in time-series averages because it considers an average of all possible paths. FastCDTW selects a single (approximate) optimal path, which preserves the original shape of the signal much better.
  • GPU Parallelization: Unlike dynamic programming, which is notoriously hard to parallelize, FastCDTW's operations (like Monte Carlo sampling and grid evaluations) are "embarrassingly parallel" and thrive on GPUs.

Key Results

  • Speed: FastCDTW is significantly faster for long sequences. For a sequence length of 10,000, it provides a 10x speedup over Soft-DTW. In a full domain adaptation pipeline, it ran up to 50x faster on a GPU than the DTW baseline.
  • Scaling: As shown in Figure 2, FastCDTW (especially the GPU versions) scales much more gracefully with sequence length ($T$) than CPU-based DTW or Soft-DTW.
Figure 2: Computation time of DTW, Soft-DTW and FastCDTW as a function of the series length.
  • Quality: In time-series averaging (Figure 3), FastCDTW successfully recovers sharp peaks in ECG and acceleration data where Soft-DTW tends to smooth them out.
Figure 3: Barycenters of accel (top), ecg (middle) and rate (bottom). Grey: the averaged series.
  • Accuracy: On the 95 UCR datasets, FastCDTW achieved an average rank comparable to Soft-DTW and significantly better than standard Euclidean distance or DTW.

Limitations and Future Work

  • Non-Convexity: Because the objective is non-convex, the algorithm is sensitive to initialization. While the authors found that starting from an "identity" warping (no warping) works well, there's no guarantee it won't get stuck in a poor local minimum for very complex signals.
  • Asymmetry: The grid-based parametrization is not perfectly symmetric (aligning $x$ to $y$ might give a slightly different result than $y$ to $x$), though this effect vanishes as the grid is refined.
  • Future Directions: The authors suggest applying FastCDTW to "continuous-time foundation models," where signals are modeled as continuous functions for tasks like forecasting on irregular grids or data imputation.

Summary updated

BibTeX
@misc{houedry2026fast,
  author = {Pierre Houedry and Romain Tavenard and Nicolas Courty and Romaric Gaudel},
  title = {{Fast Gradient-Based Approximation of Continuous Dynamic Time Warping}},
  year = {2026},
  eprint = {2610.13129},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2610.13129},
}
Figure