← Back to Pull requests

[BUG] Fix logging_metrics device mismatch in BaseModelV2 #2205

Closed
unknown closed this pull request without merging on Mar 24, 2026 04:52 UTC
View on GitHub
unknown unknown commented on Mar 17, 2026 08:04 UTC
Author

Reference Issues/PRs

Fixes #2197

What does this implement/fix? Explain your changes.

Wraps logging_metrics in nn.ModuleList in BaseModelV2.__init__ so metrics are registered as submodules and move with the model on .to() calls.

 

What should a reviewer concentrate their feedback on?

-The two regression tests in test_base_model_v2.py,
-Whether iterating metric._defaults to reach torchmetrics state tensors is acceptable, or if there's a cleaner public API to assert device propagation without a GPU?

Did you add any tests for the change?

Yes, tests/test_models/test_base_model_v2.py (new file):

  • test_logging_metrics_is_module_list this asserts the container type directly

  • test_logging_metrics_device_propagation this moves the model to torch.device("meta") and checks that metric state tensors follow. This catches the bug on CPU-only CI since .to("meta") is a real device move unlike .to("cpu") which is a no-op when already on CPU.
  •  

    Any other comments?

    Tests use DLinear with a minimal metadata dict, no dataloader or trainer needed.

    PR checklist

  • The PR title starts with either [ENH], [MNT], [DOC], or [BUG]. → [BUG]

  • Added/modified tests

  • Used pre-commit hooks when committing
  • Diff: 163 lines (+122 / -41) across 2 files Reviewer: fnhirwa Review duration: 9887m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.35) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.35 · 163 lines diff across 2 files
    0.35
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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
    Diff Size diff_size
    0.305
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #2205"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 35.0% (LOW) · Higher = larger blast radius
    35.0%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 13.8% · Safe to merge
    13.8%