← Back to Pull requests

[ENH] Merge `Flatten_Head` into `FlattenHead` with individual and `n_quantiles` support #2508

Open
unknown opened this pull request with 389 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 11, 2026 10:40 UTC
Author

Description:

Summary

- Unified two near-identical flatten-head layers into a single FlattenHead in layers/_output/_flatten_head.py by adding an individual parameter
(defaults to False, preserving all existing behaviour for TimeXer and PatchTST).
- Updated ModernTCN to import and use the unified FlattenHead instead of the now-deprecated Flatten_Head.
- Replaced layers/_head/_flatten_head.py with a thin deprecated alias (Flatten_Head) that emits a DeprecationWarning and delegates to
FlattenHead, preserving backward compatibility for any external code.
- Added unit tests covering all four combinations of individual={True, False} × n_quantiles={None, k}, module-structure assertions, and the
deprecated-alias round-trip.

Motivation

Having two classes with different names and disjoint feature sets was confusing and prevented models like ModernTCN from benefiting from quantile
outputs via the head. The merge gives both features to all models from a single, well-documented class.

Breaking changes

None for public API consumers. The only internal behaviour change is in ModernTCN.forward, where one .permute(0, 2, 1) was added after the head
call to account for the now-consistent (B, target_window, n_vars) output shape — the final model outputs are identical.

Closes #2507

Diff: 389 lines (+291 / -98) across 4 files Reviewer: phoeenniixx Review duration: 27714m
All Vouch review confidence checks passed
Residual risk 0.23 = Change Risk (0.43) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 389 lines diff across 4 files
0.43
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%
46%
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.357
Shallow Review Depth shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #2508"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 46.7% 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: 43.1% (MEDIUM) · Higher = larger blast radius
43.1%
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: 46.7% · Lower = rushed or shallow review
46.7%
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: 23.0% · Safe to merge
23.0%