Repository navigation
Description
Today's repair_timing policy can be a Pyrrhic victory: repair grinds out the last picosecond, and the time it costs is paid for in design iterations that never happen. Running time is QoR.
A request for comments.
Description
repair_timing can be most of a build, and most of that comes after it has stopped making progress. On a larger design, that means fewer iterations on the design's own parameters (floorplan, RTL, constraints) in a day, and so worse QoR in the end.
On ORFS's asap7 designs, from repair_timing -verbose:
| design | repair_timing share of stage time | progress rows after the knee | WNS given up there |
|---|---|---|---|
| coralnpu | 68 % (2,702 of 3,989 s) | 83 % | 1.6 ps |
| ibex | 86 % (932 of 1,086 s) | 83 % | 1.8 ps |
| picorv32 (3 seeds) | 58–67 % | 88–93 % | ≤ 1.2 ps |
| riscv32i | 62 % | 93 % | 1.1 ps |
| swerv_wrapper | 9 % | 64 % | 0 ps |
| cva6 | 19 % | 92 % | 6.9 ps |
"After the knee" is where a per-phase plateau rule would have ended the phase: best WNS gains < 0.5 ps and TNS < 1 % over the last 20 progress rows. A progress row is a line of -verbose output, printed every so many iterations; an iteration is a unit of repair work. The table counts rows, because the log has nothing else, so the time saved is an estimate: the logs carry no timestamps, and rows are not all equally expensive.
What happens today. Each setup phase stops on terminateProgress: every 100 iterations it compares the TNS fixed since the last check with 0.01 % of the initial TNS, a threshold that doubles every 1,000 iterations, and it never stops before iteration 1,000. WNS plays no part. Beyond that there are blind caps (-max_iterations, -max_passes) and knobs that need the answer up front (-setup_margin, -repair_tns).
Why it is like this (Chesterton's fence). The stop is conservative on purpose. Progress is not monotonic, so a plateau does not mean the end:
- In coralnpu's CTS repair the main phase reaches 80 % of its WNS gain in the first 10 % of rows and then gains nothing for 42 % of rows. Then last gasp takes WNS from −46.6 to −35.0 ps in a few rows.
- cva6 gains late: the rule above costs it 6.9 ps.
A stop that comes too early and misses closure costs a tape-out; grinding costs compute. With closure as the goal, grinding is the safe default.
It is a hard problem, and an old one. Deciding when an optimizer has done enough is the stopping criterion of simulated-annealing placement [1], what METRICS set out to learn from measured runs [2], "doomed run" prediction with graph learning on industrial flows [3], and one of Kahng's open challenges, because today humans make that call [4]. Outside EDA, early stopping is the core of hyperparameter search [5]. Commercial tools now spend machine learning and many machines on the same trade-off [6]. People keep trying because the payoff is large.
I tried this before without applying Chesterton's fence, with predictable results: a built-in effort level (#10900, PR #10942) and a futility stop (PR #10248). The objection there stands: not everyone agrees how much effort to spend.
Suggested Solution
A strawman, for comments, not a recommendation: something concrete to pick apart. The best idea I have so far is a general user callback, a native Tcl or Python procedure, that makes the low-frequency stopping decision, while everything high-frequency stays in C++.
- Invocation is decoupled from logging. Progress rows are logged at uneven intervals of iterations, sometimes so far apart that the callback should have been asked several times in between. The callback is called every N iterations of work (its own cadence), not at log rows.
- It gets two dictionaries: read-only state from C++ (phase, iteration, WNS, TNS, violators, moves, area, ...), and a mutable state dictionary of its own, kept between calls; plus its parameters.
- It returns
continue,next_phaseorstop, with a reason that is logged. - The decision is per phase: stopping all of repair at the first plateau would have given up coralnpu's last-gasp 11 ps.
- The inputs are QoR only, so results stay deterministic.
- Today's behaviour becomes the default, overridable. The existing
terminateProgressrule is the default stopping policy, and today's progress rows the default logging cadence; a user can override either, independently. Without an override, nothing changes.
In the flow it is a variable, say REPAIR_TIMING_POLICY_TCL in ORFS-based flows (make or Bazel), naming the file that defines the rule. Rules start specific to a PDK and a design, written by whoever knows them, and are removed for a sign-off run. A small library of reusable rules may emerge from them; and who knows, a dominant one might emerge that experience can promote to the default. A smaller step in the same direction: expose terminateProgress's thresholds per phase, for WNS as well as TNS, as @minjukim55 suggested in #10900. (-policy is already an alias for -phases, so the callback needs another name.)
The case against. A user policy may need retuning when OpenROAD changes repair; if the change is an improvement, that is a good problem to have. And there is something to be said for having no policy and leaving it all to OpenROAD: a user policy does not dominate, or OpenROAD would already have had one or offered the options. Comments welcome on whether a callback is the right shape, what it gets wrong, or whether there is a better one.
Additional Context
Reproduce: any ORFS asap7 design above. Read the WNS and TNS columns of repair_timing -verbose in 4_1_cts.log and 5_1_grt.log in log order; the iteration counter restarts per phase, marked * for the main phases and + for last gasp.
[1] M. D. Huang, F. Romeo, A. Sangiovanni-Vincentelli, "An efficient general cooling schedule for simulated annealing", ICCAD 1986.
[2] S. Fenstermaker, D. George, A. B. Kahng, S. Mantik, B. Thielges, "METRICS: a system architecture for design process optimization", DAC 2000. https://vlsicad.ucsd.edu/Publications/Conferences/112/c112.pdf
[3] Y.-C. Lu, S. Nath, V. Khandelwal, S. K. Lim, "Doomed run prediction in physical design by exploiting sequential flow and graph learning", ICCAD 2021. https://gtcad.gatech.edu/www/papers/iccad21-1.pdf
[4] A. B. Kahng, "Reducing time and effort in IC implementation: a roadmap of challenges and solutions", DAC 2018. https://vlsicad.ucsd.edu/Publications/Conferences/360/c360.pdf
[5] L. Li, K. Jamieson, G. DeSalvo, A. Rostamizadeh, A. Talwalkar, "Hyperband: a novel bandit-based approach to hyperparameter optimization", JMLR 18, 2018. https://jmlr.org/papers/v18/16-558.html
[6] For example Synopsys DSO.ai: https://www.synopsys.com/blogs/chip-design/enhancing-chip-design-with-ai.html
Activity
[-]repair_timing: let the user end a phase at its knee[/-][+]RFC: repair_timing, a user callback to end a phase at its knee[/+]noahwithoutark22 commentedon Oct 9, 2026
I ran the plateau rule from the RFC on other ORFS asap7 designs (aes, jpeg, ethmac, tpu, mock-cpu), using the
openroad/orfsDocker image built 7 Oct 2026 with default settings. The exact image digest, script and CSV are in this gist: https://gist.github.com/noahwithoutark22/e750168482f608d3b75be848b36d41c0Rule: knee = first row where the last 20 rows gained < 0.5 ps WNS and < 1% of the phase's initial |TNS| (my reading of "TNS < 1%"). "TNS given up" = TNS gained after the knee, as a % of that initial |TNS|. Main (
*) phases:mock-cpu's phases are shorter than the 20-row window, so the rule doesn't apply. Last gasp reaches the knee at the minimum window on every design. Caveats as in the RFC: rows aren't time, and these designs are small. One observation: on aes and jpeg the TNS left behind after the knee is a few percent, so stopping there isn't free if TNS matters.
oharboe commentedon Oct 9, 2026
Thanks for testing.
This makes me think of a complication. Against the clock periods in the designs' SDCs, the final WNS in your CSV is not small. At the end of GRT it is −11 ps on aes (3 % of 380 ps), −36 ps on mock-cpu (13 % of 270 ps), −97 ps on ethmac (10 % of 1000 ps), −100 ps on jpeg (18 % of 545 ps) and −372 ps on tpu (186 % of 200 ps). So "WNS given up: 0.0 ps" means the worst path stopped moving while repair carried on working on TNS. With WNS this negative, repair is grinding on paths it can't fix, and that is a different regime from the one the RFC is about.
The other end has a problem too. Repair stops at slack ≥ the setup margin (0 by default), so a design that closes reports no WNS beyond that, which tells us nothing about how far a policy could have gone. A better metric is the minimum clock period,
clock_period − WNS, compared between policies as a percentage. To get a reading, the clock should be set so that the default flow ends slightly negative, a few percent like aes here.Second, the flow cascades. In ORFS, timing is repaired by default at floorplan, CTS and GRT, each against a different estimate of the parasitics. How much one stage repairs changes what the next stage starts from: TNS left behind at CTS may or may not be recovered at GRT. Only running the rest of the flow and comparing the final minimum clock period tells us. A per-stage knee measures what that stage gave up, not what the flow gave up.
That makes a proper study expensive. With P policies, S stages that repair and the flow's stages after each:
Third, the stages are not equal. GRT is the last stage that repairs timing in ORFS, so its policy should be all-out on QoR: meet WNS ≥ 0, or get as close as it can. Earlier stages repair against estimates (floorplan before placement, CTS on placement parasitics), so how much they repair is negotiable. It works more like a margin than the goal. Kahng argues that tools which guardband against miscorrelation with later analysis "perform unneeded sizing, shielding or VT-swapping operations that cost area, power and schedule" [2, §3.2]. He also describes flow options as a tree of trajectories that can't be searched exhaustively, and proposes pruning it with predictors and go-with-the-winners instead [2, §2, Fig. 5–6].
That gives a simple criterion. A policy that is faster end to end and gives up no minimum clock period at the end of GRT dominates. What the earlier stages' periods do along the way is not the objective. My interest is design space exploration on asap7, where detailed route is too expensive to run per arm, so I take the GRT minimum clock period as the signal. That needs the GRT-to-route gap to be similar across arms, not small, and I expect it to shift a little only on congested designs. Fixing GRT at all-out also takes a factor out of the study: P^(S−1) instead of P^S. In ORFS that is 6 + 4 = 10 stage runs to the end of the flow per policy, or 3 + 1 = 4 if the arms stop at GRT.
One data point in that shape, from a study I ran on a synthetic asap7 design (bazel-orfs #958, 12 placement seeds per arm, clock set so repair still had work left):
TNS_END_PERCENT=0halved GRT stage time, −135 s, which clears the noise. Its minimum clock period at GRT moved −0.17 ps, against 1.44 ps the study could resolve. The same study found GRT's minimum clock period scattering 13.8 % (2σ) over seeds on that contended design, so one run per arm resolves nothing.[1] A. B. Kahng, S. Mantik, "Measurement of inherent noise in EDA tools", ISQED 2002. https://vlsicad.ucsd.edu/Publications/Conferences/131/c131.pdf
[2] A. B. Kahng, "Reducing time and effort in IC implementation: a roadmap of challenges and solutions", DAC 2018. https://vlsicad.ucsd.edu/Publications/Conferences/360/c360.pdf
noahwithoutark22 commentedon Oct 9, 2026
Thanks, that's a fair correction. I was reading WNS in ps without relating it to the clock period, and most of these designs end GRT far too negative for the plateau to say much about the regime in the RFC.
For reference,
timing__fmaxin5_1_grt.jsongives the minimum period directly (1/fmax = clock_period − WNS). For the default flow it is: aes 392.3 ps (clock 380), mock-cpu 306 ps (clock 270), jpeg 647 ps (clock 545), tpu 573 ps (clock 200). ethmac is limited by its rx clock at about 398 ps.I'll try rerunning a few of the smaller designs with the clock set so the default flow ends a few percent negative at GRT, and compare the GRT minimum period and stage time between the default flow and
TNS_END_PERCENT=0, with a few seeds per arm. I can't test the plateau rule itself that way, since ORFS has no variable for-max_iterations, so it would be a different policy from the callback. Happy to adjust the plan if you'd rather see something else.oharboe commentedon Oct 9, 2026
Heads up before the rerun:
timing__fmaxis the maximum overall_clocks, and that now includes the virtual I/O clocks (vclk_<name>) ORFS added in June. So 1/timing__fmaxcan be a virtual clock's minimum period rather than the core clock's: on ibex at GRT it reads 807 ps, whilecore_clockis at 970 ps. See #11668. Until that's fixed, usetiming__fmax__clock:<clock>for the real clock. On a design with several real clocks, also keep in mind that the aggregate is the fastest clock, not the one that limits the design.On the plan: would you be interested in checking whether an aggressive termination policy at the earlier repair stages (floorplan, CTS), combined with an all-out repair at GRT, is actually a dominating solution? That means faster end to end with no loss in the GRT minimum period. The arms would differ only before GRT, and GRT would stay at the default in every arm. A
TNS_END_PERCENT=0applied everywhere also changes GRT, which mixes the two questions. A few seeds per arm, with the clock set so the default flow ends a few percent negative at GRT, as you describe.noahwithoutark22 commentedon Oct 9, 2026
Thanks, didn't realise
timing__fmaxpicks up the virtual clocks. I'll switch totiming__fmax__clock:<clock>.And yes, I'd like to try that. I'll lower
TNS_END_PERCENTat floorplan and CTS only and leave GRT at the default in every arm. The clocks will be set so the default flow ends a few percent negative, with a fewGPL_RANDOM_SEEDvalues per arm.TNS_END_PERCENTis a single variable for all three stages, so I'll patch a copy of the flow scripts to make it apply only before GRT. I'll report the minimum period at GRT and the stage times when I have them.maliberty commentedon Oct 9, 2026
@jhkim-pii already has some work pending that will add a low/medium/high effort to allow for earlier stopping (along with better MT support). It should be public for review soon.
oharboe commentedon Oct 9, 2026
@maliberty 🥳 I wrote this up after staring at CoralNPU logs, a happy case for improved policies, meaning lots of futile repair time.
I imagine this will be broadly welcomed improvement!!!
Any insights on effort before grt? can it be low always?
noahwithoutark22 commentedon Oct 9, 2026
These are the results for the early-stage run:
TNS_END_PERCENT=0at floorplan and CTS only, GRT left at the default. I used 3GPL_RANDOM_SEEDs per arm and set the clocks so the default flow ends a few percent negative. Min period isclock_period − WNSfromglobalroute__timing__fmax__clock:<clock>at the end of GRT.clkmrx_clkmtx_clkclkI don't find a dominating solution here.
Keep in mind that these are small designs and only 3 seeds per arm. I compared CPU time rather than wall time because I had 8 flows running at once. One of the aes early=0 runs had the machine to itself, so I left it out of the time numbers.
Once @jhkim-pii's effort levels are public I can rerun this against them, if that would be useful.
Patch, SDC changes and scripts are in this gist: https://gist.github.com/noahwithoutark22/486dd2e6150aadfe82fc75a72ce4baeb
oharboe commentedon Oct 12, 2026
Repair curves from two public designs, from
repair_timing -verbose: XiangShan's XSTile in bazel-orfs (test/coremark_joule/designs/asap7/xiangshan, the parent and its five blocks, one SDC at 473 ps) and ORFS asap7/coralnpu as in #4653 (1,900 ps). Period is SDC period − WNS.Share of the period gain against share of the progress rows; a dot marks a jump on the
finalrow.Minimum period so far against iteration.
finalrow.finalrow.Across 92 runs of these flows, every run that gained 10 % or more of its total in its last 10 % of rows did so on the
finalrow, with-skip_last_gaspset. That row carries the result of phases whose iterations-verbosedoes not print.Nothing obvious sticks out from the curves alone. A knee rule needs more than the table gives today:
finalrow split by phase;🤖 Generated with Claude Code
jhkim-pii commentedon Nov 11, 2026
@oharboe @noahwithoutark22
repair_timing -policy PARALLEL_EVAL -effort [ low | medium | high]has been merged. In many designs, it shows better convergence and it also provides effort control option.Do you think the user callback is still needed? IMO, the callback feature may not be easy to use.
oharboe commentedon Nov 11, 2026
I'd leave the user-callback be until we've had time to try out this new feature and even then I'm not optimistic. I don't think the information to implement a policy exists in looking at the past of a repair convergence curve.
jhkim-pii commentedon Nov 12, 2026
@oharboe The new
PARALLEL_EVALpolicy stops when there is no further WNS/TNS improvement over a set number of iterations. I think this is one of the simplest ways to evaluate the recent convergence trend.However, I'm not sure how best to handle early stopping based on convergence history, as it can vary significantly across designs. Please let me know if you have any ideas or suggestions. Thanks!
oharboe commentedon Nov 12, 2026
So how would it work for a case like this?
I don't think the information for a stopping policy exists in the history in the example above, so I'm not convinced a policy based on history exists.
jhkim-pii commentedon Nov 13, 2026
@oharboe
Compared the two policies.
LEGACY LAST_GAP CRIT_VT_SWAPThe two policies stop the optimization when there is no more WNS/TNS enhancement for a certain iterations.
work meter, which is a measure of machine-independent estimated runtime (in second).coralnpu
XSTile parent
oharboe commentedon Nov 14, 2026
How did you run the above? I am interested in trying it.
jhkim-pii commentedon Nov 14, 2026
In ORFS design config.mk,
Or