Skip to content

[GPL] Add randomized initial placement perturbation in GPL#10642

Open
calewis wants to merge 6 commits into
The-OpenROAD-Project:masterfrom
calewis:gpl-placement-perturbation
Open

[GPL] Add randomized initial placement perturbation in GPL#10642
calewis wants to merge 6 commits into
The-OpenROAD-Project:masterfrom
calewis:gpl-placement-perturbation

Conversation

@calewis

@calewis calewis commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

Implemented a randomized initial placement perturbation feature in the OpenROAD Global Placer (GPL). This feature shifts standard cells by discrete increments of site widths (X direction) and row heights (Y direction), bounded to a maximum of 0.5 microns in both directions.

This replacement of the legacy srand(42) and rand() non-grid-aligned cell perturbation is controlled by a seed configured via the new -random_seed flag (default is 1)

Impact

  • Replaces the srand(42) based random cell coordinate perturbation loops in global placement with a new implementation.
  • Adds the -random_seed option to the global_placement Tcl command to customize the random seed (default is 1).
  • Perturbs standard cell initial coordinates by up to 0.5 microns in both X and Y directions, yielding slightly different but deterministic placements.
  • Updates all affected global placement regression golden files (.ok and .defok files) to align with the new default seed 1 layout expectations.

Verification

  • I have verified that the local build succeeds (./etc/Build.sh).
  • I have run the relevant tests and they pass.
  • My code follows the repository's formatting guidelines.
  • I have included tests to prevent regressions.
  • I have signed my commits (DCO).

@calewis calewis requested review from a team as code owners June 11, 2026 16:37
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Note

The number of changes in this pull request is too large for Gemini Code Assist to generate a review.

@calewis calewis force-pushed the gpl-placement-perturbation branch from fbc9177 to 0eddb5e Compare June 11, 2026 19:21
@github-actions github-actions Bot added size/M and removed size/S labels Jun 11, 2026
Comment thread src/gpl/src/nesterovBase.cpp Outdated
Comment on lines +1963 to +1964
// microns. We guarantee at least 1 site/row step of shift if perturbation is
// enabled.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is that guarantee needed? Global placement doesn't legal the result.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It's not needed, you want to simplify to something else?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@calewis calewis marked this pull request as draft June 16, 2026 23:28
@calewis calewis force-pushed the gpl-placement-perturbation branch 6 times, most recently from 018a4f0 to ca5112e Compare June 22, 2026 19:57
Signed-off-by: Drew Lewis <cannada@google.com>

TAG=agy
CONV=0fed8794-10c3-4c6f-bdf2-3dedf6c02c30
@calewis calewis force-pushed the gpl-placement-perturbation branch from ca5112e to 616a13d Compare June 22, 2026 20:18
@calewis calewis marked this pull request as ready for review June 22, 2026 20:20
Update the golden file to match the deterministic placement results produced by the global placement perturbation logic on this branch. The test has been verified to be 100% deterministic and independent of thread count (verified with both 4 and 8 threads).

Signed-off-by: Drew Lewis <cannada@google.com>
@calewis calewis force-pushed the gpl-placement-perturbation branch from 173be28 to c86c58e Compare June 24, 2026 11:40
@calewis

calewis commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator Author

@maliberty all checks now pass and I'm happy with where it's at.

@maliberty

Copy link
Copy Markdown
Member

I started a secure CI. This has a merge conflict.

Comment on lines +1981 to +1987
// To ensure that 99.5% of the perturbations fall within a circle of radius
// r_dbu, we use a Rayleigh distribution for the radial distance R = sqrt(X^2
// + Y^2). CDF(r) = 1 - exp(-r^2 / (2 * sigma^2)) = 0.995 => sigma = r_dbu *
// sqrt(-1 / (2 * ln(0.005))) sigma \approx 0.3071963263271184 * r_dbu.
const double sigma = r_dbu * 0.3071963263271184;

boost::random::normal_distribution<double> dist(0.0, sigma);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I thought we talked about using a bounded offset. This gives some chance for a large jump that is unexpected.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

If you'd like we can just resample until the offset is <= the radius? There is only a 0.5% of a point falling outside the radius so only a 0.003% chance you'd need to sample more than twice. Gaussian is nice because the most probable outcome is that you barely move the point at all.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The perturbation distances in microns look like (0.5 micron radius):

Vector Length Histogram (Rayleigh Distribution)
Based on 2D Normal (mean=0, sigma=0.153598)
Points: 50000
Min length: 0.000769
Max length: 0.786546
------------------------------------------
 0.00 | ** (267)
 0.03 | **************** (1900)
 0.06 | ****************************** (3537)
 0.09 | ****************************************** (4884)
 0.12 | *********************************************** (5460)
 0.15 | ************************************************** (5792)
 0.18 | ************************************************* (5752)
 0.21 | ********************************************* (5246)
 0.24 | ************************************** (4517)
 0.27 | ****************************** (3548)
 0.30 | ************************* (2952)
 0.33 | ****************** (2111)
 0.36 | ************ (1458)
 0.39 | ******** (1016)
 0.42 | ***** (621)
 0.45 | *** (400)
 0.48 | ** (263)
 0.51 | * (124)
 0.54 |  (67)
 0.57 |  (38)
 0.60 |  (22)
 0.63 |  (8)
 0.66 |  (9)
 0.69 |  (4)
 0.72 |  (2)
 0.78 |  (2)

With the current code if instead we use rejection based sampling for distances over 0.5 micron:

Truncated Vector Length Histogram
Based on 2D Normal (mean=0, sigma=0.153598)
Points Accepted: 50000
Points Rejected: 256 (fell outside 0.5 radius)
Min length: 0.001130
Max length: 0.499774
------------------------------------------
0.00 | * (103)
0.02 | ********** (826)
0.04 | ******************** (1627)
0.06 | **************************** (2315)
0.08 | ************************************* (2976)
0.10 | ****************************************** (3423)
0.12 | *********************************************** (3836)
0.14 | ************************************************** (4009)
0.16 | ************************************************* (3954)
0.18 | ************************************************ (3864)
0.20 | ******************************************** (3558)
0.22 | ***************************************** (3323)
0.24 | ************************************** (3063)
0.26 | ********************************* (2708)
0.28 | *************************** (2225)
0.30 | *********************** (1919)
0.32 | ******************* (1543)
0.34 | *************** (1217)
0.36 | ************ (991)
0.38 | ********* (759)
0.40 | ******* (582)
0.42 | ***** (426)
0.44 | *** (297)
0.46 | ** (231)
0.48 | * (150)
0.50 |  (75)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Finally, for completeness the old code, assuming it was using uniform sampling between 0 and 0.5 microns for both x and y:

Uniform Vector Length Histogram [x, y from U(0.0, 0.5)]
------------------------------------------
 0.00 |  (18)
 0.02 | * (111)
 0.04 | **** (255)
 0.06 | ****** (368)
 0.08 | ******** (509)
 0.10 | ********* (572)
 0.12 | ************ (766)
 0.14 | ************** (875)
 0.16 | **************** (1007)
 0.18 | ****************** (1092)
 0.20 | ******************** (1271)
 0.22 | ********************** (1353)
 0.24 | ************************ (1475)
 0.26 | ************************* (1556)
 0.28 | *************************** (1684)
 0.30 | ******************************* (1899)
 0.32 | ********************************* (2003)
 0.34 | ********************************* (2035)
 0.36 | ************************************** (2321)
 0.38 | *************************************** (2423)
 0.40 | ****************************************** (2556)
 0.42 | ******************************************** (2692)
 0.44 | ********************************************** (2824)
 0.46 | *********************************************** (2862)
 0.48 | ************************************************** (3031)
 0.50 | *********************************************** (2903)
 0.52 | *********************************** (2132)
 0.54 | **************************** (1742)
 0.56 | *********************** (1442)
 0.58 | ******************* (1195)
 0.60 | **************** (992)
 0.62 | ************* (810)
 0.64 | ********* (566)
 0.66 | ****** (379)
 0.68 | *** (216)
 0.70 | * (65)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess it still falls off sharply enough to not be worth changing.

calewis added 3 commits June 24, 2026 21:22
…turbation

Signed-off-by: Drew Lewis <cannada@google.com>

# Conflicts:
#	test/ibex_sky130hs.metrics_limits
Signed-off-by: Drew Lewis <cannada@google.com>
Signed-off-by: Drew Lewis <cannada@google.com>
@calewis calewis requested a review from a team as a code owner June 25, 2026 16:58
@calewis calewis requested a review from maliberty June 25, 2026 16:58
Signed-off-by: Drew Lewis <cannada@google.com>
@calewis calewis force-pushed the gpl-placement-perturbation branch from dd4a0ab to 3280e93 Compare June 25, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants