Overview

What laylight is for and the minimal workflow for building photonic layouts.

laylight is a dedicated DSL for creating layout designs. Its current first version is exposed through Python bindings, and today the strongest coverage is in photonic structures, with room to grow into other layout domains such as MEMS in the future.

laylight is aimed at the part of a layout workflow where you want code-level control without rebuilding the same device plumbing in every project.

The library currently emphasizes a few practical goals:

  • Keep device construction programmable instead of template-driven.
  • Make process layers explicit through a small Technology abstraction.
  • Let layout assembly stay close to KLayout's underlying data model.
  • Support composition patterns that are easy to test with small examples.

This is a good fit when you want a lightweight core for waveguides, curves, rings, and related structures, then grow outward into more specialized devices and routing logic.

This documentation site focuses on the main entry points:

  • Create a laylight.Layout
  • Select process layers from Technology
  • Instantiate device objects from core
  • Compose and place device cells into a top cell
  • Export the resulting layout to GDS or PNG

Workspace Layout

This repository is currently a uv workspace. The core library lives in packages/core, the runnable examples live in packages/examples, and the documentation site lives in packages/docs.

From the repository root you can run:

uv run --package laylight-docs laylight-docs-build
uv run --package laylight-examples laylight-examples --output-dir build/examples

If you do not want to install the workspace packages first, the current repository layout also supports:

PYTHONPATH=packages/core:packages/examples python -m laylight_examples --output-dir build/examples

Minimal Layout Flow

The following snippet shows the most basic usage flow in core:

import laylight
from klayout import db as kdb

from packages.core.laylight.structure.wg import WGStraight
from packages.core.laylight.technology import Technology

layout = laylight.Layout()
layout.dbu = 0.001
tech = Technology()
top = layout.create_cell("TOP")

waveguide = WGStraight(
    length=200,
    width=0.5,
    layout=layout,
    tech=tech,
)

top.insert(kdb.DCellInstArray(waveguide.cell().cell_index(), laylight.Trans()))
layout.write("build/minimal.gds")

There are three key steps in this workflow: create a Layout, instantiate a device, and insert the device cell into the top-level cell. The device itself is responsible for generating its geometry.

If you want to understand the abstractions behind that minimal flow, continue with Device Abstraction, Placer Chain API, and Technology Layers. For runnable examples, see Examples.