Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update examples/semiconductor #340

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
69d0dd7
add expert plans and knowledge for 1 demo question
srag21 Aug 7, 2024
892e29c
update examples/semiconductor/streamlit-main DEFAULT_PROBLEM
TheVinhLuong102 Aug 7, 2024
81af153
simplify examples/semiconductor/streamlit-main app
TheVinhLuong102 Aug 7, 2024
d22627b
update api
Aug 7, 2024
9e3e91b
Merge branch 'examples/semiconductor' of github.com:aitomatic/openssa…
Aug 7, 2024
a77f18e
update examles/semiconductor/expert-knowledge.txt
TheVinhLuong102 Aug 7, 2024
9488a16
Merge pull request #341 from aitomatic/examples/semicon-optim
TheVinhLuong102 Aug 7, 2024
db8a06c
update new plan
Aug 7, 2024
3476219
feat: semiconductor ui
vophihungvn Aug 7, 2024
1f7a6ce
Merge branch 'examples/semiconductor' of github.com:aitomatic/openssa…
vophihungvn Aug 7, 2024
d4f34b1
parse json
Aug 7, 2024
8c12a4d
Merge branch 'examples/semiconductor' of github.com:aitomatic/openssa…
Aug 7, 2024
73946a5
feat: setup app stack
vophihungvn Aug 7, 2024
e95ed97
Merge branch 'examples/semiconductor' of github.com:aitomatic/openssa…
vophihungvn Aug 7, 2024
b167f2d
feat: move to component files
vophihungvn Aug 7, 2024
bee7bd4
fix: updated Dockerfile
vophihungvn Aug 7, 2024
60a3ddd
feat: add package json fie
vophihungvn Aug 7, 2024
1aff6cf
update api
Aug 7, 2024
fbe1b11
feat: add env file
vophihungvn Aug 7, 2024
7f355a4
handle bugs
Aug 7, 2024
c181aa8
feat: integrate backend
vophihungvn Aug 7, 2024
4fd14e1
Merge branch 'examples/semiconductor' of github.com:aitomatic/openssa…
vophihungvn Aug 7, 2024
8392ec1
feat: integrate api
vophihungvn Aug 7, 2024
a4e3040
feat: refactor right pane
vophihungvn Aug 7, 2024
558dff6
feat: Add agent advice
vophihungvn Aug 7, 2024
36ada5a
feat: updated UI
vophihungvn Aug 8, 2024
e4e731c
fix typos
Aug 8, 2024
92330eb
fix placeholder
Aug 8, 2024
d8d787c
update examples/semiconductor/streamlit-main
TheVinhLuong102 Aug 10, 2024
16b9c3d
refactor examples/semiconductor/streamlit-main app
TheVinhLuong102 Aug 10, 2024
050f5b3
update examples/semiconductor/streamlit-main app
TheVinhLuong102 Aug 10, 2024
e90354a
feat: log time
vophihungvn Aug 12, 2024
302d9ce
minor edit in examples/semiconductor/agent module imports
TheVinhLuong102 Aug 13, 2024
97a4686
Merge branch 'main' of https://GitHub.com/Aitomatic/OpenSSA into exam…
TheVinhLuong102 Aug 30, 2024
96e81e5
feat: new UI
vophihungvn Sep 3, 2024
dbcb28a
fix: image width
vophihungvn Sep 3, 2024
72c4fa0
feat: response
vophihungvn Sep 5, 2024
fdba0d0
fix: get response from backend
vophihungvn Sep 5, 2024
b9fcf26
Merge branch 'main' of https://GitHub.com/Aitomatic/OpenSSA into exam…
TheVinhLuong102 Oct 1, 2024
f9204bb
Merge branch 'main' of https://GitHub.com/Aitomatic/OpenSSA into exam…
TheVinhLuong102 Oct 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ docs/_build/
# DATA & EXAMPLE FILES
# ====================
examples/**/*.json
!examples/**/package.json
!examples/**/package-lock.json


# Exception
!examples/semiconductor/semiconductor-ui/api/poetry.lock

.openssa/
test*.ipynb
tmp/
62 changes: 62 additions & 0 deletions examples/semiconductor/expert-knowledge.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
Etching Silicon Dioxide (SiO2): typical recipe(s)
=================================================

If using Inductively Coupled Plasma (ICP) Reactive Ion Etching (RIE)
--------------------------------------------------------------------


GASES & FLOW RATES:

Common gas is CHF3, often mixed with small amount of Ar and/or O2:
- CHF3 provides fluorine for etching while also polymerising to provide sidewall protection, improving anisotropy
- Ar helps maintain stable plasma
- O2 enhances volatility of etch products

