Skip to content

RFC: repair_timing, a user callback to end a phase at its knee #11684

Open

Description

@oharboe

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_phase or stop, 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 terminateProgress rule 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

  1. changed the title [-]repair_timing: let the user end a phase at its knee[/-] [+]RFC: repair_timing, a user callback to end a phase at its knee[/+] on Oct 9, 2026
  2. noahwithoutark22 commented on Oct 9, 2026

    @noahwithoutark22

    I ran the plateau rule from the RFC on other ORFS asap7 designs (aes, jpeg, ethmac, tpu, mock-cpu), using the openroad/orfs Docker image built 7 Oct 2026 with default settings. The exact image digest, script and CSV are in this gist: https://gist.github.com/noahwithoutark22/e750168482f608d3b75be848b36d41c0

    Rule: 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:

    design stage rows rows after knee WNS given up TNS given up
    aes CTS 95 68% 0.0 ps 7.6%
    aes GRT 184 24% 0.0 ps 3.6%
    jpeg CTS 287 90% 0.7 ps 4.9%
    jpeg GRT 392 89% 0.0 ps 4.5%
    ethmac CTS 46 37% 0.0 ps 1.2%
    ethmac GRT 110 32% 0.0 ps 1.2%
    tpu CTS 415 knee only at the last row 0.0 ps 0.0%
    tpu GRT 370 71% 0.0 ps 1.8%

    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.

  3. oharboe commented on Oct 9, 2026

    @oharboe
    CollaboratorAuthor

    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:

    • One repair stage at a time (default policy elsewhere): changing stage i means rerunning every stage from i to the end. That is P·Σᵢ(stages from i to end), so O(P·S²) when repair stages are spread through the flow.
    • Interactions (any policy at any stage): P^S flows. Sharing common prefixes brings this to about P^S·P/(P−1) stage runs, which is still exponential.
    • Noise: everything is multiplied by the repeats needed to resolve the difference. Kahng & Mantik measured a random seed moving a result by about ±0.2 %, and renaming nets moving it by more than 7 % [1]. A policy that changes which cells get inserted perturbs the naming.

    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=0 halved 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

  4. noahwithoutark22 commented on Oct 9, 2026

    @noahwithoutark22

    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__fmax in 5_1_grt.json gives 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.

  5. oharboe commented on Oct 9, 2026

    @oharboe
    CollaboratorAuthor

    Heads up before the rerun: timing__fmax is the maximum over all_clocks, and that now includes the virtual I/O clocks (vclk_<name>) ORFS added in June. So 1/timing__fmax can be a virtual clock's minimum period rather than the core clock's: on ibex at GRT it reads 807 ps, while core_clock is at 970 ps. See #11668. Until that's fixed, use timing__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=0 applied 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.

  6. noahwithoutark22 commented on Oct 9, 2026

    @noahwithoutark22

    Thanks, didn't realise timing__fmax picks up the virtual clocks. I'll switch to timing__fmax__clock:<clock>.

    And yes, I'd like to try that. I'll lower TNS_END_PERCENT at 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 few GPL_RANDOM_SEED values per arm. TNS_END_PERCENT is 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.

  7. maliberty commented on Oct 9, 2026

    @maliberty
    Member

    @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.

  8. oharboe commented on Oct 9, 2026

    @oharboe
    CollaboratorAuthor

    @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?

  9. noahwithoutark22 commented on Oct 9, 2026

    @noahwithoutark22

    These are the results for the early-stage run: TNS_END_PERCENT=0 at floorplan and CTS only, GRT left at the default. I used 3 GPL_RANDOM_SEEDs per arm and set the clocks so the default flow ends a few percent negative. Min period is clock_period − WNS from globalroute__timing__fmax__clock:<clock> at the end of GRT.

    design / clock default (mean, range) early=0 (mean, range)
    aes clk 389.9 ps (3.6) 397.4 ps (2.6)
    ethmac mrx_clk 397.8 ps (6.0) 395.6 ps (6.2)
    ethmac mtx_clk 307.2 ps (6.8) 307.0 ps (14.8)
    mock-cpu clk 303.5 ps (10.0) 306.0 ps (6.6)

    I don't find a dominating solution here.

    • aes is about 2 % worse with the early cut. All three early=0 runs (396.1 to 398.8 ps) land above all three default runs (388.7 to 392.3 ps), so it doesn't look like seed noise.
    • ethmac and mock-cpu are inside the seed-to-seed spread.
    • On time, the only real saving is aes floorplan, roughly 10 s of CPU down to 3 s. CTS didn't change, and total CPU on ethmac and mock-cpu is the same in both arms. GRT is 70 to 90 % of the CPU time on these designs, so trimming repair before GRT doesn't buy much.

    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

  10. oharboe commented on Oct 12, 2026

    @oharboe
    CollaboratorAuthor

    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 final row.

    Minimum period so far against iteration.

    • XSTile parent, global route: 3,276 → 2,480 ps over the table, a steady descent; 90 % of the gain by 40 % of the rows, nothing in the last third.
    • coralnpu, global route: 64 % of its gain in the first 8 % of the rows, flat for the rest, then 36 % on the final row.
    • CTS, the XSTile blocks: about 80 % within the first fifth of the rows, a long plateau, then 17–22 % of the gain on the final row.

    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 final row, with -skip_last_gasp set. That row carries the result of phases whose iterations -verbose does not print.

    Nothing obvious sticks out from the curves alone. A knee rule needs more than the table gives today:

    • which phase each row belongs to, and the final row split by phase;
    • a timestamp per row, so a plateau is measured in seconds, not rows;
    • per row, the move kinds accepted and whether the worst endpoint changed.

    🤖 Generated with Claude Code

    Image Image
  11. jhkim-pii commented on Nov 11, 2026

    @jhkim-pii
    Contributor

    @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.

  12. oharboe commented on Nov 11, 2026

    @oharboe
    CollaboratorAuthor

    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.

  13. jhkim-pii commented on Nov 12, 2026

    @jhkim-pii
    Contributor

    @oharboe The new PARALLEL_EVAL policy 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!

  14. oharboe commented on Nov 12, 2026

    @oharboe
    CollaboratorAuthor

    @oharboe The new PARALLEL_EVAL policy 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.

    So how would it work for a case like this?

    image

    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!

    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.

  15. jhkim-pii commented on Nov 13, 2026

    @jhkim-pii
    Contributor

    @oharboe

    Compared the two policies.

    • LLV (default policy): LEGACY LAST_GAP CRIT_VT_SWAP
    • PARALL_EVAL (new): Typically, this showsbetter QoR and runtime.

    The two policies stop the optimization when there is no more WNS/TNS enhancement for a certain iterations.

    • LLV: After iteration 1,000, checks TNS every 100 iterations. Two consecutive checks below 0.02% of initial |TNS| ended LEGACY: iterations 1,100/1,200 for XSTile and 1,800/1,900 for coralnpu. The last gasp and critical VT swap phases ran afterward.
    • PARALLEL_EVAL: After entering the WNS tail, stops when weighted tail work exceeds 4× pre-tail work, with a minimum budget of 60 reference seconds. Coralnpu used 60.389/60; XSTile used 1072.835/1064.447. PARALLEL_EVAL uses work meter, which is a measure of machine-independent estimated runtime (in second).

    coralnpu

    image image

    XSTile parent

    image image
  16. oharboe commented on Nov 14, 2026

    @oharboe
    CollaboratorAuthor

    How did you run the above? I am interested in trying it.

  17. jhkim-pii commented on Nov 14, 2026

    @jhkim-pii
    Contributor

    In ORFS design config.mk,

    export SETUP_REPAIR_PHASES = PARALLEL_EVAL
    

    Or

    repair_timing -policy PARALLEL_EVAL ...
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

rsz

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions