[BUG] Validate v2 forecaster trainer and datamodule inputs early #2513
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.42) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 330 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.347
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #2513"
general
weight: 0.35
phoeenniixx
Reference Issues/PRs
Fixes #2504.
What does this implement/fix? Explain your changes.
Reject invalid
traineranddatamoduleinputs before checkpoint configuration is read or training data and models are built. Previously a trainer dictionary could fail with an unrelatedKeyError/AttributeError, and the wrong datamodule family could produce invalid model dimensions and a division by zero._check_typeto accept only a configured LightningTrainerorNone.get_datamodule_cls(), with a dedicated hint for passing a class instead of an instance. A separate hint covers passing the Trainer class.fit, including parameters changed after construction.Nonedefaults, compatible subclasses, constructor trainer cloning, and per-fit trainer overrides.What should a reviewer concentrate their feedback on?
The validation timing and error messages, particularly wrong-family datamodules and class-versus-instance mistakes. The datamodule requirement comes from each concrete forecaster rather than a hard-coded model family.
Did you add any tests for the change?
Yes. The focused suite now has five cases covering invalid constructor trainers and datamodules plus an invalid
fit(trainer=...)override.pytorch_forecasting.base._base_pkg. A plain pytest run still fails during collection because that module is missing onv2-dev. The previous Read the Docs build failed on the same import. Related import cleanup is tracked in #2503.pre-commit run --filescould not finish setting up its pinned hooks because the environment could not fetch them from GitHub.Environment: Python 3.13, torch 2.8.0 CPU, Lightning 2.6.6.
Any other comments?
Targets
v2-dev. Thanks to @karthik-0306 for the detailed report and proposed use of the existing validation helper. No dependency changes.PR checklist