Typical starting point:
- 20-50 sccm of CHF3
- 5-10 sccm of Ar
- 2-5 sccm of O2


ICP POWER:

Higher ICP power (e.g., 500-1000W) increases plasma density and etch rate
BUT may also lead to more physical damage and less anisotropic profiles


RF POWER:

Lower RF power (e.g., 10-50W) provides more anisotropic profiles


PRESSURE:

Lower pressure (e.g., 5-20 mTorr) helps improve anisotropy


ETCH TIME:

You need to adjust etch time depending on desired depth and etch rate.

Remember that etch rate can vary across wafer and over time, so it's best to overestimate time and measure depth periodically.


END-POINT DETECTION:

Many RIE systems have optical emission spectroscopy (OES) or interferometry for end-point detection.
These can stop etching process when desired depth is reached.


OPTIMIZATION CONSIDERATIONS:

- Etch rate
- Selectivity to mask and underlying layers
- Etch profile (anisotropy)
- Uniformity
- Physical or chemical damage


SAFETY PROCEDURES:

- Always follow safety procedures when working with plasma etching systems and handling gases
- Confirm with facility and equipment manager that your planned recipe is compatible and won't cause any damage or contamination
17 changes: 17 additions & 0 deletions examples/semiconductor/expert-programs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
plan:
task: |-
For etching PECVD SiO2 using Inductively Coupled Plasma (ICP) Reactive Ion Etching (RIE),
recommend 2 good parameter sets and their relative advantages/disadvantages

sub-htps:
- task: |-
Get typical gases used for such process and their flow rate ranges
in SiO2 etching using Inductively Coupled Plasma (ICP) Reactive Ion Etching (RIE)

- task: |-
Get typical ICP Power, RF Power and Pressure value ranges and associated trade-offs
in SiO2 etching using Inductively Coupled Plasma (ICP) Reactive Ion Etching (RIE)

- task: |-
Recommend 2 parameter sets (each including Flow Rate for each Gas, plus ICP Power, RF Power and Pressure)
with analysis of their relative pros and cons.
40 changes: 40 additions & 0 deletions examples/semiconductor/semiconductor-ui/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM --platform=linux/amd64 python:3.12-slim AS base

# Install Poetry
RUN apt update -y && apt upgrade -y && apt install git -y
RUN apt update -y && apt install poppler-utils -y
RUN python -m pip install --upgrade pip && \
pip install --no-cache-dir poetry==1.3.2


RUN poetry config virtualenvs.in-project true && \
poetry config installer.max-workers 10

WORKDIR /api

COPY pyproject.toml poetry.lock /api/

# =======================================
# Build image
FROM base AS build
ENV POETRY_REQUESTS_TIMEOUT=300
ENV PIP_DEFAULT_TIMEOUT=300
RUN poetry install

# =======================================
# App image
FROM base AS app

COPY --from=build /api/.venv /api/.venv

ENV PATH="/api/.venv/bin:$PATH"
ENV PATH="/api:$PATH"
# ENV PATH="/api/openssa:$PATH"
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH="/"

COPY . /api/

EXPOSE 8080

CMD ["sh", "start.sh"]
35 changes: 35 additions & 0 deletions examples/semiconductor/semiconductor-ui/api/data_and_knowledge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from __future__ import annotations

from pathlib import Path
from typing import TYPE_CHECKING

from dotenv import load_dotenv
import yaml

if TYPE_CHECKING:
from openssa.core.programming.hierarchical.plan import HTPDict


load_dotenv()


EXPERT_KNOWLEDGE_FILE_PATH: Path = Path(__file__).parent / 'expert-knowledge.txt'
with open(file=EXPERT_KNOWLEDGE_FILE_PATH,
buffering=-1,
encoding='utf-8',
errors='strict',
newline=None,
closefd=True,
opener=None) as f:
EXPERT_KNOWLEDGE: str = f.read()


EXPERT_PROGRAM_SPACE_FILE_PATH: Path = Path(__file__).parent / 'expert-program-space.yml'
with open(file=EXPERT_PROGRAM_SPACE_FILE_PATH,
buffering=-1,
encoding='utf-8',
errors='strict',
newline=None,
closefd=True,
opener=None) as f:
EXPERT_PROGRAM_SPACE: dict[str, HTPDict] = yaml.safe_load(stream=f)
62 changes: 62 additions & 0 deletions examples/semiconductor/semiconductor-ui/api/expert-knowledge.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
Etching Silicon Dioxide (SiO2): typical recipe(s)
=================================================

If using Inductively Coupled Plasma (ICP) Reactive Ion Etching (RIE)
--------------------------------------------------------------------


GASES & FLOW RATES:

