garvitsachdeva commited on
Commit
e8360fd
Β·
1 Parent(s): a798c01

Fix CPU training + 1902ms step speed bottleneck

Browse files
Files changed (2) hide show
  1. app.py +9 -15
  2. requirements.txt +3 -0
app.py CHANGED
@@ -14,23 +14,9 @@ Training starts automatically when the Space boots.
14
  Refresh the page or click "Refresh" to see live progress.
15
  """
16
 
17
- import sys, os, subprocess
18
  print("=== PYTHON STARTED ===", flush=True)
19
 
20
- # Force CUDA-enabled PyTorch β€” the default PyPI wheel is CPU-only.
21
- # This must run before any `import torch` in the process.
22
- print("Installing CUDA torch...", flush=True)
23
- _r = subprocess.run(
24
- [sys.executable, "-m", "pip", "install", "-q",
25
- "--index-url", "https://download.pytorch.org/whl/cu121",
26
- "torch>=2.2.0"],
27
- capture_output=True, text=True,
28
- )
29
- if _r.returncode == 0:
30
- print("CUDA torch installed OK.", flush=True)
31
- else:
32
- print("CUDA torch install warning:", _r.stderr[-300:], flush=True)
33
-
34
  import gradio as gr
35
  print("=== GRADIO IMPORTED ===", flush=True)
36
 
@@ -153,6 +139,14 @@ def _training_thread():
153
  SpindleFlowEnv._call_specialist = _new_call
154
  SpindleFlowEnv._simulate_patched = True
155
 
 
 
 
 
 
 
 
 
156
  # ── Smoke test ──────────────────────────────────────
157
  _log("Running smoke test...")
158
  env = SpindleFlowEnv(
 
14
  Refresh the page or click "Refresh" to see live progress.
15
  """
16
 
17
+ import sys, os
18
  print("=== PYTHON STARTED ===", flush=True)
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  import gradio as gr
21
  print("=== GRADIO IMPORTED ===", flush=True)
22
 
 
139
  SpindleFlowEnv._call_specialist = _new_call
140
  SpindleFlowEnv._simulate_patched = True
141
 
142
+ # ── Disable Tier-2 LLM scoring during training ───────
143
+ # TieredRewardScorer._tier2_score calls OpenAI API (>1000ms per episode).
144
+ # Returning None forces it to fall back to Tier-1 embedding scoring (~fast),
145
+ # preserving a meaningful reward signal without API latency.
146
+ from reward.tiered_reward import TieredRewardScorer
147
+ TieredRewardScorer._get_openai_client = lambda self: None
148
+ _log("TieredRewardScorer β†’ Tier-1 only (LLM judge disabled for speed) βœ“")
149
+
150
  # ── Smoke test ──────────────────────────────────────
151
  _log("Running smoke test...")
152
  env = SpindleFlowEnv(
requirements.txt CHANGED
@@ -1,3 +1,6 @@
 
 
 
1
  openenv>=0.1.0
2
  stable-baselines3>=2.3.0
3
  sb3-contrib>=2.3.0
 
1
+ --index-url https://download.pytorch.org/whl/cu121
2
+ --extra-index-url https://pypi.org/simple
3
+ torch
4
  openenv>=0.1.0
5
  stable-baselines3>=2.3.0
6
  sb3-contrib>=2.3.0