Skip to content

Add post-solve region cost optimizer - #166

Open
seveibar wants to merge 21 commits into
mainfrom
agent/add-unravel-region-cost-optimizer
Open

Add post-solve region cost optimizer#166
seveibar wants to merge 21 commits into
mainfrom
agent/add-unravel-region-cost-optimizer

Conversation

@seveibar

@seveibar seveibar commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add UnravelTinyHyperGraphSolver as an unconditional post-solve optimization stage
  • minimize peak region cost first and total region cost second with topology-preserving boundary permutations, single-route replacement, and dependency-driven two-route ejection
  • preserve fixed solved copper as congestion, collision, and boundary-order anchors while optimizing every movable route
  • validate replacement geometry against foreign-terminal keepouts and exact routing/downstream-risk envelopes
  • relink the final solution toward the solved input, removing speculative lane displacements and route replacements that are no longer needed to hold the achieved peak

Engineering invariants

The optimizer has no dataset classifier, sample ID, density gate, route-count gate, target-reduction cutoff, mutation cap, hot-region cap, reroute cap, or detour cap. Every solved graph executes the same stages. Optional resource limits remain explicit caller controls.

The search follows first-order descent: it exhausts boundary untwists, searches single-route replacements, and opens the much larger pair-ejection neighborhood only at a one-route local optimum. This reduced Pipeline7 sample 13's pair search from 5.88 million to 120 thousand iterations without a size threshold or skipped pipeline stage.

Peak-plateau moves remain available to unlock later bottleneck reductions. Once the final peak is known, reverse path relinking tentatively removes accepted boundary and reroute mutations. A removal is committed only when it:

  • preserves the achieved peak region cost
  • does not increase region occupancy or wirelength from the current state
  • does not add route segments or layer transitions
  • remains within the original solved graph's routing-risk, segment-risk, downstream-risk, and endpoint-clearance envelope

If a search never lowers the peak, the exact solved input assignments and their original order are restored.

Standalone benchmark

./benchmark.sh

Metric Baseline Optimized Reduction
P50 max region cost 1.440 0.589 59.1%
P95 max region cost 3.464 1.669 51.8%

All 8 committed SRJ18 Pipeline7 hypergraphs completed, preserved every route, and improved. The requested P50/P95 50% target is met.

Pipeline7 profiling

  • SRJ18 sample 3: completes in 10.4s and passes relaxed DRC; reverse relinking removes the unrelated plateau swap that previously introduced a same-net via regression.
  • SRJ18 sample 13: retains a 33.8% peak-cost reduction (4.277 to 2.831), and downstream trace simplification now finishes in 12.3s instead of remaining in same-net via merging past 60s. The complete Pipeline7 sample finishes in 79.2s rather than timing out. Its pre-existing dense-layout DRC failures remain; this change does not claim to repair them.

No downstream pipeline branch, detailed-router threshold, sample-specific condition, or geometric-connectivity inference is used. The focused universal Pipeline7 integration is in tscircuit/tscircuit-autorouter#2115.

Validation

  • bun test — 144 passed, 0 failed
  • bunx tsc --noEmit
  • bun run format:check
  • git diff --check
  • ./benchmark.sh — 100% completion and improvement; P50/P95 target met

@vercel

vercel Bot commented Aug 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tiny-hypergraph Ready Ready Preview Aug 15, 2026 6:12am

Request Review

@tscircuitbot

Copy link
Copy Markdown

Benchmark This PR

Run benchmarks by commenting on this PR:

/benchmark [benchmark.sh args...]
/benchmark --dataset <hg07|srj18> --limit <n> --solver <core|poly> --families <default|default+deep|all> --concurrency <n|auto>

Everything after /benchmark is forwarded directly to ./benchmark.sh.
Every command runs current main and the PR head sequentially on the same Blacksmith machine, then reports their results side by side.

Examples:

  • /benchmark -> all committed completed SRJ18 Pipeline7 cases, core solver
  • /benchmark --limit 4 -> first four committed Pipeline7 cases
  • /benchmark --dataset srj18 --concurrency auto -> srj18 samples with runner CPU-count concurrency
  • /benchmark --sample sample003 -> one committed SRJ18 Pipeline7 case
  • /benchmark --dataset hg07 --limit 20 --solver poly -> first 20 hg07 samples with the poly solver
  • /benchmark --dataset hg07 --limit 40 --families default+deep -> first 40 hg07 samples with deeper candidate families

Any PR whose title contains [BENCHMARK TEST] will automatically run the benchmark workflow on PR updates.

@seveibar

Copy link
Copy Markdown
Contributor Author

/benchmark --dataset 18 --same-machine

@tscircuitbot

tscircuitbot commented Aug 13, 2026

Copy link
Copy Markdown

Tiny Hypergraph Same Machine Benchmark Failed

Main c60c552 and PR ee46c15 ran sequentially on blacksmith-01kzye9awvjptjn5kt5ja14agk-32vcpu with identical arguments.

Run Dataset Solver Families Success Routes Final Cost Avg Hops P50 P95
Main n/a n/a n/a n/a n/a n/a n/a n/a n/a
PR n/a n/a n/a n/a n/a n/a n/a n/a n/a
Main Branch Details
(the paired benchmark did not produce a main report)
PR Details

(benchmark results were not produced)

Workflow: View run
Artifact: https://github.com/tscircuit/tiny-hypergraph/actions/runs/31742899747

@seveibar

Copy link
Copy Markdown
Contributor Author

/benchmark --dataset 18 --same-machine

@tscircuitbot

tscircuitbot commented Aug 13, 2026

Copy link
Copy Markdown

Tiny Hypergraph Same Machine Benchmark Failed

Main c60c552 and PR ee46c15 ran sequentially on blacksmith-01kzyedm7sxbcremm6909gpfh3-32vcpu with identical arguments.

Run Dataset Solver Families Success Routes Final Cost Avg Hops P50 P95
Main n/a n/a n/a n/a n/a n/a n/a n/a n/a
PR n/a n/a n/a n/a n/a n/a n/a n/a n/a
Main Branch Details
(the paired benchmark did not produce a main report)
PR Details

(benchmark results were not produced)

Workflow: View run
Artifact: https://github.com/tscircuit/tiny-hypergraph/actions/runs/31743084590

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants