Adding real droplet TIP and real-time simulations
Browse files
app.py
CHANGED
|
@@ -2,21 +2,35 @@ import gradio as gr
|
|
| 2 |
import requests
|
| 3 |
import time
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
# --- LOGIC ---
|
| 6 |
def ghost_translate(cuda_code):
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
yield "π» Ghost-Coder: Analyzing CUDA Kernel...", ""
|
| 10 |
-
time.sleep(1)
|
| 11 |
-
|
| 12 |
-
yield "π Translating to HIP (AMD ROCm)...", ""
|
| 13 |
-
time.sleep(2)
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
# --- UI DESIGN ---
|
| 22 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
@@ -34,4 +48,4 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 34 |
|
| 35 |
run_btn.click(ghost_translate, inputs=[input_code], outputs=[logs, output_code])
|
| 36 |
|
| 37 |
-
demo.launch()
|
|
|
|
| 2 |
import requests
|
| 3 |
import time
|
| 4 |
|
| 5 |
+
# --- CONFIGURATION ---
|
| 6 |
+
# Replace this with your actual Droplet IP
|
| 7 |
+
DROPLET_IP = "134.199.195.151"
|
| 8 |
+
API_URL = f"http://{DROPLET_IP}:8080/translate"
|
| 9 |
+
|
| 10 |
# --- LOGIC ---
|
| 11 |
def ghost_translate(cuda_code):
|
| 12 |
+
# Step 1: UI Feedback
|
| 13 |
+
yield "π» Ghost-Coder: Analyzing CUDA Kernel...", "Loading..."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
try:
|
| 16 |
+
# Step 2: Real API Call to your MI300X
|
| 17 |
+
# We wrap this in a try/except in case the bridge isn't reachable
|
| 18 |
+
response = requests.post(API_URL, json={"code": cuda_code}, timeout=120)
|
| 19 |
+
|
| 20 |
+
if response.status_code == 200:
|
| 21 |
+
hip_code = response.json().get("hip_code", "// Error: No code returned")
|
| 22 |
+
|
| 23 |
+
# Step 3: Simulate the 'Self-Healing' steps for visual impact
|
| 24 |
+
yield "π Analyzing HIP logic on ROCm stack...", "Generating..."
|
| 25 |
+
time.sleep(1.5)
|
| 26 |
+
yield "π οΈ Verifying syntax and memory offsets...", "Verifying..."
|
| 27 |
+
time.sleep(1.5)
|
| 28 |
+
yield "β
Self-Healing successful! HIP Code generated.", hip_code
|
| 29 |
+
else:
|
| 30 |
+
yield f"β Droplet Error: {response.status_code}", "// Check bridge logs on MI300X"
|
| 31 |
+
|
| 32 |
+
except Exception as e:
|
| 33 |
+
yield f"β Connection Error: Ensure bridge is running on {DROPLET_IP}", str(e)
|
| 34 |
|
| 35 |
# --- UI DESIGN ---
|
| 36 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
|
|
| 48 |
|
| 49 |
run_btn.click(ghost_translate, inputs=[input_code], outputs=[logs, output_code])
|
| 50 |
|
| 51 |
+
demo.queue().launch() # Added .queue() for better streaming performance
|