[ENH] M mode test for TimeXer v2#2284
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2284 +/- ##
=======================================
Coverage ? 87.04%
=======================================
Files ? 166
Lines ? 9773
Branches ? 0
=======================================
Hits ? 8507
Misses ? 1266
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Hi @phoeenniixx this pr passes all the tests and is ready for review |
| dataset = TimeSeries( | ||
| data=df, | ||
| time="time_idx", | ||
| target=["target1", "target2"], # M mode uses multiple targets | ||
| group=["group_id"], | ||
| num=["temperature", "humidity", "pressure", "wind_speed"], | ||
| known=["temperature", "humidity", "pressure", "wind_speed", "time_idx"], | ||
| ) | ||
|
|
||
| data_module = TslibDataModule( | ||
| time_series_dataset=dataset, | ||
| batch_size=2, | ||
| context_length=12, | ||
| prediction_length=8, | ||
| train_val_test_split=(0.7, 0.15, 0.15), | ||
| ) | ||
| data_module.setup() | ||
| metadata = data_module.metadata | ||
|
|
There was a problem hiding this comment.
why are we not using pkg class here? I think we could use that and then we dont need to create these classes or anything and everything would happen under the hood, we just need to pass configs?
phoeenniixx
left a comment
There was a problem hiding this comment.
Thanks!
I have added some suggestions, please have a look at them
|
Hi @phoeenniixx i have done the required changes and the pr is ready for review |
| pkg.datamodule = pkg._build_datamodule(dataset) | ||
| pkg.datamodule.setup(stage="fit") | ||
|
|
||
| pkg._build_model(metadata=pkg.datamodule.metadata, **pkg.model_cfg) | ||
|
|
||
| train_dataloader = pkg.datamodule.train_dataloader() | ||
| batch = next(iter(train_dataloader))[0] |
There was a problem hiding this comment.
I think if you call pkg.fit(), pkg.predict(), you wouldnt have to create the data module etc separately. Or is this intentional?
There was a problem hiding this comment.
I think if you call
pkg.fit(),pkg.predict(), you wouldnt have to create the data module etc separately. Or is this intentional?
Yes, avoiding pkg.fit() is intentional. For multiple targets (M mode), the dataloader returns targets as a list ([target1, target2]), but the underlying metric layer incorrectly unpacks lists as (target, weight), causing pkg.fit() to crash. By manually triggering the forward pass instead, we bypass this metric bug and successfully verify the model architecture handles M mode correctly.
There was a problem hiding this comment.
This should be raised as an issue then! we should have a look at it. Can you please raise an issue and add your findings there? Please make sure to add some code to reproduce the error, so that we can diagnose it
|
Can you please explain how we are handling M tests without the pipeline able to handle the |
Right now, the PyTorch Forecasting v2 training pipeline (i.e., pkg.fit()) crashes on M mode datasets because the metrics layer (specifically LightningMetric.update which MultiLoss uses) isn't designed to handle target being a list of multiple target tensors. It incorrectly tries to unpack [target1, target2] as (target, weight), which causes a shape/dimension mismatch. Because we cannot train the model end-to-end with multiple targets using the built-in pkg.fit() pipeline, we have to bypass the metrics layer to test if the M mode architecture works. Here is how we are handling the M mode tests without full pipeline support:
Summary: We are handling M mode testing by checking the model's core architecture and forward pass in isolation, bypassing the high-level Lightning metric/loss calculations that are currently bugged/unsupported for multi-target datasets. This proves the internal layers of TimeXer scale correctly to multiple targets, even though the surrounding training wrapper does not yet support it.. |
|
Hi @phoeenniixx are there any changes required in this pr or is this pr good to merge ? |
Reference Issues/PRs
Resolves a codebase TODO.
What does this implement/fix? Explain your changes.
Added an M mode (multiple series) test to
test_timexer_v2.pyto resolve the actionable TODO comment requesting tests for multiple series forecasting now that the feature is successfully implemented.Improves test coverage and validates that the TimeXer v2 model correctly processes multi-target datasets.What should a reviewer concentrate their feedback on?
Did you add any tests for the change?
Yes, added
test_m_modetotests/test_models/test_timexer_v2.py.Any other comments?
PR checklist
pre-commit install.To run hooks independent of commit, execute
pre-commit run --all-files