Skip to content

[ENH] Add MultiLoss and multi-target support to ptf-v2#2312

Open
andersendsa wants to merge 6 commits into
sktime:mainfrom
andersendsa:multiloss_support
Open

[ENH] Add MultiLoss and multi-target support to ptf-v2#2312
andersendsa wants to merge 6 commits into
sktime:mainfrom
andersendsa:multiloss_support

Conversation

@andersendsa

Copy link
Copy Markdown
Contributor

Reference Issues/PRs

#2308

What does this implement/fix? Explain your changes.

Fixes the BaseModelV2 to_prediction and to_quantiles functions to return multi-target list of tensors appropriately with MultiLoss. Updates log_metrics in BaseModelV2 to appropriately tag multi-target metrics logging iteratively to prevent dimension mismatch crashes.

Did you add any tests for the change?

tests/test_models/test_base_model_v2.py:

test_multi_loss_predictions: Verifies that to_prediction and to_quantiles correctly process predictions utilizing MultiLoss with different metrics like MAE and QuantileLoss, checking that it correctly outputs lists of tensors with the appropriate shapes.

test_multi_loss_log_metrics: Verifies that log_metrics successfully logs the evaluations for each target without a dimension crash, and correctly maps the prefix tags sequentially.

PR checklist

  • The PR title starts with either [ENH], [MNT], [DOC], or [BUG]. [BUG] - bugfix, [MNT] - CI, test framework, [ENH] - adding or improving code, [DOC] - writing or improving documentation or docstrings.
  • Added/modified tests
  • Used pre-commit hooks when committing to ensure that code is compliant with hooks. Install hooks with pre-commit install.
    To run hooks independent of commit, execute pre-commit run --all-files

@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@andersendsa andersendsa changed the title Add MultiLoss and multi-target support to ptf-v2 [ENH] Add MultiLoss and multi-target support to ptf-v2 Jun 16, 2026
@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.23529% with 2 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@c35d588). Learn more about missing BASE report.

Files with missing lines Patch % Lines
pytorch_forecasting/models/base/_base_model_v2.py 88.23% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2312   +/-   ##
=======================================
  Coverage        ?   87.12%           
=======================================
  Files           ?      167           
  Lines           ?     9763           
  Branches        ?        0           
=======================================
  Hits            ?     8506           
  Misses          ?     1257           
  Partials        ?        0           
Flag Coverage Δ
cpu 87.12% <88.23%> (?)
pytest 87.12% <88.23%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@andersendsa andersendsa force-pushed the multiloss_support branch 2 times, most recently from 1d7c22b to 14ec491 Compare June 19, 2026 09:26

@phoeenniixx phoeenniixx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of unrelated changes like to the notebooks and test.yml? Why? Please merge with main to solve the issues in the CI

@andersendsa

Copy link
Copy Markdown
Contributor Author

There are a lot of unrelated changes like to the notebooks and test.yml? Why? Please merge with main to solve the issues in the CI

@phoeenniixx Those other changes were already done when i checked out the repository

@phoeenniixx

Copy link
Copy Markdown
Member

There are a lot of unrelated changes like to the notebooks and test.yml? Why? Please merge with main to solve the issues in the CI

@phoeenniixx Those other changes were already done when i checked out the repository

I meant on your branch. you dont need to make these changes. Look at changed files - they have a lot of files which have unrelated changes to the PR. Please revert those

andersendsa and others added 6 commits June 19, 2026 19:34
Fixes the BaseModelV2 `to_prediction` and `to_quantiles` functions to return multi-target list of tensors appropriately with `MultiLoss`. Updates `log_metrics` in `BaseModelV2` to appropriately tag multi-target metrics logging iteratively to prevent dimension mismatch crashes.
@andersendsa

Copy link
Copy Markdown
Contributor Author

Hi @phoeenniixx i have done all the changes and the pr is ready for review

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants