KFactory 3.0.0rc2
KFactory is a Python framework for photonic and electronic chip layout, built on KLayout's C++ geometry engine. It provides parametric cells with caching, optical and electrical routing, enclosures via Minkowski sums, and schematic-driven design with LVS.
Key Features
- Cell caching — the
@kf.celldecorator deduplicates identical components automatically - Routing — optical and electrical bundle routing, Manhattan primitives, all-angle routing, and path-length matching
- Cross-sections & enclosures — define waveguide profiles and automatic boolean cladding layers via Minkowski sums
- Schematics — place-and-connect workflow with netlist extraction and layout-vs-schematic verification
- Virtual cells — hierarchical logical containers for schematic-driven design
- Dual coordinate systems —
KCell(integer DBU) andDKCell(float µm) work side by side - KLayout integration — full access to
kdb.Region,kdb.Polygon, DRC, and GDS/OASIS I/O - Jupyter & KLive — live preview in KLayout while editing notebooks
- PDK system — bundle layers, factories, cross-sections, and technology into reusable packages
Getting Started
Installation
KFactory is available on PyPI and requires Python 3.12+.
uv add kfactory
# or with pip
pip install kfactory
Development
just dev
This installs the development environment and sets up pre-commit hooks.
Ecosystem
| Package | Description |
|---|---|
| gdsfactory | Full-featured chip design framework — KFactory is its layout backend |
| kfnetlist | Standalone netlist extraction and generation |
Documentation
Full documentation is available at gdsfactory.github.io/kfactory.
Upgrading from an earlier version? See the migration guide.
License
-
Getting Started
Install kfactory and build your first component in under 5 minutes.
-
Core Concepts
Understand KCells, layers, ports, instances, and the DBU ↔ µm coordinate systems.
-
Routing
Optical and electrical bundle routing, Manhattan primitives, all-angle, and path-length matching.
-
Components
Straight waveguides, euler/circular bends, tapers, Bezier S-bends, and the factory pattern.
-
Enclosures
Layer enclosures via Minkowski sums, cross-sections, and KCell-level cladding.
-
Utilities
Grid layout, packing, DRC fixing, fill, and regression testing.
-
PDK
Bundle layers, factories, cross-sections, and technology into a reusable PDK.
-
Schematics
Schematic-driven layout, netlist extraction, LVS, and YAML/JSON round-trips.
-
How-To Guides
Common patterns, best practices, and a comprehensive FAQ.