Skip to content
LGAI-ResearchPublic

About

A reinforcement learning environment for PCB autorouting, built on KiCad's push-and-shove router. Includes a decoder-only PPO/GRPO agent, LLM tool-calling and rule-based baselines, and a uniform 3-stage evaluation pipeline. The routing engine ships separately as the PCBWorld-Engine submodule (GPLv3).

Resources

Stars

45 stars

Watchers

2 watching

Forks

Repository files navigation

PCBWorld

PCBWorld version KiCad 9.0.8 Python 3.12+ License: BSD-3-Clause

PCBWorld v1.2.2, from LG AI Research: an open-source Gymnasium environment for PCB routing, built on KiCad's interactive router.

It runs on Linux x86_64 (primary) and on macOS with Apple Silicon (experimental, see below). The environment is BSD-3-Clause; the engine is GPLv3 (see Licensing). The engine submodule pins KiCad 9.0.8.

PCBWorld wraps KiCad's push-and-shove router as a Gymnasium environment. An agent places tracks and vias on a real .kicad_pcb board, and every step is scored by KiCad's own design-rule checker. What routes here routes in KiCad.

The repository ships the environment, synthetic board generators, the real-board benchmark splits, one evaluation pipeline shared by every method, and three families of baselines: a decoder-only PPO/GRPO transformer, LLM tool-calling agents, and the rule-based routers Freerouting and KRT.

Demo

An LLM agent routing two production boards end to end (time-lapse; click for the full video):

0018_hy_adapter 0100_smt-zvs-driver
Case study 1 Case study 2

All supplementary videos: PCBWorld_media/index.html.

Using the environment

from configs.loader.schema import EnvConfig
from pcb_world.core.env import PCBWorld
from pcb_world.core.action_schema import ACT_NET_SELECT, ACT_START_ROUTE, ACT_MAKE_LINE, ACT_NET_END

# EnvConfig: every env setting (defaults: configs/env.yaml)
env = PCBWorld("tests/fixtures/simple_routing_board.kicad_pcb", EnvConfig.with_overrides(max_steps=200))
obs, info = env.reset(seed=0)

src, dst = obs["board_static"]["nets"]["net_1"]["pads"].values()
(x0, y0), (x1, y1) = src["center"]["xy"], dst["center"]["xy"]

for action in (
    {"action_type": ACT_NET_SELECT, "net_id": 1},
    {"action_type": ACT_START_ROUTE, "x_mm": x0, "y_mm": y0, "layer": src["layer"]},
    {"action_type": ACT_MAKE_LINE, "x_mm": x1, "y_mm": y1, "routing_mode": 2},
    {"action_type": ACT_NET_END},
):
    obs, reward, terminated, truncated, info = env.step(action)

State, actions and reward: docs/ENVIRONMENT.md.

Quick start

1. Setup

git clone --recursive https://github.com/LGAI-Research/PCBWorld.git pcbworld && cd pcbworld
bash tools/setup/setup_all.sh        # conda env, pinned baselines, engine build, import smoke
conda activate pcbworld && export PYTHONPATH=build_rl/pcbnew/python/rl:. PCBWORLD_DATA_ROOT=$PWD/var/datasets

setup_all.sh needs conda's libmamba solver (the default from conda 23.10) or mamba in conda's base; the classic solver does not finish on this env, so the script stops and says how to switch (SKIP_ENV=1 keeps an existing env without solving).

macOS (Apple Silicon)

The same setup_all.sh picks environment.macos.yml and requirements-macos.txt on an arm64 Mac; install the Xcode Command Line Tools first (xcode-select --install). The engine is built from the conda env alone; a Homebrew install is ignored. Rebuild it (after a C++ change) with bash tools/setup/build_engine.sh, as on Linux. This path is experimental. On a Mac:

  • Verified (Apple M5 Pro, macOS 26.4): setup_all.sh end to end (env, baseline downloads, engine build, import), the test suite, and the RL quick start (step 3: board generation, PPO training on the Apple GPU (MPS), evaluation); KRT's grid_router builds with cargo.
  • Not yet verified: LLM agents through a provider API, full rule-based baseline runs (Freerouting, KRT, OrthoRoute), and the optional pcbnew / kicad-cli builds (BUILD_PCBNEW=1, BUILD_CLI=1).
  • Linux only: LLM-policy training (verl-agent) and the local vLLM provider (vLLM ships no macOS build), the CUDA kernels (flash-attn), and multi-GPU training (NCCL).
  • Unsupported: Intel Macs (no PyTorch 2.8 build for x86_64 macOS).

