← Back to Pull requests

[ENH] Add conversion hooks at the v2 model-metrics boundary #2496

Open
unknown opened this pull request with 244 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 03, 2026 04:32 UTC
Author

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

  • [ x] The PR title starts with either [ENH], [MNT], [DOC], or [BUG]. [BUG] - bugfix, [MNT] - CI, test framework, [ENH] - adding or improving code, [DOC] - writing or improving documentation or docstrings.

  • [x ] Added/modified tests

  • [x ] Used pre-commit hooks when committing to ensure that code is compliant with hooks. Install hooks with pre-commit install.

  • To run hooks independent of commit, execute pre-commit run --all-files

    Diff: 244 lines (+183 / -61) across 3 files Reviewer: phoeenniixx Review duration: 39602m
    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
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 38.8% (MEDIUM) · Higher = larger blast radius
    38.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.1% · Safe to merge
    22.1%