[BUG] fix AggregationMetric target weighting when y_pred has an extra dimension #2541
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.44) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.44 · 253 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 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.331
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #2541"
general
weight: 0.35
fnhirwa
Reference Issues/PRs
Fixes #2540
What does this implement/fix? Explain your changes.
AggregationMetric._calculate_meanbroadcast the weight to the shape ofy_predwhen weighting the target:When predictions have an extra dimension (quantiles, distribution parameters), the
(B, T)target was multiplied by a(B, T, 1)or(B, 1, 1)weight. This raised aRuntimeErrorforB != T, and gave a wrongly shaped mean forB == T. The weight also exists without user weights: for aPackedSequencetarget the method uses the(B, T)length mask as the weight.The weight is now broadcast to
targetfor the target mean. The prediction mean is unchanged.What should a reviewer concentrate their feedback on?
The one-line change in
_calculate_mean, and whether the test's reference (weighted means of target and prediction computed by hand, thenQuantileLoss) matches the intended semantics.Did you add any tests for the change?
test_aggregation_metric_weighted_with_quantiles, parametrized over(B, T)and(B,)weights, withB=4,T=3, 7 quantiles and random weights:main: both cases fail withRuntimeError: The size of tensor a (4) must match the size of tensor b (3);tests/test_metrics.pypasses (72 passed, 6 skipped, the skips are thecpflowssoft dependency).pre-commitpasses on the changed files.PR checklist
🤖 Generated with Claude Code