Remove hooks for archived early incumbent experiments
This commit is contained in:
parent
64e103b59e
commit
07a2c0e167
4 changed files with 6 additions and 77 deletions
|
|
@ -369,14 +369,12 @@ class _AutomaticRun:
|
|||
break
|
||||
return trials
|
||||
|
||||
def _incumbent_trials(self, options: RoutingOptions, best: Trial, target: int, *, retry_disconnected: bool = True) -> list[Trial]:
|
||||
def _incumbent_trials(self, options: RoutingOptions, best: Trial, target: int) -> list[Trial]:
|
||||
problem = self.problem
|
||||
retained = {net_id: best.run.results_by_net[net_id] for net_id in best.valid_costs}
|
||||
with self._time("plan", policy="incumbent-retry"):
|
||||
blocked = _disconnected_nets(problem, self.board, options, retained)
|
||||
if blocked:
|
||||
if not retry_disconnected:
|
||||
return []
|
||||
seeds = {net_id: result.as_seed() for net_id, result in retained.items()}
|
||||
run = self._run(replace(problem, initial_paths=seeds), options=options, policy="incumbent-retry")
|
||||
stage = RoutingStage(
|
||||
|
|
|
|||
|
|
@ -295,7 +295,6 @@ def _direct_trials(
|
|||
run_route: RouteCall = route_once,
|
||||
score: Scorer = _length,
|
||||
check_trial: CheckTrial | None = None,
|
||||
recover_before_retry: Callable[[Trial], list[Trial]] | None = None,
|
||||
) -> list[Trial]:
|
||||
def check(run: RoutingRunResult, stage: RoutingStage) -> Trial:
|
||||
stage = replace(stage, policy=strategy)
|
||||
|
|
@ -351,11 +350,6 @@ def _direct_trials(
|
|||
if candidate.direct.keys() != locks.direct.keys():
|
||||
retry_locks = candidate
|
||||
if retry_locks is not None:
|
||||
if recover_before_retry is not None:
|
||||
recovered = recover_before_retry(first)
|
||||
trials.extend(recovered)
|
||||
if any(trial.selectable and len(trial.valid_costs) == len(problem.nets) for trial in recovered):
|
||||
return trials
|
||||
trials.append(check(*_route_residual(problem, retry_options, strategy, retry_locks, run_route=run_route)))
|
||||
return trials
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ from inire.tests.routing_benchmarks import (
|
|||
)
|
||||
from inire.tests.routing_corpus import CASE_GROUPS, CORPUS_CASES, automatic_options, profile_options
|
||||
from inire.tests.stress_routing_benchmarks import STRESS_BENCHMARK_CASES
|
||||
from scripts.benchmark_retry_order import _POLICIES, _RetryExperiment
|
||||
from scripts.compare_topological_routing import (
|
||||
_direct_trials,
|
||||
_geometry_json,
|
||||
|
|
@ -140,21 +139,6 @@ def test_stress_residual_dogleg_completes_layout_before_wider_search() -> None:
|
|||
assert set(search.valid_net_ids) == {"branch_west", "branch_east", "lower_rail"}
|
||||
|
||||
|
||||
def test_opt_in_near_port_recovery_finishes_before_the_direct_retry() -> None:
|
||||
(case,) = CASE_GROUPS["stress-crossings-shared-outside-detour"]
|
||||
profile = "corpus-regression"
|
||||
options = automatic_options(profile_options(case, profile), profile)
|
||||
|
||||
report = _RetryExperiment(case.problem, options, _POLICIES["recover-near-port"]).execute().automatic
|
||||
|
||||
assert report is not None
|
||||
assert set(report.verified_net_ids) == {net.net_id for net in case.problem.nets}
|
||||
searches = [stage for stage in report.stages if stage.operation == "search"]
|
||||
assert [stage.policy for stage in searches] == ["direct-probe-near-port", "incumbent-residual"]
|
||||
assert len(searches[0].valid_net_ids) == 7
|
||||
assert report.stages[report.selected_stage].kind == "incumbent-verified"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(("iterations", "probe_limit"), [(1, 1), (3, 2)])
|
||||
def test_automatic_probe_caps_iterations_and_preserves_callback_order(monkeypatch, iterations, probe_limit) -> None:
|
||||
(case,) = CASE_GROUPS["pic-splitter-tree-1x8-ew"]
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ from time import perf_counter
|
|||
from typing import TYPE_CHECKING
|
||||
|
||||
from inire import route
|
||||
from inire.router._automatic import _AutomaticRun, _INITIAL_NODE_LIMIT, _NEAR_PORT_ITERATION_LIMIT
|
||||
from inire.router._routing_policy import LockPlan, _best_trial, _direct_trials, _disconnected_nets, _route_residual
|
||||
from inire.router._automatic import _AutomaticRun, _NEAR_PORT_ITERATION_LIMIT
|
||||
from inire.router._routing_policy import LockPlan, _best_trial, _disconnected_nets, _route_residual
|
||||
from inire.tests.routing_corpus import (
|
||||
CASE_GROUPS,
|
||||
PROFILES,
|
||||
|
|
@ -35,8 +35,6 @@ if TYPE_CHECKING:
|
|||
@dataclass(frozen=True, slots=True)
|
||||
class _RetryPolicy:
|
||||
lattice_limit: int | None = None
|
||||
recovery_stage: str | None = None
|
||||
recovery_remaining: int = 1
|
||||
probe_iterations: int | None = _NEAR_PORT_ITERATION_LIMIT
|
||||
residual_limit: int | None = None
|
||||
residual_after_fallback: bool = False
|
||||
|
|
@ -45,11 +43,6 @@ class _RetryPolicy:
|
|||
_POLICIES = {
|
||||
"baseline": _RetryPolicy(),
|
||||
**{f"lattice-{limit}": _RetryPolicy(lattice_limit=limit) for limit in (500, 750, 1000, 1500, 2000)},
|
||||
"recover-lookahead": _RetryPolicy(recovery_stage="direct-lookahead-retry"),
|
||||
"recover-near-port": _RetryPolicy(recovery_stage="direct-probe-near-port", recovery_remaining=2),
|
||||
"lattice-1500-and-recover-near-port": _RetryPolicy(
|
||||
lattice_limit=1500, recovery_stage="direct-probe-near-port", recovery_remaining=2
|
||||
),
|
||||
**{f"probe-iterations-{count}": _RetryPolicy(probe_iterations=count) for count in (1, 2, 3)},
|
||||
"probe-full-budget": _RetryPolicy(probe_iterations=None),
|
||||
**{f"residual-{limit}": _RetryPolicy(residual_limit=limit) for limit in (1500, 3000)},
|
||||
|
|
@ -72,7 +65,6 @@ class _RetryExperiment(_AutomaticRun):
|
|||
})
|
||||
|
||||
def _search_trials(self, trials: list[Trial], target: int) -> None:
|
||||
self.routing_bound = target
|
||||
super()._search_trials(trials, target)
|
||||
limit = self.retry_policy.residual_limit
|
||||
if (
|
||||
|
|
@ -91,34 +83,6 @@ class _RetryExperiment(_AutomaticRun):
|
|||
options = replace(self.options, refinement=replace(self.options.refinement, enabled=False))
|
||||
trials.extend(self._widen_residual(options, retained, limit, target, policy="late-bounded-residual", check_connectivity=True))
|
||||
|
||||
def _recover_before_direct_retry(self, attempt: Trial, options: RoutingOptions) -> list[Trial]:
|
||||
target = len(self.problem.nets)
|
||||
verified = len(attempt.valid_costs)
|
||||
if (
|
||||
self.routing_bound < target
|
||||
or target <= 2
|
||||
or self.problem.initial_paths
|
||||
or not 0 < target - verified <= self.retry_policy.recovery_remaining
|
||||
or 3 * verified < 2 * target
|
||||
):
|
||||
return []
|
||||
|
||||
seeded = replace(
|
||||
options,
|
||||
search=replace(options.search, node_limit=min(_INITIAL_NODE_LIMIT, self.options.search.node_limit)),
|
||||
congestion=replace(options.congestion, max_iterations=min(2, options.congestion.max_iterations)),
|
||||
topology=replace(options.topology, mode="seed"),
|
||||
)
|
||||
started, first_run = perf_counter(), len(self.metrics)
|
||||
recovered = self._incumbent_trials(seeded, attempt, target, retry_disconnected=False)
|
||||
complete = any(candidate.selectable and len(candidate.valid_costs) == target for candidate in recovered)
|
||||
outcome = "incomplete" if recovered else "disconnected"
|
||||
self._record_retry("incumbent-recovery", "complete" if complete else outcome, started, first_run)
|
||||
if complete:
|
||||
return recovered
|
||||
# Keep failed experimental work visible without changing the fallback incumbent.
|
||||
return [replace(candidate, selection="incomplete-layout") for candidate in recovered]
|
||||
|
||||
def _direct(self, options: RoutingOptions, policy: str) -> list[Trial]:
|
||||
if policy == "direct-probe-near-port":
|
||||
cap = self.retry_policy.probe_iterations
|
||||
|
|
@ -126,18 +90,7 @@ class _RetryExperiment(_AutomaticRun):
|
|||
iterations = configured if cap is None else min(configured, cap)
|
||||
if iterations != options.congestion.max_iterations:
|
||||
options = replace(options, congestion=replace(options.congestion, max_iterations=iterations))
|
||||
if policy != self.retry_policy.recovery_stage:
|
||||
return super()._direct(options, policy)
|
||||
with self._time("plan", planner="direct", policy=policy):
|
||||
return _direct_trials(
|
||||
self.problem,
|
||||
self.board,
|
||||
options,
|
||||
policy,
|
||||
run_route=partial(self._run, policy=policy),
|
||||
check_trial=self._trial,
|
||||
recover_before_retry=partial(self._recover_before_direct_retry, options=options),
|
||||
)
|
||||
|
||||
def _seed_recovery_trials(self, options: RoutingOptions, trials: list[Trial], target: int) -> None:
|
||||
limit = self.retry_policy.lattice_limit
|
||||
|
|
@ -158,8 +111,8 @@ class _RetryExperiment(_AutomaticRun):
|
|||
trials[-1] = replace(trials[-1], selection="incomplete-layout")
|
||||
super()._seed_recovery_trials(options, trials, target)
|
||||
|
||||
def _incumbent_trials(self, options: RoutingOptions, best: Trial, target: int, *, retry_disconnected: bool = True) -> list[Trial]:
|
||||
trials = super()._incumbent_trials(options, best, target, retry_disconnected=retry_disconnected)
|
||||
def _incumbent_trials(self, options: RoutingOptions, best: Trial, target: int) -> list[Trial]:
|
||||
trials = super()._incumbent_trials(options, best, target)
|
||||
limit = self.retry_policy.residual_limit
|
||||
if (
|
||||
limit is None
|
||||
|
|
|
|||
Loading…
Reference in a new issue