inire/docs/routing-diagnostics.md

7.4 KiB

Routing diagnostics and metrics

Start with the symptom. For layout or option changes, use the user troubleshooting guide.

Automatic reports

  • A net is missing. Compare the verified count with max_routed. In overloaded-gate, capacity_limit.cut_x locates the cut that fits three of four requested routes. Below the bound, read stages for skipped or locked nets and for the attempt where coverage stopped increasing. Run the overloaded-gate fixture

  • The chosen route changed. Start at stages[selected_stage]. The planner identifies the source of the proposal and mode identifies the worker, so a bundle seed can be checked by an off worker. Use planner_rejections for constructive candidates that never reached selection. Report definitions

  • The run slowed down. Group exclusive timings by policy and operation, including failed attempts. duration_s also includes orchestration. Detailed traces, corridor reports, and expanded states describe the selected attempt when present. Check run.metrics and stage data for work across attempts. Benchmark profiles

Route metrics

Pair each counter with a question about the work. Use a repeated wall-time comparison to confirm the effect. Higher counts can reflect more useful search or coverage.

Observation What to check next
More expansions and a later selected stage Compare the node counts and verified IDs of each stage. The original work may have moved into a fallback.
Similar expansions, more search time Check ray_cast_calls* and ray_cast_exact_geometry_checks for visibility work. Compare dynamic congestion_candidate_ids with congestion_exact_pair_checks to see how much candidate geometry reaches exact tests.
Verification dominates Compare verify_path_report_calls with verify_static_buffer_ops and verify_dynamic_exact_pair_checks. This can distinguish repeated path checks from expensive checks of the same paths.
Refinement takes longer Compare refinement_windows_considered, refinement_candidates_verified, and refinement_candidates_accepted. Check whether the added windows buy a better path before enlarging the default budget.
Attempts reach targets while verified coverage stays flat Compare iteration_conflict_edges and nets_carried_forward. Inspect pair-local attempts and accepts after congestion stops. pair_local_search_nodes_expanded counts searches that returned a locally valid pair, so consult the attempt count to see failed searches.

nets_routed and nets_reached_target count attempts. To count final successes use result.is_valid or verified_net_ids. Fields ending in _total_ns measure durations and can vary between identical runs. Use the counter schema for exact field names and the example snapshot to investigate earlier observations. Counter schema · Historical example snapshot · Snapshot JSON

Traces

Enable the DiagnosticsOptions flag for the question you want to answer.

Question Flag and result
Which net consumed an iteration's budget? capture_iteration_trace records iteration_trace. Inspect per-net net_attempts for expansions, pruning, congestion calls, and seed usage.
Which two routes overlap after re-verification? capture_conflict_trace records conflict_trace. Use the dynamic conflict edges to find the pair and the component indices to locate the overlap.
Why was a nearby detour rejected? capture_frontier_trace records frontier_trace for reached-but-colliding nets. Look at the sampled states and prune reasons near the final overlap. The analysis leaves the selected route fixed.
What did the last unresolved iteration hand to pair-local repair? capture_pre_pair_frontier_trace records pre_pair_frontier_trace. Check reroute order, conflict edges, and per-net attempt work immediately before repair.
Where did the router explore? capture_expanded records expanded_nodes for plotting. See the fan-out example.

Follow a late conflict into pair-local repair

Capture the no-warm-start fan-out scenario from the repository root.

python -m scripts.record_iteration_trace --scenario example_07_large_scale_routing_no_warm_start \
    --include-performance-only --output-dir /tmp/inire-trace
  1. Open the generated iteration_trace.md. Compare the last iteration's completed count and conflict edges with the final result summary. In the recorded example, the last iteration had six completed nets and two conflict edges.
  2. Inspect the final result and pair-local counters in iteration_trace.json. All ten nets verified after repair in the recorded run. The last congestion iteration alone misses this improvement.
  3. To see which paths overlapped, capture the same scenario with scripts.record_conflict_trace. Compare restored_best with final. Use the pre-pair trace to investigate reroute order and per-net work before repair. Recorded iteration trace · Conflict trace · Pre-pair trace

Use an iteration_callback for live progress across automatic attempts and the final result for coverage. Callback API

Reproduce and compare

  1. Start with a fixture that shows the symptom. Capture the same options at both revisions. For a behavior-preserving change, exact parity checks paths, scores, stage metadata, stable counters, and coverage. Add --callbacks and --diagnostics to both captures when changing callback or trace behavior.
  2. For a policy change, check verified IDs, paths, and per-net costs first. Advance to the full corpus and relevant holdouts once the focused case behaves as intended. Use interleaved repeats for timing and name the boards that get slower. Time inside failed retries can explain a tail regression that the median obscures.
  3. If the run gets slower without more expansions, check the operation timings and use the counters above to pick a narrower trace or profile.
python -m scripts.routing_benchmark_parity capture /tmp/routing-before.json --case stress
# Use the same options on the changed revision.
python -m scripts.routing_benchmark_parity capture /tmp/routing-after.json --case stress
python -m scripts.routing_benchmark_parity compare /tmp/routing-before.json /tmp/routing-after.json

Use scripts.record_iteration_trace and scripts.record_pre_pair_frontier_trace to inspect a late conflict. Use scripts.record_conflict_trace and scripts.record_frontier_trace to locate an overlap and inspect rejected moves near it. Pass --output-dir /tmp/inire-trace for a scratch capture. The trace writers support --scenario for an individual built-in case and --include-performance-only for the heavier cases.

For isolated timing gates, run INIRE_RUN_PERFORMANCE=1 python -m pytest -q inire/tests/test_example_performance.py. Use scripts.record_performance_baseline with --output-dir to record an example snapshot and scripts.diff_performance_baseline with --baseline and --metric to compare a fresh run. The pair-local characterization and optimization log preserve earlier experiments.