PhIDO (Photonics Intelligent Design and Optimization) is an intelligent web application that automates the design of photonic integrated circuits using Large Language Models (LLMs). The application provides both automatic guided workflows and step-by-step execution modes for circuit design, from specification to layout generation and Design Rule Checking (DRC).
PhIDO/
βββ PhotonicsAI/ # Main application package
β βββ Photon/ # Core application modules
β β βββ webapp.py # Streamlit web application (main entry point)
β β βββ llm_api.py # LLM API integrations and model configurations
β β βββ utils.py # Utility functions for circuit processing
β β βββ prompts.yaml # LLM prompts and system instructions
β β βββ templates.yaml # Circuit templates and configurations
β β βββ DemoPDK.py # Demo Process Design Kit
β β βββ drc/ # Design Rule Checking module
β β β βββ drc.py # DRC execution engine
β β β βββ drc_script.drc # KLayout DRC script
β β βββ CIRCUIT_wdd0.yaml # Example circuit configuration
β βββ KnowledgeBase/ # Design knowledge and components
β β βββ DesignLibrary/ # Photonic component library
β β β βββ mzi_1x1_heater_tin_cband.py # MZI with TiN heaters
β β β βββ mzi_2x2_heater_tin_cband.py # 2x2 MZI with heaters
β β β βββ ... # Other photonic components
β β βββ FDTD/ # Finite Difference Time Domain simulation data
β βββ config.py # Application configuration
βββ requirements.txt # Complete environment dependencies
βββ Makefile # Build and run commands
βββ Testbench.xlsx # Contains 102 testbench prompts
βββ README.md # This file
-
System Dependencies (Ubuntu/Debian):
sudo apt-get update sudo apt-get install graphviz libgraphviz-dev pkg-config klayout
-
Python Environment:
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txtAfter this is done, do:
pip install kfactory==0.21.1Ignore the pip dependency resolver conflict with gdsfactory 8.8.5.
Create a log folder under PhIDO-Release/PhotonicsAI/
Create a .env file in the project root with your API keys:
# Required for OpenAI models (GPT-4, GPT-4o, O1)
OPENAI_API_KEY='your-openai-api-key'
# Required for Anthropic Claude models
ANTHROPIC_API_KEY='your-anthropic-api-key'
# Required for Google Gemini models
GOOGLEGENAI_API_KEY='your-google-api-key'
# Required for DeepSeek-R1
DEEPSEEK_API_KEY='your-deepseek-api-key'
# Required for models hosted on NVIDIA NIM
NVIDIA_API_KEY='your-nvidia-nim-api-key'PhIDO supports multiple LLM providers through the llm_api.py module, LLM selection is configured at the beginning of webapp.py script. The user may run different LLMs at each step of PhIDO, provided that the models' API keys are configured within the environmental variables:
- GPT-4o - General purpose reasoning
gpt-4o - o1 - (Default) Specialized for reasoning tasks
o1 - o3-mini - Faster reasoning model
o3-mini - Environment Variable:
OPENAI_API_KEY
- Claude-3-7-Sonnet-20250219 - Balanced performance and speed
claude-3-7-sonnet-latest - Claude-4.0-Opus - Advanced reasoning capabilities
claude-opus-4-20250514 - Environment Variable:
ANTHROPIC_API_KEY
- Gemini-2.5-Pro - Advanced reasoning and code generation
gemini-2.5-pro - Gemini-1.5-Pro - General purpose reasoning
gemini-1.5-pro - Gemini-1.5-Flash - Fast response model
gemini-1.5-flash - Gemini-2.0-Flash - Latest flash model
gemini-2.0-flash - Environment Variable:
GOOGLEGENAI_API_KEY
- nvidia/llama-3.1-nemotron-ultra-253b-v1 - Large-scale reasoning
nvidia/llama-3.1-nemotron-ultra-253b-v1 - nvidia/nemotron-4-340b-instruct - Alternative Nemotron model (Deprecated on NIM)
nvidia/nemotron-4-340b-instruct - Environment Variable:
NVIDIA_API_KEY
- DeepSeek-Reasoner - Specialized reasoning model
deepseek-reasoner - Environment Variable:
DEEPSEEK_API_KEY
Note that OPENAI_API_KEY must be set in addition to any other model api key as PhIDO uses GPT models for formatting entity extraction results via pydantic.
Other models offered by API providers above may also work but have not been tested.
PhIDO provides two distinct workflow modes to accommodate different user preferences and use cases:
A fully automated, step-by-step process that guides users through the entire circuit design pipeline.
Workflow Steps:
- Entity Extraction: Analyzes user input to extract circuit requirements, components, and specifications
- Component Selection: Matches extracted entities with available photonic components from the knowledge base
- Schematic Generation: Creates a circuit DSL (Domain Specific Language) representation with component connections
- Layout & Simulation: Generates GDS layout files and performs circuit simulations
- Design Rule Checking (DRC): Validates layout against manufacturing design rules using KLayout
Features:
- Automatic progression between steps
- Real-time feedback and status updates
- Error handling and recovery
- Integrated validation at each stage
- Template-based circuit generation
- DRC integration for manufacturing readiness
Allows users to execute individual workflow steps with custom inputs and manual control.
Available Steps:
- Entity Extraction: Run with custom circuit descriptions
- Component Selection: Execute with predefined templates or custom components
- Schematic Generation: Generate circuit DSL from custom inputs
- Layout & Simulation: Create layouts and run simulations independently
- DRC Validation: Run design rule checks on generated layouts
Features:
- Manual step execution
- Custom input capabilities
- Detailed step-by-step control
- Individual result inspection
- Template-based processing
- DRC results display and analysis
- Intelligent Component Matching: AI-powered selection of photonic components based on specifications
- Automatic Routing: Smart connection generation between components
- Layout Generation: GDS file creation for fabrication
- Simulation Integration: Circuit performance analysis using SAX
- Template Workflows: Pre-defined circuit templates with customizable parameters
- KLayout Integration: Automated DRC using industry-standard KLayout
- Manufacturing Validation: Checks for minimum feature sizes, spacing, and design rules
- Error Reporting: Detailed DRC violation reports with visual feedback
- Layer Compatibility: Handles GDS layer number limitations gracefully
- Component Library: Extensive photonic component database including:
- MZI (Mach-Zehnder Interferometer) variants with heaters
- Directional couplers and splitters
- Waveguides and bends
- Active components with TiN heaters
- FDTD Simulations: Pre-computed electromagnetic simulations
- Design Templates: Reusable circuit configurations
- Process Design Kit: Manufacturing-ready component definitions
- Interactive Web Interface: Streamlit-based responsive UI
- Real-time Feedback: Live progress updates and status indicators
- Error Recovery: Graceful handling of failures with retry mechanisms
- Export Capabilities: Multiple output formats (GDS, YAML, PNG)
- Token Usage Tracking: Monitor LLM API usage and costs
- Runtime Performance: Track workflow execution times
Before starting:
export PYTHONPATH='.'Set ./PhIDO-Release as a PYTHONPATH environmental variable.
make runstreamlit run PhotonicsAI/Photon/webapp.py- Start the application and select "Step-by-Step Workflow"
- Choose a template (e.g., "MZI with TiN heaters")
- Customize parameters (length, width, heater specifications)
- Generate circuit DSL from template
- Create layout and run simulations
- Validate with DRC for manufacturing readiness
- Start the application and select "Automatic Workflow"
- Enter a circuit description (e.g., "Design a 2x2 Mach-Zehnder interferometer with heaters")
- Follow the guided process through all steps
- Review generated schematics and layouts
- Check DRC results for any violations
- Export results for fabrication or further analysis
webapp.py: Main Streamlit application with UI components and workflow logicllm_api.py: LLM integration layer supporting multiple providers and modelsutils.py: Utility functions for circuit processing, DOT graph generation, and data handlingprompts.yaml: Structured prompts for different LLM tasks and workflow stepstemplates.yaml: Circuit templates and component configurationsdrc/: Design Rule Checking module with KLayout integrationKnowledgeBase/: Photonic component library and simulation data
To add new photonic components:
- Create component file in
KnowledgeBase/DesignLibrary/ - Define component geometry and parameters
- Add S-parameter models for simulation
- Update component templates in
templates.yaml - Add corresponding prompts in
prompts.yaml
To add new design rules:
- Modify
drc/drc_script.drcwith new rule definitions - Update layer definitions and constraints
- Test with sample layouts
- Update DRC reporting in
webapp.py
To add support for new LLM models:
- Add the model configuration in
llm_api.py - Update the model selection in
webapp.py - Add corresponding environment variables
- Test with appropriate prompts
- GDS Layer Number Errors: PhIDO automatically handles large layer numbers with fallback strategies
- DRC Failures: Check KLayout installation and DRC script configuration
- LLM API Errors: Verify API keys and model availability
- Component Import Errors: Ensure all dependencies are installed correctly
If you encounter import issues:
export PYTHONPATH='.' If you encounter the error below:
ModuleNotFoundError: No module named 'kfactory.routing.generic'do
pip install kfactory==0.21.1Ignore the pip dependency resolver conflict with gdsfactory 8.8.5.
If you encounter a logger error, create a log folder under PhIDO-Release/PhotonicsAI.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with Streamlit for the web interface
- Powered by various LLM providers (OpenAI, Anthropic, Google, NVIDIA)
- Uses GDSFactory for photonic layout generation
- Integrates with SAX for circuit simulations
- KLayout for Design Rule Checking
- Template-based workflows for rapid prototyping