Installation¶
Lightsmith needs Python 3.10 or newer. The core install is pure Python and depends only on NumPy, SciPy, pydantic, array-api-compat and miepython.
CPU¶
Check the installation:
lightsmith doctor # array frameworks and GPUs that the solvers can see
lightsmith backends # every solver backend, and whether it is available
Optional extras¶
| Extra | Adds | Needed for |
|---|---|---|
gpu |
PyTorch (torch>=2.7) |
GPU solvers, every gradient path, inverse design |
mcp |
The MCP Python SDK (mcp>=1.2,<2) |
The lightsmith-mcp server |
tmatrix |
treams (Python < 3.14) | The T-matrix backend |
layout |
gdsfactory (Python ≥ 3.11) | Importing gdsfactory components and netlists. The built-in GDS reader needs no extra. |
xarray |
xarray | Labelled-array conversions |
Combine extras as needed:
Licences of optional dependencies
gdsfactory is MIT, but recent versions pull in KLayout (GPL-3.0-or-later) through kfactory. For that reason it is optional and imported lazily.
GPU¶
The GPU solvers run on PyTorch with CUDA. Install a CUDA build of PyTorch that matches your driver.
- Linux: the PyPI
torchwheels already include CUDA, solightsmith[gpu]is enough. - Windows: the PyPI
torchwheels are CPU-only. Take PyTorch from the PyTorch index instead. - RTX 50xx (Blackwell): needs CUDA 12.8 wheels (
cu128) or newer.
Add this to your own pyproject.toml so that uv resolves torch from the CUDA index:
Then check that the GPU is visible:
The output should show the GPU under "cuda_gpus", and "auto_device" should name cuda:0. With
device="auto", which is the default, solvers that support a GPU use it. Pass device="cpu" to force the
CPU, device="cuda:1" to pick a specific GPU, or device="torch-cpu" to run the PyTorch code path on
the CPU, for example to get gradients without a GPU.
From a clone (development)¶
git clone https://github.com/lightsmith-photonics/lightsmith
cd lightsmith
uv sync --extra gpu --extra mcp # pulls CUDA 12.8 PyTorch wheels on Windows and Linux
uv run lightsmith doctor
uv run pytest
To build this documentation locally:
GPL plugins¶
GPL-licensed solvers are separate packages. Once installed, they register through the
lightsmith.backends entry-point group, and lightsmith backends lists them: