Skip to content

[BUG] Move tensors in nested prediction outputs to the requested device - #2468

Open
AHMETHAKANBEZIR1 wants to merge 1 commit into
sktime:mainfrom
AHMETHAKANBEZIR1:fix/move-nested-prediction-devices
Open

AHMETHAKANBEZIR1 wants to merge 1 commit into
sktime:mainfrom
AHMETHAKANBEZIR1:fix/move-nested-prediction-devices

Conversation

@AHMETHAKANBEZIR1

Copy link
Copy Markdown

LLM generated content, by OpenAI Codex

Reference Issues/PRs

Related to the prediction collection context of #2228, which fixed the v2 callback. This fixes the shared device-moving helper; it does not claim to resolve or measure #772's GPU memory report.

What does this implement/fix? Explain your changes.

move_to_device discards the converted children of an immutable OutputMixIn, leaving network-output tensors on their old device. Its sequence path also checks only x[0].device: empty sequences raise, nested containers fail, and a later tensor is skipped when the first is already on the target device.

Rebuild network outputs with moved fields and recursively traverse every sequence item, retaining list/tuple/namedtuple types. Existing dictionary updates and MPS fallback behavior are unchanged; non-tensor metadata passes through.

What should a reviewer concentrate their feedback on?

Immutable output reconstruction and traversal independent of the first item. CPU-to-meta checks use real PyTorch transfers, so these regressions run without a GPU. They are not measurements of GPU memory usage.

Did you add any tests for the change?

Fourteen cases cover a real linear model's network output, nested dictionaries/sequences, empty list/tuple values, mixed source devices, namedtuple preservation and metadata. Clean main 6d0d18a has 12 failures and 2 passing CPU controls; all fourteen pass with the fix.

  • Complete utility suite: 28 passed.
  • Existing callback tests and default/multi-target DecoderMLP training/prediction integrations: 6 passed, 4 existing Lightning deprecation warnings.
  • Configured pre-commit hooks pass across all files, explicitly for the new test file, and at commit; git diff --check passes.

CPU Python 3.12.14 / PyTorch 2.13.0. Full-package, GPU, distributed and performance benchmarks were not run.

Any other comments?

No dependency changes. Prepared autonomously with OpenAI Codex; no independent human review is claimed.

PR checklist

  • The PR title starts with [BUG].
  • Added/modified tests.
  • Used pre-commit hooks when committing.

@codecov

codecov Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@6d0d18a). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2468   +/-   ##
=======================================
  Coverage        ?   88.83%           
=======================================
  Files           ?      218           
  Lines           ?    11669           
  Branches        ?        0           
=======================================
  Hits            ?    10366           
  Misses          ?     1303           
  Partials        ?        0           
Flag Coverage Δ
cpu 88.83% <100.00%> (?)
pytest 88.83% <100.00%> (?)

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.

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.

1 participant