[ENH] Add conversion hooks at the v2 model-metrics boundary #2496
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.39) × (1 − Review Confidence (0.43)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 244 lines diff across 3 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
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.329
Real PR Conversation Timeline
1 comments
"Review active on #2496"
general
weight: 0.35
phoeenniixx
Reference Issues/PRs
Fix #2495
What does this implement/fix? Explain your changes.
| File | Method / call site | Hook conversion and notes |
| --- | --- | --- |
| models/base/_base_model_v2.py | training_step | Convert predictions from [B,T,K,O] to K tensors of shape [B,T,O], and targets from [B,T,K] to K tensors of shape [B,T]. MultiLoss receives a prediction list and (target_list, weight). Single-target metrics receive individual tensors. Keep the loss result unchanged. |
| Same file | validation_step | Apply the same input hooks before computing validation loss. |
| Same file | test_step | Apply the same input hooks before computing test loss. |
| Same file | log_metrics | Pair each target with its prediction. Distinguish raw predictions from already converted point predictions, preserving raw inputs for loss-like logging metrics. Keep logged values unchanged. |
| Same file | to_prediction | Convert inputs before calling the metric’s bound method. For originally 4D predictions, restore point results to [B,T,K], including K=1. Preserve legacy return formats and handle both the kwargs call and its fallback. |
| Same file | to_quantiles | Convert inputs before calling the metric’s bound method. For originally 4D predictions, restore quantile results to [B,T,K,Q], including K=1. Preserve legacy return formats and handle both the kwargs call and its fallback. Q need not equal the original output size O. |
Did you add any tests for the change?
Yes
PR checklist
pre-commit install.To run hooks independent of commit, execute
pre-commit run --all-files