Common gas is CHF3, often mixed with small amount of Ar and/or O2:
- CHF3 provides fluorine for etching while also polymerising to provide sidewall protection, improving anisotropy
- Ar helps maintain stable plasma
- O2 enhances volatility of etch products

Typical starting point:
- 20-50 sccm of CHF3
- 5-10 sccm of Ar
- 2-5 sccm of O2


ICP POWER:

Higher ICP power (e.g., 500-1000W) increases plasma density and etch rate
BUT may also lead to more physical damage and less anisotropic profiles


RF POWER:

Lower RF power (e.g., 10-50W) provides more anisotropic profiles


PRESSURE:

Lower pressure (e.g., 5-20 mTorr) helps improve anisotropy


ETCH TIME:

You need to adjust etch time depending on desired depth and etch rate.

Remember that etch rate can vary across wafer and over time, so it's best to overestimate time and measure depth periodically.


END-POINT DETECTION:

Many RIE systems have optical emission spectroscopy (OES) or interferometry for end-point detection.
These can stop etching process when desired depth is reached.


OPTIMIZATION CONSIDERATIONS:

- Etch rate
- Selectivity to mask and underlying layers
- Etch profile (anisotropy)
- Uniformity
- Physical or chemical damage


SAFETY PROCEDURES:

- Always follow safety procedures when working with plasma etching systems and handling gases
- Confirm with facility and equipment manager that your planned recipe is compatible and won't cause any damage or contamination
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
plan:
task: |-
For etching PECVD SiO2 using Inductively Coupled Plasma (ICP) Reactive Ion Etching (RIE),
recommend 2 good parameter sets and their relative advantages/disadvantages

sub-htps:
- task: |-
Get typical gases used for such process and their flow rate ranges
in SiO2 etching using Inductively Coupled Plasma (ICP) Reactive Ion Etching (RIE)

- task: |-
Get typical ICP Power, RF Power and Pressure value ranges and associated trade-offs
in SiO2 etching using Inductively Coupled Plasma (ICP) Reactive Ion Etching (RIE)

- task: |-
Recommend 2 parameter sets (each including Flow Rate for each Gas, plus ICP Power, RF Power and Pressure)
with analysis of their relative pros and cons.
136 changes: 136 additions & 0 deletions examples/semiconductor/semiconductor-ui/api/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import os
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from collections import defaultdict

Check notice on line 4 in examples/semiconductor/semiconductor-ui/api/main.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

examples/semiconductor/semiconductor-ui/api/main.py#L4

standard import "collections.defaultdict" should be placed before third party imports "fastapi.FastAPI", "fastapi.middleware.cors.CORSMiddleware"
import openai
from openssa import Agent, ProgramSpace, HTP, HTPlanner, OpenAILM


# pylint: disable=wrong-import-order
from data_and_knowledge import EXPERT_PROGRAM_SPACE, EXPERT_KNOWLEDGE
from semikong_lm import SemiKongLM


def get_or_create_agent(
use_semikong_lm: bool = True, max_depth=2, max_subtasks_per_decomp=4
) -> Agent:
lm = (SemiKongLM if use_semikong_lm else OpenAILM).from_defaults()

program_space = ProgramSpace(lm=lm)
if EXPERT_PROGRAM_SPACE:
for program_name, htp_dict in EXPERT_PROGRAM_SPACE.items():
htp = HTP.from_dict(htp_dict)
program_space.add_or_update_program(
name=program_name, description=htp.task.ask, program=htp
)

return Agent(
program_space=program_space,
programmer=HTPlanner(
lm=lm, max_depth=max_depth, max_subtasks_per_decomp=max_subtasks_per_decomp
),
knowledge={EXPERT_KNOWLEDGE} if EXPERT_KNOWLEDGE else None,
resources={},
)


import time

app = FastAPI()

app.add_middleware(
CORSMiddleware,
allow_origins=[os.environ.get("FRONTEND_URL", "http://localhost:4000")],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)

client = openai.OpenAI(api_key=os.environ["OPENAI_API_KEY"])

def call_gpt(prompt):
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{
"role": "system",
"content": "You are an expert in parsing text into a specific format. Please help me with this task.",
},
{"role": "user", "content": prompt},
],
)
return response.choices[0].message.content

def parse_recipe_text(text):
parsed_data = {"recipe_1": "", "recipe_2": "", "agent_advice": ""}
lines = text.split("\n")
current_section = None

for line in lines:
if "recipe_1:" in line:
current_section = "recipe_1"
elif "recipe_2:" in line:
current_section = "recipe_2"
elif "agent_advice:" in line:
current_section = "agent_advice"
elif current_section:
parsed_data[current_section] += line + "\n"

