Repository navigation
(Discarded) rsz: WNS stagnation logic enhancement based on PR 10248 - #10284
openroad-ci wants to merge 18 commits into
Conversation
Adds a deterministic WNS-stagnation gate to RepairSetup::terminateProgress(). Best-so-far WNS is sampled every pass into a 200-pass ring buffer; if the best observed value has not improved by max(1 ps, 0.5% * |initial_wns|) over a full window, the gate returns true. Combined with the existing two-consecutive-termination rule this aborts the phase after ~1200 passes of no WNS movement on designs where tiny TNS twitches would otherwise keep the optimizer running forever. Motivated by automated architectural-exploration flows where the .sdc is held at an ambitious target while RTL evolves. Without this, a WNS gap of hundreds of ps grinds repair_timing for hours producing no useful movement and forcing users to guess SETUP_SLACK_MARGIN values to stop it. The gate fires only when no reasonable user would disagree that further effort is futile (1 ps absolute floor keeps tape-out grind untouched; the TNS fix-rate gate still owns termination near closure). On trip, a single loud INFO log (RSZ-0234/235/236) names the best-effort WNS and notes this is probably an exploration run. No new Tcl flag, no new ORFS env var - hardcoded conservative defaults. New test test/orfs/hopeless/ synthesizes 8 parallel 8-deep arithmetic pipelines on asap7 with a 50 ps clock and asserts both that the flow completes and that the gate log message appears (sh_test + grep). A check_same idempotent test guards the determinism property. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
- RepairSetup.hh: include <cstddef> for size_t and <string> for std::string (include-cleaner warnings from clang-tidy CI bot). - RepairSetup.hh / RepairSetup.cc: name the stagnation-gate warmup threshold wns_stagnation_warmup_iterations_ instead of the bare 1000 literal, matching the style of the other tunables in this class. Not applied: gemini-code-assist's suggestion to change wns_stagnation_abs_tol_ from 1.0e-12f to 1.0e-3f. sta::Slack is measured in seconds (see src/sta/include/sta/Units.hh:73 "Sta internal units are always seconds, ..."), so 1.0e-12 s is 1 ps, which is the intended value. 1.0e-3 s would be 1 ms and would disable the gate. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Wrap long sta::Slack initialization line that clang-format flagged on PR The-OpenROAD-Project#10248 after the gemini-code-assist suggestion was applied via the GitHub UI. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
The sliding-window check (window_best - window_oldest over 200 passes) mis-classified plateaus as futility: any real design whose WNS drops dramatically early then flat-lines at a topology-bound floor while TNS keeps improving (aes, clone_flat, repair_fanout*) tripped the gate and aborted repair_timing too early, leaving worse max_cap/max_slew slack and different .ok-file output. Replace with best_wns_ever vs initial_wns_: only fire when WNS has effectively never moved from its starting value, which is the real signature of an obviously-futile run. Also bump rel_tol 0.5% -> 5%. Empirically aes improves WNS by ~50% of initial, clone_flat by ~95%, repair_fanout by ~90%; the hopeless.v synthetic only moves WNS by ~2% because buffer insertion chips something off even a grossly-over-clocked design. 5% sits in the gap. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Tiny TCL unit test exercising the WNS-stagnation gate added in this PR without scraping log strings. It builds a flat block of 1200 register-to-register pairs (DFF_X2 driver -> DFF_X2 sink, no logic in between), holds the cell library to _X1 / _X2 sizes, and sets a 1 ps clock period so that no SizeUpMove / BufferMove / pin-swap / clone / split-load / unbuffer move can improve WNS. The endpoint count is chosen so the inner-loop counter passes the gate's warmup before the legacy phase has visited every endpoint. Without the gate the same .tcl runs to iteration 1200 (one futile pass per endpoint); with the gate it exits at iteration 1002 and the .ok diverges, so the test fails without the fix and passes with it. Replaces the orfs-based test/orfs/hopeless gate-coverage check that maliberty asked to convert into a repair_setup-only unit test. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com> # Conflicts: # src/rsz/test/CMakeLists.txt
Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
There was a problem hiding this comment.
Code Review
This pull request introduces a 'WNS-stagnation' gate to the repair_timing flow in RepairSetup. This mechanism detects and aborts 'obviously futile' optimization runs where the Worst Negative Slack (WNS) fails to improve significantly after a warmup period, preventing the tool from grinding indefinitely on infeasible designs. The changes include new tracking methods in RepairSetup, updated logging, and a new regression test suite to verify the gate's behavior. I have no further feedback to provide.
This reverts commit 1dfe516. Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
…ate/OpenROAD into secure-pr-10248-add-unit-test Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
The window-improvement and threshold values are pure functions of already-stored state (best_wns_, ring buffer, initial_wns_). Compute them locally in terminateProgress() and recompute on demand in wnsStagnationReport() instead of mirroring them on the class. Removes 2 members and the "result-cached-for-display" smell. Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
|
@oharboe 1. WNS impact
2. TNS degradation
|
Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
…-unit-test Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com> # Conflicts: # src/rsz/test/CMakeLists.txt
|
clang-tidy review says "All clean, LGTM! 👍" |
|
@oharboe I enabled your WNS stagnation checker for |
Yes, I only have this problem when WNS < 0. |
|
@oharboe
I want to clarify these things. B. If you care the TNS too, then the TNS monitoring logic enhancement is required. So I wonder if you are ok w/ |
|
When it is clearly hopeless to close timing(WNS=0), then I want the quick wins in WNS and TNS and then terminate. Terminating quickly is more important than the exact improvements in WNS and TNS, we just want to fix pathological fanout things that are quick to fix(such as pathological fanout?). |
|
I see. If |
Do I have to configure something or change options? The change I made originally would do this without configuration, which is important for the automated design space exploration and I think a better user experience overall. |
|
@oharboe To use the WNS phase, you should change option. Default phases:
WNS phase:
Default phases vs. WNS phase
In your design, how many iterations are executed until the termination by no TNS improvement? |
|
@jhkim-pii Can we change the naming of the options to describe intent of the user instead of instructing repair_timing what to do? |
Could you please give an example? I guess you may want this. |
|
How about using last gasp? I want best WNS but -skip_last_gasp and a new -skip_stagnation_check Or do we need to distinguish between -skip_last_gasp and -skip_stagnation_check? I'm not into the details enough to judge. |
|
I asked Gemini for some help to say something about this PR because I'm not up to speed on all the concerns. It was helpful for me, so I thought I would share. OverviewThe logic introduced in PR #10284 (and #10248) represents a fundamental departure from traditional EDA principles. While the intent is to improve "No-Human-In-Loop" autonomy, the implementation creates a "weird" entanglement of physical constraints, heuristic proxies, and resource management that violates the Principle of Least Astonishment (POLA). 1. The Category Error: WNS vs. TNSThe PR treats WNS (Worst Negative Slack) and TNS (Total Negative Slack) as interchangeable signals for optimization "progress." In physical design, they serve entirely different masters:
The Problem: Using TNS "stagnation" to kill a process that might still be improving WNS is logically flawed. A designer may be perfectly willing to spend 2 hours of runtime to fix the final 10ps of WNS on a single critical path, even if 10,000 other non-critical paths (TNS) haven't moved an inch. 2. Orthogonality: Runtime is a Budget, Not a GoalRuntime capping and optimization goals are orthogonal concerns.
By baking "stagnation detection" and "runtime timeouts" directly into the resizer's internal logic, the tool is making executive decisions on behalf of the user without transparency.
3. Cognitive Load and the "Stunned" UserThe proliferation of "if/then/else" logic regarding when to stop or pivot increases the cognitive load to a breaking point. When a tool exposes its internal heuristics as configurable knobs, it shifts the burden of understanding from the developer to the designer.
4. Guidance for a Better Product ApproachTo align with industry-standard expectations and minimize user "stunning," the following changes are recommended:
ConclusionPR #10284 attempts to solve a performance problem by introducing an "Uncanny Valley" of automation—where the tool acts "smart" but in a way that is opaque and technically inconsistent. For OpenROAD to be a professional-grade tool, it must respect the distinction between physical requirements (WNS) and resource budgets (Runtime). |
|
@oharboe I want to focus on this. Needs
Please correct me if I misunderstood anything. Prerequisite: Optimization iteration loop
RepairSetup::repairSetup_Legacy() or repairSetup_LastGasp()
...
violator_collector_->init(setup_slack_margin); // Gather violated endpoints
while (violator_collector_->hasMoreEndpoints()) { // Loop until all violated endpoints are visited
violator_collector_->advanceToNextEndpoint();
sta::Vertex* end = violator_collector_->getCurrentEndpoint();
while (pass <= max_passes) { // pass means a repairEndpoint() attempt within the selected endpoint
opto_iteration++; // iteration means a single repairEndpoint() attempt
terminationCheckLogic // early termination if TNS improvement is less than threshold for 2 x 100 iterations
...
repairEndpoint(end->pin(), ...);
...
}
}
Existing TNS stagnation checkerThere is such TNS stagnation checking logic already (regardless of this PR).
repair_setup_hopeless.tcl exampleFor the default phases (LEGACY + LAST_GASP), Early termination decision historyIteration 1249: LEGACY phase finished after visiting all the violated endpoint (= no early termination) TNS improvement decision threshold historyInitial TNS = -83.6
Iteration 1000: TNS = -83.3, threshold = 0.01% -> 0.02% (0.01672)
Iteration 1249: LEGACY phase finished. TNS = -83.2, threshold = 0.02% My questionsYou said that some designs took long runtime w/ small TNS twitches.
If you want to monitor the both WNS and TNS, this PR is not needed. Possibly, the threshold tuning is enough. |
|
@jhkim-pii I think I owe you a test case, I will see about sharing one privately. Would that be the best way forward? I don't have specific recommendations, Claude hacked away at my problem and tried to come up with something that a) fixed my problem b) didn't break anything. However, as we often find: better to provide a test case... Thoughts? |
Yeah. Sharing the problematic test case will make things clear. |
|
The root-cause was fixed by #10571. |

This PR is based on the latest head of the original public PR:
The only additional change on top of that PR is the failing-test rebaseline commit:
This updates only src/rsz/test/repair_hold_multi_output_load.ok for the current timing output. The previously local repair_setup_stagnation test commit was intentionally excluded because PR #10248 already added a similar repair_setup_hopeless unit test.
Verification:
bazel test --cache_test_results=no --test_output=errors //src/rsz/test:repair_hold_multi_output_load-tcl_testResult: PASSED