| from pydantic import BaseModel |
| from typing import Optional, List |
| from enum import Enum |
|
|
|
|
| class AgentStatus(str, Enum): |
| WAITING = "waiting" |
| RUNNING = "running" |
| DONE = "done" |
| FAILED = "failed" |
| RETRYING = "retrying" |
|
|
|
|
| class WorkloadType(str, Enum): |
| COMPUTE_BOUND = "compute-bound" |
| MEMORY_BOUND = "memory-bound" |
| UNKNOWN = "unknown" |
|
|
|
|
| class PortRequest(BaseModel): |
| cuda_code: str |
| kernel_name: Optional[str] = "custom" |
| simple_mode: Optional[bool] = False |
|
|
|
|
| class ColdStartRequest(BaseModel): |
| cuda_code: str |
| kernel_name: Optional[str] = "unknown_input" |
|
|
|
|
| class AggregateMetricsRequest(BaseModel): |
| kernel_names: Optional[List[str]] = None |
|
|
|
|
| class AgentEvent(BaseModel): |
| agent: str |
| status: AgentStatus |
| message: str |
| detail: Optional[str] = None |
|
|
|
|
| class VerificationResult(BaseModel): |
| compiled_successfully: bool |
| executed_without_error: bool |
| output_matches_expected: bool |
| checksum_computed: Optional[str] = None |
| expected_checksum: Optional[str] = None |
| actual_checksum: Optional[str] = None |
| mock_mode: Optional[bool] = False |
|
|
|
|
| class CostEstimate(BaseModel): |
| manual_porting_weeks: str |
| rocmport_minutes: str |
| estimated_savings: str |
| complexity_factor: str |
|
|
|
|
| class RiskItem(BaseModel): |
| """One flagged pattern found by the pure-Python static scanner.""" |
| line: Optional[int] = None |
| pattern: str |
| risk_level: str |
| description: str |
| amd_fix_hint: str |
|
|
|
|
| class StaticRiskReport(BaseModel): |
| """Aggregated output of the static wavefront correctness scanner.""" |
| items: List[RiskItem] |
| critical_count: int |
| high_count: int |
| medium_count: int |
| scan_duration_ms: float |
|
|
|
|
| class AnalyzerResult(BaseModel): |
| kernels_found: List[str] |
| cuda_apis: List[str] |
| warp_size_issue: bool |
| warp_size_detail: Optional[str] |
| workload_type: WorkloadType |
| sharding_detected: bool |
| difficulty: str |
| difficulty_reason: str |
| prediction: Optional[str] = None |
| line_count: Optional[int] = None |
| complexity_score: Optional[int] = None |
| static_risk_report: Optional[StaticRiskReport] = None |
|
|
|
|
| class TranslatorResult(BaseModel): |
| hip_code: str |
| total_changes: int |
| hipify_changes: int |
| llm_changes: int |
| diff_lines: List[dict] |
|
|
|
|
| class OptimizerResult(BaseModel): |
| optimized_code: str |
| changes: List[dict] |
| iteration: int |
|
|
|
|
| class TesterResult(BaseModel): |
| success: bool |
| iteration: int |
| speedup: float |
| bandwidth_utilized: float |
| execution_ms: float |
| bottleneck: str |
| notes: str |
| |
| verification: Optional[VerificationResult] = None |
| data_source: Optional[str] = None |
|
|
|
|
| class FinalReport(BaseModel): |
| migration_success: bool |
| speedup: float |
| bandwidth_utilized: float |
| total_changes: int |
| bottleneck: str |
| amd_advantage_explanation: str |
| iterations: int |
| hip_code: str |
| optimized_code: str |
| verification: Optional[VerificationResult] = None |
| cost_estimate: Optional[CostEstimate] = None |
| |
| simplified_explanation: Optional[str] = None |
| |
| static_risk_report: Optional[StaticRiskReport] = None |
| |
| data_source: str = "simulated" |
|
|