parsed_data = {key: value.strip() for key, value in parsed_data.items()}
return parsed_data

def solve_semiconductor_question(question):
start = time.time()
solutions = defaultdict(str)

solutions[question] = get_or_create_agent(use_semikong_lm=True).solve(
problem=question
)

print(f"get_or_create_agent taken: {time.time() - start}")
start = time.time()

solution = solutions[question]
solution = solution.replace("$", r"\$")

prompt = f"""{solution} \n\n Please help me parse the above text into this format:\n
recipe_1: Show the recipe 1 here\n
recipe_2: Show the recipe 2 here\n
agent_advice: Show the agent's general considerations here\n
DO NOT forget the key and DO NOT change the key format.
"""

solution = call_gpt(prompt)
print(f"call_gpt taken: {time.time() - start}")
start = time.time()
parsed_solution = parse_recipe_text(solution)
print(f"parse_recipe_text taken: {time.time() - start}")
return parsed_solution


@app.get("/")
async def root():
return {"message": "Hello World"}


@app.get("/data")
async def get_data():
return {"data": "data"}


@app.post("/data")
async def post_data(data: dict):
question = data.get("question")
if not question:
return {"error": "No question provided"}, 400

try:
parsed_answer = solve_semiconductor_question(question)
return parsed_answer
except Exception as e:

Check warning on line 130 in examples/semiconductor/semiconductor-ui/api/main.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

examples/semiconductor/semiconductor-ui/api/main.py#L130

Unused variable 'e'
# logger.error(f"Error solving the question: {e}")
# return {"error": str(e)}, 500
time.sleep(10)
return """
{'recipe_1': 'Parameters:\n- Gases and Flow Rates:\n - CHF3: 50 sccm\n - Ar: 10 sccm\n - O2: 5 sccm\n- ICP Power: 1000 W\n- RF Power: 50 W\n- Pressure: 20 mTorr\n- Etch Time: Start with 8 minutes and measure periodically\n\nPros:\n1. High Etch Rate: The high ICP power and higher flow rates of CHF3 and O2 increase the density of reactive species, leading to a faster etch rate.\n2. Stable Plasma: The addition of Ar at 10 sccm helps maintain a stable plasma, which is crucial for consistent etching.\n3. Improved Volatility: The higher O2 flow rate enhances the volatility of etch products, improving overall etch efficiency.\n\nCons:\n1. Physical Damage: The high ICP power and RF power can lead to more physical damage to the PR mask and underlying layers due to increased ion bombardment.\n2. Less Anisotropic Profiles: Higher RF power may result in less anisotropic etch profiles, which could be problematic for applications requiring precise vertical etching.\n3. Higher Pressure: The higher pressure may reduce the mean free path of ions, potentially affecting the directionality of the etch.', 'recipe_2': 'Parameters:\n- Gases and Flow Rates:\n - CHF3: 20 sccm\n - Ar: 5 sccm\n - O2: 2 sccm\n- ICP Power: 500 W\n- RF Power: 10 W\n- Pressure: 5 mTorr\n- Etch Time: Start with 15 minutes and measure periodically\n\nPros:\n1. High Anisotropy: The lower RF power and lower pressure will help achieve more anisotropic etch profiles, which is essential for applications requiring precise vertical etching.\n2. Reduced Physical Damage: Lower ICP and RF power reduce the risk of physical damage to the PR mask and underlying layers, making this set suitable for delicate structures.\n3. Directional Etching: The lower pressure improves the directionality of the etch by reducing the number of collisions between ions and neutral species.\n\nCons:\n1. Lower Etch Rate: The lower ICP power and reduced flow rates of CHF3 and O2 will result in a slower etch rate, requiring longer etch times to achieve the desired depth.\n2. Plasma Stability: The lower flow rate of Ar may make it more challenging to maintain a stable plasma, which could affect the consistency of the etch process.\n3. Process Control: The lower pressure and power settings require more precise control of the process parameters to maintain stability and achieve the desired etch profile.', 'agent_advice': '- Etch Rate and Uniformity: Regularly measure the etch depth to ensure uniformity across the wafer. Adjust the etch time accordingly.\n- End-Point Detection: Utilize optical emission spectroscopy (OES) or interferometry if available on the Plasmalab System 100 to accurately determine the end-point of the etch process.\n- Safety Procedures: Always follow safety protocols when handling gases and operating the ICP RIE system. Confirm with the facility manager that the chosen recipe is compatible with the equipment.\n\nBy starting with these recipes and making necessary adjustments based on periodic measurements and observations, you should be able to achieve the desired etch depth and profile for your SiO2 pattern.\n```'}
"""
Loading
Loading