rsz: `repair_timing -setup` main phase exits on "no TNS progress" with violating endpoints never visited

Aperta
#12,563 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@precisionmoon ci sta già lavorando.

Dal 3/12/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

bug rsz
Description

repair_timing -setup can end its main (LEGACY) phase while endpoints with negative slack are still waiting in its endpoint list, unvisited. The remaining endpoints are repairable: calling repair_timing -setup again with the same arguments repairs them. The cause is how SetupLegacyBase::terminateProgress measures progress, described below from the source.

This was seen on a large private design, on global-route parasitics, with a positive -setup_margin. I cannot share the design, and I do not have a small public reproducer. The analysis below is from the source alone, so it can be checked without one.

Version

26Q4 tag (c4d317e4fa). The same logic is on master at f2bd51d859, apart from the guard discussed under "What master already covers".

Mechanism

All references are to src/rsz/src/policy/ at the 26Q4 tag.

  1. The list is built once per phase. SetupLegacyPolicy::initializeMainRepair calls collectViolatingEndpoints(setup_slack_margin), which returns every endpoint with slack under the margin, sorted worst first (RepairTargetCollector::collectViolatingEndpoints, stable_sort by slack). runMainRepairLoop walks that list in order. The list is not refreshed while the phase runs.

  2. Every visit costs an iteration, including a visit that does nothing. repairEndpoint increments main_state.opto_iteration at the top of its loop and only then tests whether the endpoint already meets the margin ("Endpoint slack ... meets slack margin ..., done"). A fix made for an earlier endpoint often lifts later endpoints that share its logic. Each of those, when its turn comes, spends one iteration and changes nothing.

  3. Progress is the TNS gained per 100 iterations, as a fraction of the phase's starting TNS. In SetupLegacyBase::terminateProgress:

    if (iteration % opto_large_interval_ == 0) {   // 1000
      fix_rate_threshold *= 2.0;                   // starts at inc_fix_rate_threshold_ = 0.0001
    }
    if (iteration % opto_small_interval_ == 0) {   // 100
      float curr_tns = sta_->totalNegativeSlack(max_);
      float inc_fix_rate = (prev_tns - curr_tns) / initial_tns;
      prev_tns = curr_tns;
      if (iteration > 1000 && inc_fix_rate < fix_rate_threshold) {
        ...
        return true;
      }
    }
    

    initial_tns is the TNS when the phase started. After iteration 1,000 the phase must gain 0.02% of that TNS in every 100 iterations, 0.04% after iteration 2,000, and so on. One failed check abandons the endpoint in work (restoreEndpointState); two failed checks in a row set two_cons_terminations and runMainRepairLoop exits ("Exiting due to no TNS progress for two opto cycles").

  4. Put together. On a design with several thousand endpoints in the list and a large starting TNS:

    • The required gain is an absolute amount fixed by the size of the problem at the start. It does not shrink as the remaining TNS shrinks, and it doubles every 1,000 iterations.
    • When the walk reaches a stretch of the list whose endpoints earlier fixes have already lifted, it spends one iteration on each and gains no TNS. Two hundred such endpoints in a row are two failed checks.
    • The phase then exits. Everything later in the list is never visited, including endpoints that are still negative, because the list order is the slack order from before any repair.
    • With a setup margin there is a second effect: totalNegativeSlack is measured against zero, so lifting an endpoint from zero to the margin is not progress on this measure even though that endpoint is in the list.

    In the case I saw, the main phase exited after visiting a minority of its list. Nearly every visited endpoint had ended "meets slack margin, done". WNS was still negative and most of the list was unvisited.

  5. The later phases inherit the same measure. SetupLastGaspPolicy takes initial_tns and the iteration counter from the shared setup_context_, so it is checked from its first hundredth iteration against the main phase's starting TNS, and exits the same way.

Why a second call succeeds

A second repair_timing -setup with the same arguments:

  • collects and sorts a fresh list, so endpoints that already meet the margin are gone and the remaining negative ones are at the front;
  • takes a fresh, much smaller starting TNS, so the same fraction is a small absolute amount;
  • restarts the iteration counter, so no check runs during its first 1,000 iterations.

In the case I saw, the second call brought TNS to zero and a third brought every endpoint to the margin. Naming the main phase twice in -phases in one call does not have the same effect: the second LEGACY phase re-collects its list and its starting TNS, but the call's iteration counter carries over (setup_context_.iteration), so it is checked from its first hundredth iteration and exits early again.

Nothing on the command line reaches this rule. inc_fix_rate_threshold_, opto_small_interval_ and opto_large_interval_ are constants in SetupLegacyBase.hh; -max_iterations and -max_passes are caps only.

What master already covers

Master (f2bd51d859) adds this to terminateProgress:

// TNS only sees true violations. Once it is 0, any remaining work targets
// the setup slack margin, which the fix rate cannot measure.
if (config_.setup_slack_margin > 0.0f
    && (initial_tns >= 0.0f || curr_tns >= 0.0f)) {
  prev_tns = curr_tns;
  return false;
}

That fixes the exit once TNS has reached zero while endpoints remain between zero and the margin. It does not change the case in this issue, where TNS is still negative: the threshold is still a fraction of the phase's starting TNS, the list is still walked in its initial order, and already-met endpoints still spend iterations. The main loop in SetupLegacyPolicy.cc is the same on master.

Expected behavior

A phase should not exit on low progress while endpoints in its list that are still violating have not been visited, or at least should not count visits to already-met endpoints as failed progress.

Suggested direction

Any one of these would remove the early exit; they are listed from smallest change to largest.

  1. Do not count a visit that ends at the "meets slack margin" test as an iteration, or skip such endpoints before beginEndpointRepair. Then a stretch of already-lifted endpoints cannot produce failed checks by itself.
  2. Measure the gain against the TNS that remains (prev_tns) instead of the phase's starting TNS, so the required rate follows the problem as it shrinks.
  3. When two checks in a row fail, re-collect and re-sort the endpoint list and continue if the pass over the old list repaired anything; exit only when a whole pass gains nothing. This is what a second call does today.
  4. Use a margin-aware measure (the sum of slack under the margin, or the count of endpoints under it) in place of totalNegativeSlack, which would also generalize the guard master added.

A smaller, separate point: giving each phase its own iteration baseline for the iteration > 1000 test would make a repeated phase in -phases behave like a repeated call.

How to observe

With set_debug_level RSZ repair_setup 1, the main phase prints "Exiting at iteration N because incr fix rate X% is < Y% [endpt i/n]" twice, 100 iterations apart, with i well below n, then "Exiting due to no TNS progress for two opto cycles". The command ends with [WARNING RSZ-0062] Unable to repair all setup violations. A second identical call then repairs endpoints the first one never visited.

Related
  • #11746 added the guard quoted above.
  • #11684 discusses ending a phase earlier, at its knee. This issue is the other side of the same rule: the current measure can end a phase before it has looked at endpoints that are still violating and cheap to fix.
Lingua principale
Verilog
Stelle
3.3k
Fork
1.1k
Merge medio
3g 11h
PR unite (30g)
247

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di The-OpenROAD-Project/OpenROAD

Tutte le issue di The-OpenROAD-Project/OpenROAD

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.