Initial buildout
49
docs/architecture.md
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
# Router architecture
|
||||
|
||||
`route()` uses the same worker to search, replay seeds, and verify paths. An explicit mode configures the worker directly. Automatic routing sets a coverage target and tries different plans or worker settings.
|
||||
|
||||
## Automatic routing
|
||||
|
||||

|
||||
|
||||
Follow the left column while coverage is below the target. Reaching the target skips the remaining attempts. If the attempts run out, the router selects the best layout it verified.
|
||||
|
||||
1. **Set a coverage target.** Conflicting aligned port faces and [track capacity](../inire/router/_capacity.py#L29) at rectangular cuts can bound how many nets fit.
|
||||
2. **Try constructive plans.** Bundles assign ordered tracks, columns schedule turns, and compact planners fit short links. Each plan supplies seeds for the worker to verify.
|
||||
3. **Search for missing routes.** Early attempts use small budgets and can hold verified routes fixed. When a column plan stalls, try separated channels or a shared bypass around the keepouts. If the locks cut off a port, retry with movable seeds or different lanes. With one net left, try a verified detour around the locked paths, including incumbents found by the seed fallback. Lattice search handles custom outlines and proxies and can retry unresolved nets after corridor-guided attempts.
|
||||
4. **Select and refine.** Prefer higher verified coverage. Compare cost on matching verified net IDs. Refinement can replace the selected layout only if those IDs remain verified.
|
||||
|
||||
### Example of a poor lock
|
||||
|
||||
Holding the straight trunk fixed in `stress-retry-straight-decoy` blocks both vertical routes. The `residual-dogleg` stage finishes the trunk with a four-turn detour, bringing coverage to four out of four. When changing lock ordering, check which stage finishes the trunk.
|
||||
|
||||
- [Trunk detour figure](../examples/advanced.md#trunk-that-detours-around-branches)
|
||||
- [Single-case benchmark](benchmarks.md#run-a-benchmark)
|
||||
|
||||
## Detailed search and congestion
|
||||
|
||||
- **Propose moves.** Weighted A* searches snapped positions and headings. Rays, corners, and corridor waypoints suggest straight endpoints. Admission checks the footprint, cost, and state dominance.
|
||||
- **Prune histories.** The closed set groups arrivals by position and heading. Paths with different final straights or footprints can have different valid continuations, so pruning can discard an alternative.
|
||||
- **Recheck installed paths.** A later route can conflict with one installed earlier. After each iteration, the driver rechecks the installed set and ranks snapshots by completed nets, then conflicts and dynamic collisions.
|
||||
- **Repair small conflict sets.** After restoring the best iteration, try rerouting up to two isolated pairs against the routes held fixed.
|
||||
|
||||
## Geometry and refinement
|
||||
|
||||
- **Replay.** Results carry the requested net and the effective net with resolved ports. Seed replay builds physical geometry from the effective start port using the same endpoint and bend calculations as search.
|
||||
- **Verify.** Search uses collision proxies. Verification checks the physical polygons against the board, keepouts, and other paths. In zero-node replay, verify each path's own geometry first, then add cross-net conflicts. Fixed polygons retain their vertices and enter geometric operations at full coordinate precision.
|
||||
- **Refine.** Try replacing sections with at least four quarter turns. Rank detours before building their polygons and verify the complete updated layout.
|
||||
|
||||
## Validate a change
|
||||
|
||||
| If you change | What to check | Where to start |
|
||||
| --- | --- | --- |
|
||||
| Worker setup or seed replay | Resolved ports and path geometry after replay. | [Worker entry point](../inire/router/_stack.py#L65), [placement recipes](user/route-a-layout.md#save-a-placement-recipe) |
|
||||
| Stage order or budgets | Which stage wins and whether work reappears in a later attempt. Include tight passages and preplaced crossings. | [Constructive trials](../inire/router/_automatic.py#L228), [search trials](../inire/router/_automatic.py#L488) |
|
||||
| Locks or candidate acceptance | The verified IDs and their paths after the complete layout is checked. | [Direct trials](../inire/router/_routing_policy.py#L288), [trial selection](../inire/router/_routing_policy.py#L324) |
|
||||
| Corridor or seed allocation | Coverage through shared openings and search work when a corridor reaches the wrong lane or leaves too little turn room. | [Corridor planning and realization](topological-routing.md#corridor-planning-and-realization) |
|
||||
| Moves or reroute scheduling | Which moves reach admission and which nets are retried. | [Move generation](../inire/router/_astar_moves.py), [reroute scheduling](../inire/router/_congestion_policy.py#L99) |
|
||||
| Collision or caching | Clearance and boundary decisions for both physical and proxy shapes. Compare candidate counts and exact checks along with time. | [Physical checks](../inire/geometry/collision.py#L687), [work counters](routing-diagnostics.md#route-metrics) |
|
||||
| Pair-local repair | Coverage and conflict edges before repair, plus the final installed geometry. | [Pair-local search](../inire/router/_pair_local.py), [pair repair trace](routing-diagnostics.md#follow-a-late-conflict-into-pair-local-repair) |
|
||||
| Cost or refinement | Per-net costs on equal verified ID sets and validity after the final check. | [Path refinement](../inire/router/refiner.py), [refinement handoff](../inire/router/_automatic.py#L610) |
|
||||
|
||||
Use [benchmark profiles](benchmarks.md#choose-a-profile) for policy comparisons and [route results and traces](routing-diagnostics.md#reproduce-and-compare) for behavior-preserving changes.
|
||||
61
docs/benchmark-fixtures.md
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
# Benchmark fixtures
|
||||
|
||||
- [Benchmark cases](benchmarks.md#choose-a-case)
|
||||
- [Corpus registry and profiles](../inire/tests/routing_corpus.py)
|
||||
|
||||
## Micron-scale routing cases
|
||||
|
||||
The `expanded` group adds 75 deterministic, unseeded boards with independently constructed reference routes. The authored grid units are 10, 100, 250, 500, and 1000 nm. Bend radii span 10–100 µm and trace widths span 1–20 µm. The fixtures include `grid_nm` for these boards and the imported layouts. Convert benchmark-weighted lengths to microns by multiplying by `grid_nm / 1000`.
|
||||
|
||||
| Group | Boards | Coverage |
|
||||
| --- | ---: | --- |
|
||||
| `geometry-corners` | 32 | Exact four-bend spans, tight returns and paired routes, exact-span S-bend slots, mixed widths, and saturated or overloaded apertures. |
|
||||
| `complex-layouts` | 24 | Serial aperture banks with opposing tracks, concave and fixed-route keepouts, and staggered crossing arrays. |
|
||||
| `search-challenges` | 11 | Alternating comb walls and other tight passages that require repeated turns or exercise search-budget exhaustion. |
|
||||
| `scaling` | 8 | Banks and crossing arrays of up to 256 nets, obstacle fields with up to 320 keepouts, and a 240-net board with 240 keepouts and four blocked approaches. |
|
||||
|
||||
Pytest verifies the 75 reference layouts and checks that unseeded routing reaches the known bound on every board. For a scaling comparison, use the same grid, mode, and budget across repeated runs.
|
||||
|
||||
- [Fixture definitions](../inire/tests/routing_expanded_benchmarks.py)
|
||||
|
||||
## Complex-routing example 1
|
||||
|
||||
Use `complex-routing-example-1` to test fixed eastbound arrival and `complex-routing-example-1-point-terminals` to test heading inference.
|
||||
|
||||
The Terminal-Bench tests verify the unseeded point-terminal bundle and replay both reference lane plans.
|
||||
|
||||
- [Example gallery](../examples/advanced.md#complex-routing-example-1)
|
||||
- [Complex-routing walkthrough](complex-routing-example-1.md)
|
||||
- [Terminal-Bench tests](../inire/tests/test_terminal_bench.py)
|
||||
|
||||
## Preplaced crossings
|
||||
|
||||
- `crossing-single` isolates port access on one placed cell with four straight external legs.
|
||||
- `crossing-obstructed-approaches` adds blocked approaches and a turning exit.
|
||||
- `crossing-aligned-grid` and `crossing-staggered-grid` test multiple cells and short links between device banks.
|
||||
|
||||
Use unseeded runs to evaluate routing policy. For a separate check of geometry and clearance, use the reference paths in the [crossing fixtures](../inire/tests/routing_crossing_benchmarks.py).
|
||||
|
||||
## Fabrication regression cases
|
||||
|
||||
The layout tests use process dimensions to exercise routing and placement replay.
|
||||
|
||||
| Case | Checks |
|
||||
| --- | --- |
|
||||
| Optical ports | Matching widths allow a direct link. A wider target needs a taper. |
|
||||
| Authored lengths | Custom bend lengths are retained when the route is replayed. |
|
||||
| Layers and process profiles | Independent planes retain layer assignment. Ordered profiles reserve earlier routes and apply their own bend limits. |
|
||||
| Coplanar waveguide | Route the conductor and gap envelope from the same seed. With a 29.5 µm envelope and 3 µm clearance, 28 and 32 µm pitches fail and 36 µm passes. |
|
||||
|
||||
- [Layout regression tests](../inire/tests/test_layout.py)
|
||||
|
||||
### Phase-sensitive routes
|
||||
|
||||
In the Raymond fabrication study, the authored arms of `MZI9` measured 286.770 µm and 183.637 µm. A geometrically valid replacement for the longer arm measured 127.208 µm. It passed the EBeam design-rule check and changed the signed arm-length difference from +103.133 µm to −56.429 µm. Replaying a separate Bézier-based waveguide with circular bends changed its reported length from 156.137 µm to 154.948 µm. Compare the reported lengths against the circuit's tolerance before replacing a phase-sensitive route. [Raymond fabrication layout](https://github.com/SiEPIC/openEBL-2025-02/blob/a887476a301db2a014be007717cd1821e111f58e/submissions/EBeam_hannahraymond_MZIv21.gds) · [EBeam bend definitions](https://github.com/SiEPIC/SiEPIC_EBeam_PDK/blob/363fbb52eefa8669100499ab531d3fe7befc4867/klayout/EBeam/WAVEGUIDES.xml#L3-L15) · [Reported lengths](user/api-reference.md#results)
|
||||
|
||||
## Imported fixtures
|
||||
|
||||
The converted fixtures have port openings cut into device keepouts and use a 0.1 µm grid. The test suite reads the checked-in layouts.
|
||||
|
||||
- [Converted geometry](../inire/tests/data/external_routing_benchmarks.json)
|
||||
- [Fixture sources and licenses](../inire/tests/data/README.md)
|
||||
43
docs/benchmarks.md
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
# Routing benchmarks
|
||||
|
||||
## Run a benchmark
|
||||
|
||||
From the repository root, run the overloaded-gate fixture.
|
||||
|
||||
```sh
|
||||
python -m pytest -m routing_corpus -k overloaded-gate
|
||||
```
|
||||
|
||||
The test checks that three of the four nets verify. All four nets need to cross a vertical cut with room for three tracks. Use `-k lidar-clements-8x8` to check an imported board with a bound of three out of six set by port spacing.
|
||||
|
||||
### Run the full benchmark corpus
|
||||
|
||||
```sh
|
||||
python -m pytest -m routing_corpus
|
||||
```
|
||||
|
||||
The default test suite includes the corpus. Run `python -m pytest -m retry_holdout` to focus on the holdouts.
|
||||
|
||||
## Choose a case
|
||||
|
||||
Use `pytest --collect-only -q -m routing_corpus` to list the case IDs. Start with a board that exhibits the behavior and select it with `-k`.
|
||||
|
||||
- For tight corners and S-bend slots, start with the micron-scale geometry fixtures.
|
||||
- For preplaced devices, choose a case such as `crossing-obstructed-approaches` or `crossing-staggered-grid`.
|
||||
- For a change to retry order, include the held-out return shelves, bypasses, and competing trunks.
|
||||
|
||||
The [fixture guide](benchmark-fixtures.md) describes these layouts and their known bounds. The [corpus registry](../inire/tests/routing_corpus.py) lists the groups and options.
|
||||
|
||||
## Choose a profile
|
||||
|
||||
The corpus uses automatic routing under `corpus-regression`, with a 500-node search limit, a 500-node seed budget per net, and up to three congestion iterations per attempt. On the three `search-low-length-cost` boards it also checks the original 80- or 130-node lattice budget.
|
||||
|
||||
### Compare routing modes
|
||||
|
||||
For a mode comparison, use the same problem and options in each call to `route()`. Change the topology mode and compare verified IDs, route cost on matching net sets, and work counters. The [complex-routing walkthrough](complex-routing-example-1.md#compare-all-routing-modes) shows this comparison with a 100-node search budget.
|
||||
|
||||
## Compare the results
|
||||
|
||||
1. **Coverage and bounds.** Check which nets verified and whether their count reached the expected bound. The tests also verify known reference routes where available.
|
||||
2. **Cost on matching net sets.** Benchmark-weighted length weights physical straights, 90-degree bends, and S-bends by 1, 4, and 13. Native objective cost uses the run's configured objective.
|
||||
3. **Search and time.** Compare expansions and repeated wall times at the same settings. Constructive stages can spend time planning and verifying even with zero expansions. Inspect the [automatic reports](routing-diagnostics.md#automatic-reports) to find which stage performed the work.
|
||||
113
docs/complex-routing-example-1.md
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
# Complex-routing example 1
|
||||
|
||||
Follow the outer return, `net_08`, from the input ports to its final eastbound arrival. Run from the repository root.
|
||||
|
||||
```sh
|
||||
python examples/advanced_layouts.py \
|
||||
--case complex-routing-example-1 \
|
||||
--output-dir /tmp/inire-complex-routing-example-1
|
||||
```
|
||||
|
||||
Origin. [Board 1 from Terminal-Bench pull request 345](https://raw.githubusercontent.com/harbor-framework/terminal-bench/249d125b59c0a5352d9e132195cfead6d81446be/tasks/photonic-waveguide-routing/environment/layout_spec.json).
|
||||
|
||||
## 1. Load the board and set the routing target
|
||||
|
||||
The 2,500 by 1,000 board has seven keepouts and nine nets. Width is 2, clearance is 6, and both bend radii are 50. All ports require eastbound travel. Automatic starts with a target of nine verified nets after checking port conflicts and track capacity.
|
||||
|
||||

|
||||
|
||||
Open circles mark sources and filled squares mark targets. The inset shows 24 tracks fitting through the purple cut after allowing for width and clearance.
|
||||
|
||||
## 2. Assign lanes and compile path seeds
|
||||
|
||||
The bundle planner groups nets by their passages and spaces the lanes at a pitch of 9. The first `net_08` plan takes the bottom lane at `y = 1`, rises on the right, and approaches its target heading west.
|
||||
|
||||

|
||||
|
||||
The dots mark waypoints. In the lower inset, only `net_08` and `net_00` fit below the tower. The planner compiles straight runs, right-angle corners, and diagonals into straight, quarter-turn, and S-bend seeds.
|
||||
|
||||
## 3. Fit the required eastbound arrival
|
||||
|
||||
The turnaround planner shifts the upper shelf route `net_07` and brings `net_08` beneath it. The return rises west of its target and takes a final right turn. The planner recompiles both changed seeds.
|
||||
|
||||

|
||||
|
||||
Compare the heading arrows above the red target squares.
|
||||
|
||||
## 4. Verify the seeds and refine the layout
|
||||
|
||||
A worker in mode `off` replays the `bundle-turnaround` seeds with a zero-node budget. It checks the resulting polygons against the board, keepouts, and other routes. All nine verify, so automatic skips search.
|
||||
|
||||

|
||||
|
||||
The upper panel shows the first four paths in installation order. The lower panel shows all nine checked together.
|
||||
|
||||
Automatic replays the seeds again with refinement enabled. The refiner replaces sections of `net_05` and `net_07`, preserving all nine verified nets and lowering the configured objective.
|
||||
|
||||

|
||||
|
||||
Compare the solid and dashed approaches of `net_07` near the top edge.
|
||||
|
||||
## 5. Inspect the result
|
||||
|
||||
Inspect `run.automatic.stages` and `run.automatic.selected_stage` after routing the fixed-heading board under the public defaults. Both stages report zero A* expansions.
|
||||
|
||||
| Stage | Planner | Operation | Verified nets |
|
||||
| --- | --- | --- | --- |
|
||||
| 0 | `bundle-turnaround` | Verify the compiled seeds | 9 |
|
||||
| 1, selected | `bundle-turnaround` | Refine and verify the layout | 9 |
|
||||
|
||||
The point-terminal variant accepts a westbound arrival for `net_08`, so the original bundle needs no turnaround. Rerun the gallery command with `--case complex-routing-example-1-point-terminals` to see the result.
|
||||
|
||||
- [Example gallery](../examples/advanced.md#complex-routing-example-1)
|
||||
|
||||
## Compare all routing modes
|
||||
|
||||
Each run uses 100 nodes per search and one congestion iteration, with warm start and refinement disabled. Set `infer_terminal_headings=True` for `bundle` so `net_08` can arrive westbound. Fixed eastbound headings raise a mismatch in that mode.
|
||||
|
||||
| Mode | Result |
|
||||
| --- | --- |
|
||||
| `automatic` | 9/9 verified. The turnaround plan completes the layout without building a mesh. |
|
||||
| `off` | 0/9 verified at this budget. The worker runs lattice search directly. |
|
||||
| `guide` | 1/9 verified. The worker builds a mesh and suggests corridors to lattice search. |
|
||||
| `seed` | 1/9 verified. The worker builds a mesh and searches for starting paths inside the corridors before its routing iteration. |
|
||||
| `bundle` | 9/9 verified. The worker builds and verifies ordered tracks directly from the board geometry. |
|
||||
|
||||

|
||||
|
||||
### Triangulation support
|
||||
|
||||
Inire requires Shapely 2.1 or newer with GEOS 3.10 or newer. Check the versions in the environment that runs Inire.
|
||||
|
||||
```sh
|
||||
python -c 'import shapely; print(shapely.__version__, shapely.geos_version_string)'
|
||||
```
|
||||
|
||||
Automatic builds a mesh when it reaches corridor search. Here the turnaround plan finishes first. Guide and seed also replay supplied paths without a mesh at `node_limit=0`.
|
||||
|
||||
- [Shapely installation](https://shapely.readthedocs.io/en/2.1.2/installation.html)
|
||||
- [Constrained triangulation API](https://shapely.readthedocs.io/en/2.1.2/reference/shapely.constrained_delaunay_triangles.html)
|
||||
|
||||
## Compare a guide-mode search
|
||||
|
||||
To see the corridor model on the same board, run `net_08` on its own in guide mode.
|
||||
|
||||

|
||||
|
||||
Left, the mesh, green corridor cells, and dashed guide. Right, purple expanded positions and the red partial path at the 12-node limit.
|
||||
|
||||
```sh
|
||||
python -m scripts.render_documentation_figures --output-dir /tmp/inire-complex-routing-example-1
|
||||
```
|
||||
|
||||
- [Corridor planning](topological-routing.md#corridor-planning-and-realization)
|
||||
|
||||
## Implementation
|
||||
|
||||
| Stage | Inputs and code |
|
||||
| --- | --- |
|
||||
| Board and routing target | [Board inputs](../examples/advanced-layouts.json), [problem builder](../examples/advanced_layouts.py#L37), [capacity calculation](../inire/router/_capacity.py#L29) |
|
||||
| Lanes and seeds | [Lane assignment](../inire/router/_bundle.py#L114), [waypoint compiler](../inire/router/_waypoints.py#L33) |
|
||||
| Eastbound arrival | [Turnaround candidates](../inire/router/_perimeter.py#L103) |
|
||||
| Verification and refinement | [Seeded worker](../inire/router/_automatic.py#L173), [physical verification](../inire/geometry/collision.py#L687), [refinement handoff](../inire/router/_automatic.py#L610) |
|
||||
| Figures and mode comparison | [Figure generator](../scripts/render_documentation_figures.py) |
|
||||
30
docs/development.md
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# Developer guide
|
||||
|
||||
<a id="choose-a-task"></a>
|
||||
|
||||
## Links
|
||||
|
||||
- [Complex-routing walkthrough](complex-routing-example-1.md)
|
||||
- [Router architecture](architecture.md)
|
||||
- [Topological routing](topological-routing.md)
|
||||
- [Routing diagnostics](routing-diagnostics.md)
|
||||
- [Benchmarks](benchmarks.md)
|
||||
- [Benchmark fixtures](benchmark-fixtures.md)
|
||||
- [Public API](user/api-reference.md)
|
||||
|
||||
## Check a change
|
||||
|
||||
1. From the repository root, run `uv sync` to install development dependencies. Activate `.venv` or prefix commands with `uv run`.
|
||||
2. Run `python -m pytest` for the correctness suite and `ruff check inire scripts` for lint. Use `python -m pytest -m "not routing_corpus"` for a shorter local check.
|
||||
3. For a cleanup that should preserve paths, use the same fixtures and options in both revisions. Compare the relevant [route results and traces](routing-diagnostics.md#reproduce-and-compare).
|
||||
4. For a policy or budget change, start with a case that exhibits the behavior. Compare verified IDs, cost, and work under the same [benchmark profile](benchmarks.md#choose-a-profile). Check the corpus and related holdouts before adopting the change.
|
||||
|
||||
Build release archives with `uv build`. The wheel contains the runtime. The source archive also includes tests and fixtures. Smoke-test the wheel outside the checkout on Python 3.11 with Shapely 2.1.0 and GEOS 3.10 or newer, once with NumPy 1.26 and once with NumPy 2.x.
|
||||
|
||||
### Regenerate documentation figures
|
||||
|
||||
Run `python -m scripts.render_documentation_figures` to regenerate the guides, the complex-routing walkthrough, and the advanced example gallery in `docs/figures`. Pass `--output-dir /tmp/inire-figures` to preview them in a separate directory.
|
||||
|
||||
The gallery and walkthrough use the checked-in [layout data](../examples/advanced-layouts.json). The [numbered examples](../examples/README.md) save their own plots in `examples/`.
|
||||
|
||||
When editing a guide, state which inputs or earlier example a reader needs to follow a linked section. Run affected examples, check the links and figures, and preserve existing heading anchors.
|
||||
BIN
docs/figures/automatic-stages.png
Normal file
|
After Width: | Height: | Size: 63 KiB |
BIN
docs/figures/complex-routing-example-1-guide.png
Normal file
|
After Width: | Height: | Size: 148 KiB |
BIN
docs/figures/complex-routing-example-1-input.png
Normal file
|
After Width: | Height: | Size: 63 KiB |
BIN
docs/figures/complex-routing-example-1-lanes.png
Normal file
|
After Width: | Height: | Size: 49 KiB |
BIN
docs/figures/complex-routing-example-1-modes.png
Normal file
|
After Width: | Height: | Size: 130 KiB |
BIN
docs/figures/complex-routing-example-1-refinement.png
Normal file
|
After Width: | Height: | Size: 43 KiB |
BIN
docs/figures/complex-routing-example-1-turnaround.png
Normal file
|
After Width: | Height: | Size: 59 KiB |
BIN
docs/figures/complex-routing-example-1-verification.png
Normal file
|
After Width: | Height: | Size: 73 KiB |
BIN
docs/figures/corridor-realization.png
Normal file
|
After Width: | Height: | Size: 70 KiB |
|
After Width: | Height: | Size: 70 KiB |
BIN
docs/figures/example-complex-routing-example-1.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
docs/figures/example-stress-crossing-off-lattice-slot.png
Normal file
|
After Width: | Height: | Size: 32 KiB |
BIN
docs/figures/example-stress-crossings-shared-outside-detour.png
Normal file
|
After Width: | Height: | Size: 43 KiB |
BIN
docs/figures/example-stress-passage-split-merge.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
docs/figures/example-stress-passage-width-key.png
Normal file
|
After Width: | Height: | Size: 31 KiB |