Skip to content

fix segment-based RC regression score computation#4237

Merged
eder-matheus merged 2 commits into
The-OpenROAD-Project:masterfrom
AcKoucher:fix-rc-regression-score
May 18, 2026
Merged

fix segment-based RC regression score computation#4237
eder-matheus merged 2 commits into
The-OpenROAD-Project:masterfrom
AcKoucher:fix-rc-regression-score

Conversation

@AcKoucher

Copy link
Copy Markdown
Contributor

Context

When running the regression for sky130hs/aes I got a crazy negative score for the li1 layer resistance fit.

This design had a few geometrically identical small segments on this layer that are a result of a pin access maneuver to allow reaching an instance's pin:
image

It turns out that sklearn's default baseline model for scoring the fit i.e., measuring R² is "predict the mean" which is not the proper model for our regressions since both R and C are through-origin fits - the R² computation doesn't behave well for near-zero variance. A more proper approach would be to compute R² with a "predict zero" baseline model.

Changes

Compute the fit score manually using a helper function that uses "predict zero" baseline model rather than .score.

Observations

  • I didn't change how net mode scores its fit.
  • The fit itself won't change with this PR, just the score value.
  • The scores will change slightly even for cases in which the value was already "correct" as we're measuring against a different baseline.

Signed-off-by: Arthur Koucher <arthurkoucher@precisioninno.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a custom R² calculation for through-origin regressions in correlateRC.py to replace the default sklearn scoring, which uses a 'predict mean' baseline. A new helper function, compute_through_origin_fit_score, is implemented and used for resistance and capacitance fit scoring. The review feedback suggests improving the robustness of this function by returning a perfect score of 1.0 instead of raising a ValueError when all observed values are zero, which prevents script termination during automated runs on designs with unused routing layers.

Comment thread flow/util/correlateRC.py Outdated
Signed-off-by: Arthur Koucher <arthurkoucher@precisioninno.com>
@AcKoucher AcKoucher requested a review from eder-matheus May 18, 2026 20:04
@eder-matheus eder-matheus enabled auto-merge May 18, 2026 20:48
@eder-matheus eder-matheus merged commit 74b5f96 into The-OpenROAD-Project:master May 18, 2026
8 of 9 checks passed
@maliberty

Copy link
Copy Markdown
Member

The min routing layer is met1 so li1 won't have much useful data in any case.

@AcKoucher AcKoucher deleted the fix-rc-regression-score branch May 18, 2026 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants