Skip to content

New Metric: Soft Dynamic Time Warping (Soft-DTW)#3287

Open
VijayVignesh1 wants to merge 17 commits intoLightning-AI:masterfrom
VijayVignesh1:feature/soft_dtw_loss
Open

New Metric: Soft Dynamic Time Warping (Soft-DTW)#3287
VijayVignesh1 wants to merge 17 commits intoLightning-AI:masterfrom
VijayVignesh1:feature/soft_dtw_loss

Conversation

@VijayVignesh1
Copy link
Copy Markdown
Contributor

@VijayVignesh1 VijayVignesh1 commented Oct 7, 2025

What does this PR do?

Fixes #3084

Before submitting
  • Was this discussed/agreed via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure to update the docs?
  • Did you write any new necessary tests?
PR review
Added a new domain called timeseries to include Soft DTW loss.
Ref paper: https://arxiv.org/abs/1703.01541

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃


📚 Documentation preview 📚: https://torchmetrics--3287.org.readthedocs.build/en/3287/

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Oct 7, 2025
@VijayVignesh1
Copy link
Copy Markdown
Contributor Author

@Borda Just wanted to get your initial opinion on this before I move forward. The softDTW uses dynamic programming which makes it really slow to work with on cpus. It's runs faster on gpus. Do you think it's worth continuing the effort?

@Borda
Copy link
Copy Markdown
Collaborator

Borda commented Oct 8, 2025

@Borda Just wanted to get your initial opinion on this before I move forward. The softDTW uses dynamic programming which makes it really slow to work with on cpus. It's runs faster on gpus. Do you think it's worth continuing the effort?

I think it is very fine to have only the GPU version and raise an exception or a warning on the CPU

@VijayVignesh1 VijayVignesh1 changed the title New metric: Soft Dtw Loss [WIP] New Metric: Soft Dtw Loss [WIP] Oct 9, 2025
@VijayVignesh1 VijayVignesh1 changed the title New Metric: Soft Dtw Loss [WIP] New Metric: Soft Dynamic Time Warping (Soft-DTW) Oct 9, 2025
@VijayVignesh1 VijayVignesh1 marked this pull request as ready for review October 9, 2025 19:12
Comment thread src/torchmetrics/functional/timeseries/softdtw.py Outdated
Comment thread src/torchmetrics/functional/timeseries/softdtw.py Outdated
@VijayVignesh1
Copy link
Copy Markdown
Contributor Author

@justusschock I'm looking at the unittest results. Turns out it's erroring out:

numba.cuda.cudadrv.error.NvvmSupportError: libNVVM cannot be found. Do `conda install cudatoolkit`:
libnvvm.so: cannot open shared object file: No such file or directory

The pysdtw library used as reference needs it. Is there any way around it?

@justusschock
Copy link
Copy Markdown
Member

@VijayVignesh1 not fully sure, but you could just add that libs installation to the docker command in .lightning/workloads.

@VijayVignesh1
Copy link
Copy Markdown
Contributor Author

@VijayVignesh1 not fully sure, but you could just add that libs installation to the docker command in .lightning/workloads.

@justusschock I removed the cuda usage in reference implementation and everything works fine now.

@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 18, 2025

Codecov Report

❌ Patch coverage is 35.71429% with 63 lines in your changes missing coverage. Please review.
✅ Project coverage is 37%. Comparing base (88bca94) to head (0f34ea5).

❌ Your project check has failed because the head coverage (37%) is below the target coverage (95%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #3287    +/-   ##
=======================================
- Coverage      37%     37%    -1%     
=======================================
  Files         364     353    -11     
  Lines       20096   19998    -98     
=======================================
- Hits         7520    7361   -159     
- Misses      12576   12637    +61     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Request metrics for time series forecasting.

3 participants