Rewrite routing documentation for users and developers

This commit is contained in:
Jan Petykiewicz 2026-11-26 20:25:20 -08:00
commit 2b02c6eae9

116
README.md
View file

@ -1,113 +1,43 @@
# inire: Auto-Routing for Photonic and RF Integrated Circuits
# inire
`inire` is a high-performance auto-router designed specifically for the physical constraints of photonic and RF integrated circuits. It uses a Hybrid State-Lattice A* search combined with negotiated congestion to route multiple nets while maintaining strict geometric fidelity and clearance.
Inire routes waveguides between fixed ports on photonic and RF layouts. It uses straight segments, 90-degree bends, and S-bends, and checks the finished geometry for clearance. You supply the placement, keepouts, and allowed bend radii. The router returns the routes it could verify along with any partial results.
## Key Features
## Install
* **Hybrid State-Lattice Search**: Routes using discrete 90° bends and parametric S-bends, ensuring manufacturing-stable paths.
* **Negotiated Congestion**: Iteratively resolves multi-net bottlenecks by inflating costs in high-traffic regions.
* **Analytic Correctness**: Every move is verified against an R-Tree spatial index of obstacles and other paths.
* **1nm Precision**: All coordinates and ports are snapped to a 1nm manufacturing grid.
* **Safety & Proximity**: Uses a sampled obstacle-boundary proximity model to bias routes away from nearby geometry.
* **Locked Routes**: Supports treating prior routed nets as fixed obstacles in later runs.
From a checkout with Python 3.11 or newer, run `pip install .`. For development, `uv sync` also installs the test and lint tools.
## Installation
`inire` requires Python 3.11+. You can install the dependencies using `uv` (recommended) or `pip`:
```bash
# Using uv
uv sync
# Using pip
pip install numpy scipy shapely rtree matplotlib
```
## Quick Start
## Route a net
```python
from inire import NetSpec, ObjectiveWeights, Port, RoutingOptions, RoutingProblem, SearchOptions, route
from inire import NetSpec, Port, RoutingProblem, route
problem = RoutingProblem(
bounds=(0, 0, 1000, 1000),
nets=(
NetSpec("net1", Port(50, 100, 0), Port(150, 100, 0), width=2.0),
),
)
options = RoutingOptions(
search=SearchOptions(
bend_radii=(50.0, 100.0),
greedy_h_weight=1.2,
),
objective=ObjectiveWeights(
bend_penalty=10.0,
),
nets=(NetSpec("input", Port(50, 100, 0), Port(250, 100, 0), width=2),),
clearance=2,
)
run = route(problem, options=options)
if run.results_by_net["net1"].is_valid:
print("Successfully routed net1!")
run = route(problem)
result = run.results_by_net["input"]
if result.is_valid:
print(result.report.total_length)
else:
print(result.outcome)
```
Automatic routing is the default. It starts with up to 500 nodes per search attempt and can use the configured search ceiling for unresolved layouts. [Routing options](DOCS.md#automatic-routing)
Use one coordinate unit throughout the layout. Port coordinates snap to the integer grid in that unit. Headings are in degrees, with 0 pointing east and 90 pointing north. The target heading is the direction of travel into the target.
For incremental workflows, feed prior routed results back into a new `RoutingProblem` via `static_obstacles` using `RoutingResult.locked_geometry`.
Automatic routing is the default. For a layout with crossing devices, place the devices first and route each external segment as a separate net. Include device keepouts with access to their ports. To keep previously routed waveguides fixed, add their `locked_geometry` to the next problem's obstacles. [API and tuning guide](DOCS.md)
## Usage Examples
## Examples and development
For detailed visual demonstrations and architectural deep-dives, see the **[Examples README](examples/README.md)**.
- [Runnable examples](examples/README.md) cover clearance, locked waveguides, custom bends, and partial routes.
- [Architecture](docs/architecture.md) describes planner selection, detailed search, and verification.
- [Routing benchmarks](docs/topological-routing.md) explain the corpus, profiles, and measured coverage.
- [Diagnostics](docs/routing-diagnostics.md) explains counters, timings, and trace tools.
Check the `examples/` directory for ready-to-run scripts. To run an example:
```bash
python3 examples/01_simple_route.py
```
## Testing
Run the default correctness suite with:
```bash
python3 -m pytest
```
The default test run checks automatic routing against the expected coverage on all 67 boards at 500 nodes per search attempt and three congestion iterations. It also verifies the reference paths for the ten stress layouts. Use `pytest -m "not routing_corpus"` for a shorter local run. The comparison CLI selects the stress layouts with `--case stress` and all 67 boards with `--case corpus`.
Runtime regression checks for the example scenarios are opt-in and require:
```bash
INIRE_RUN_PERFORMANCE=1 python3 -m pytest -q inire/tests/test_example_performance.py
```
The [routing benchmark matrix](docs/topological-routing.md#comparison) compares the baseline, soft guidance, and corridor seeds across several search budgets.
## Documentation
Current documentation lives in:
* **[DOCS.md](DOCS.md)** for the public API and option reference.
* **[docs/architecture.md](docs/architecture.md)** for the current implementation structure.
* **[docs/performance.md](docs/performance.md)** for the committed performance-counter baseline.
## API Stability
The stable API lives at the package root and is centered on `route(problem, options=...)`.
Deep-module interfaces such as `inire.router._router.PathFinder`, `inire.router._search.route_astar`, and `inire.geometry.collision.RoutingWorld` remain accessible for advanced use, but they are unstable semi-private interfaces and may change without notice.
## Architecture
`inire` operates on a **State-Lattice** defined by $(x, y, \theta)$. From any state, the router expands via three primary "Move" types:
1. **Straights**: Variable-length segments.
2. **90° Bends**: Fixed-radius PDK cells.
3. **Parametric S-Bends**: Procedural arcs for bridging small lateral offsets ($O < 2R$).
For multi-net problems, the negotiated-congestion loop handles rip-up and reroute logic and seeks a collision-free configuration without crossings.
## Configuration
`inire` is highly tunable. The stable API is `RoutingProblem` plus `RoutingOptions`, routed via `route(problem, options=...)`. Deep modules remain accessible for advanced workflows, but they are unstable and may change without notice. See `DOCS.md` for a full parameter reference.
Run `python -m pytest` for the correctness suite, including all 67 routing regression boards. Use `python -m pytest -m "not routing_corpus"` for a shorter local run. [Performance checks](docs/routing-diagnostics.md#reproduce-and-compare)
## License
This project is licensed under the GNU Affero General Public License v3. See `LICENSE.md` for details.
GNU Affero General Public License v3. [License text](LICENSE.md)