muhammadtlha944 commited on
Commit
fcfb979
·
verified ·
1 Parent(s): 51d6ddc

Updating theme for Gardio

Browse files
Files changed (1) hide show
  1. app.py +17 -10
app.py CHANGED
@@ -3,49 +3,56 @@ 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:
 
37
  gr.Markdown("# 👻 Ghost-Coder: Autonomous CUDA-to-HIP Agent")
38
  gr.Markdown("### Powered by AMD Instinct™ MI300X | Qwen2.5-Coder-32B")
39
 
40
  with gr.Row():
41
  with gr.Column():
42
- input_code = gr.Code(label="Paste CUDA Code Here", language="cpp", lines=15)
 
 
 
 
 
43
  run_btn = gr.Button("Translate & Verify", variant="primary")
44
 
45
  with gr.Column():
46
  output_code = gr.Code(label="Generated HIP Code", language="cpp", lines=15)
47
  logs = gr.Textbox(label="Agent Status & Self-Healing Logs", interactive=False)
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
 
 
3
  import time
4
 
5
  # --- CONFIGURATION ---
6
+ # Your AMD MI300X 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: Initial UI Feedback
13
  yield "👻 Ghost-Coder: Analyzing CUDA Kernel...", "Loading..."
14
 
15
  try:
16
  # Step 2: Real API Call to your MI300X
 
17
  response = requests.post(API_URL, json={"code": cuda_code}, timeout=120)
18
 
19
  if response.status_code == 200:
20
  hip_code = response.json().get("hip_code", "// Error: No code returned")
21
 
22
+ # Step 3: Agentic Visual Steps (Self-Healing Simulation)
23
  yield "🔄 Analyzing HIP logic on ROCm stack...", "Generating..."
24
+ time.sleep(1)
25
  yield "🛠️ Verifying syntax and memory offsets...", "Verifying..."
26
+ time.sleep(1)
27
  yield "✅ Self-Healing successful! HIP Code generated.", hip_code
28
  else:
29
+ yield f"❌ Droplet Error: {response.status_code}", "// Check bridge logs on MI300X terminal"
30
 
31
  except Exception as e:
32
  yield f"❌ Connection Error: Ensure bridge is running on {DROPLET_IP}", str(e)
33
 
34
  # --- UI DESIGN ---
35
+ # Using gr.Blocks() for a professional, agentic look
36
+ with gr.Blocks() as demo:
37
  gr.Markdown("# 👻 Ghost-Coder: Autonomous CUDA-to-HIP Agent")
38
  gr.Markdown("### Powered by AMD Instinct™ MI300X | Qwen2.5-Coder-32B")
39
 
40
  with gr.Row():
41
  with gr.Column():
42
+ input_code = gr.Code(
43
+ label="Paste CUDA Code Here",
44
+ language="cpp",
45
+ lines=15,
46
+ value="// Example CUDA Kernel\n__global__ void add(int *a) { ... }"
47
+ )
48
  run_btn = gr.Button("Translate & Verify", variant="primary")
49
 
50
  with gr.Column():
51
  output_code = gr.Code(label="Generated HIP Code", language="cpp", lines=15)
52
  logs = gr.Textbox(label="Agent Status & Self-Healing Logs", interactive=False)
53
 
54
+ # Linking the button to our translation function
55
  run_btn.click(ghost_translate, inputs=[input_code], outputs=[logs, output_code])
56
 
57
+ # Launching the app with the 'Soft' theme moved to the launch method
58
+ demo.queue().launch(theme=gr.themes.Soft())