muhammadtlha944 commited on
Commit
51d6ddc
Β·
verified Β·
1 Parent(s): 84a3a22

Adding real droplet TIP and real-time simulations

Browse files
Files changed (1) hide show
  1. app.py +27 -13
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
- # This will eventually point to your MI300X droplet's IP
8
- # For now, we simulate the "Ghost" agentic flow for the UI
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
- # Simulating a self-healing loop
16
- yield "πŸ› οΈ Compilation Attempt 1: detected missing semicolon...", "Error: expected ';' at line 4"
17
- time.sleep(2)
18
-
19
- yield "βœ… Self-Healing successful! HIP Code generated.", "Final HIP Code Generated & Verified."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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