2. Open-source boards (D3)

bash tools/quickstart/prepare_pcbench.sh --limit 30 --workers 8

Collects the PCBench boards and preprocesses them into the D3 benchmark set. Drop --limit for all of them.

3. Train an RL policy

bash tools/quickstart/train_rl.sh --data-dir var/datasets/synthetic/synth_2L_v2 --boards 200 --iterations 5 --seed 42

Generates the boards when the directory is empty, trains PPO on them, and evaluates the policy on the test split.

4. Route with an LLM

GEMINI_API_KEY=... bash tools/quickstart/run_llm.sh   # or OPENAI_API_KEY, ANTHROPIC_API_KEY, TOGETHER_API_KEY

Any one key works; the script picks the provider from it (Gemini has a free tier). Without a key it only prints the prompt and runs a single fixed step.

The shipped defaults use a newer potential-function combination than the paper. To reproduce the KDD submission with its original reward, follow experiments/kdd/.

Benchmark results

Routing quality on D3-A, the 99 small open-source PCBench boards; the RL policy is trained on synthetic D2 boards only and routes the D3-A boards zero-shot. Table 3 of the paper (arXiv:2607.05915), under the @5 protocol of docs/METRICS.md; Freerouting and PPO are means over 4 seeds.

Method CP ↑ Pot. ↑ Rout. ↑ Time (s) ↓
Reference (the boards' original routed traces) 1.00 23.16 1.00 -
Freerouting 0.80 22.71 0.91 7.09
KRT (KiCadRoutingTools) 0.74 20.00 0.94 0.65
LLM agent, GPT-5.4 0.65 19.42 0.91 231.15
LLM agent, GPT-5.4-mini 0.28 14.22 0.72 56.85
LLM agent, GPT-5.4-nano 0.30 14.16 0.73 100.76
LLM agent, Qwen3.5-397B 0.34 14.88 0.75 81.82
PPO, decoder-only Transformer 0.86 21.46 0.95 1.83

Best CP and Pot. per column of this table, excluding Reference, in bold. The full table (D2, D3-B, OrthoRoute, the RL variants) is Table 3 of PCBWorld.pdf. Pot. uses the paper's reward, so it is reproduced through experiments/kdd/, not the quick start (see above).

The trained policies from the paper are on Hugging Face: LG-AI-Research/PCBWorld (download notes: docs/QUICKSTART.md). The checkpoints are licensed separately from this code, under the EXAONE AI Model License Agreement 1.2 - NC: research and educational use only, with no commercial use of the checkpoints or of their output (see the license in the Hugging Face repository).

Licensing

PCBWorld is two programs, distributed separately:

Program Where License
PCBWorld: the environment, agents, benchmark, training and evaluation code this repository BSD-3-Clause
PCBWorld Engine: the KiCad modifications, the RL router, the engine server LGAI-Research/PCBWorld-Engine, pinned here as the engine/ submodule GPLv3

Third-party notices: Notice.md.

Citation

Accepted to the KDD 2026 Workshop on Evaluation and Trustworthiness of Agentic AI (arXiv:2607.05915, PCBWorld.pdf).

@inproceedings{song2026pcbworld,
  title     = {PCBWorld: A Benchmark Environment for Engine-Grounded
               PCB Design Automation},
  author    = {Song, Hyungseok and Park, Junseok and Choi, Won-Seok and
               Bae, Seohui and Jeong, Han-Seul and Park, Youngjoon and
               Lee, Soonyoung},
  booktitle = {KDD 2026 Workshop on Evaluation and Trustworthiness of
               Agentic AI},
  year      = {2026},
  note      = {arXiv:2607.05915},
}

Contact

Open an issue, or write to [email protected]. Bug reports and pull requests are welcome.

About

A reinforcement learning environment for PCB autorouting, built on KiCad's push-and-shove router. Includes a decoder-only PPO/GRPO agent, LLM tool-calling and rule-based baselines, and a uniform 3-stage evaluation pipeline. The routing engine ships separately as the PCBWorld-Engine submodule (GPLv3).

Resources

Stars

45 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages