import gradio as gr import requests import time # --- CONFIGURATION --- # Replace with your actual URLs DROPLET_IP = "134.199.195.151" API_URL = "https://djrbe-134-199-192-140.run.pinggy-free.link/translate" LABLAB_URL = "https://lablab.ai/event/amd-ai-hackathon/ghost-coder" # Update this link! # --- LOGIC --- def ghost_translate(cuda_code): yield "👻 Ghost-Coder: Analyzing CUDA Kernel...", "Loading..." try: # Standard marker for backend slicing split_marker = "// --- GHOST-CODER HIP OUTPUT ---" formatted_prompt = f"""Task: Translate the following CUDA code to AMD HIP. Output ONLY valid C++ code. Do not include markdown blocks or explanations. // --- ORIGINAL CUDA CODE --- {cuda_code} {split_marker} """ response = requests.post(API_URL, json={"code": formatted_prompt}, timeout=120) if response.status_code == 200: raw_response = response.json().get("hip_code", "") # Hard Slice logic to ensure clean output if split_marker in raw_response: hip_code = raw_response.split(split_marker)[-1].strip() else: hip_code = raw_response.strip() # Agentic Visual Feedback yield "🔄 Analyzing HIP logic on ROCm stack...", "Generating..." time.sleep(1) yield "🛠️ Verifying syntax and memory offsets...", "Verifying..." time.sleep(1) yield "✅ Self-Healing successful! HIP Code generated.", hip_code else: yield f"❌ Droplet Error: {response.status_code}", "// Check bridge logs on MI300X" except Exception as e: yield f"❌ Connection Error: Ensure bridge is running", str(e) # --- UI DESIGN --- with gr.Blocks(css=".banner { margin-bottom: 20px; }") as demo: # Header Banner - Wrapped for maximum compatibility with gr.Row(): gr.HTML(f"""
The AMD MI300X instance for this live demo has been paused following the conclusion of the hackathon credit period.
View Full Video Demo & Technical Pitch