File size: 1,609 Bytes
485813e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | from typing import TypedDict, Optional, List, Any, Annotated
import operator
class MigrationState(TypedDict):
# ── Input ──────────────────────────────────────────────────────────────────
cuda_code: str
kernel_name: str
simple_mode: bool
# ── Intermediate results (pydantic model instances stored as Any) ──────────
analyzer_result: Optional[Any] # AnalyzerResult
translator_result: Optional[Any] # TranslatorResult
optimizer_result: Optional[Any] # OptimizerResult
tester_result: Optional[Any] # TesterResult
# ── Control flow ───────────────────────────────────────────────────────────
iteration: int # incremented each time optimizer node runs
max_iterations: int # default 3
should_retry: bool
# ── Output ─────────────────────────────────────────────────────────────────
migration_success: bool
final_report: dict
# ── SSE event accumulator — LangGraph appends each node's new events ───────
# operator.add reducer: each node returns a *list of new events*;
# LangGraph concatenates them into a single growing list.
events: Annotated[List[dict], operator.add]
|