garvitsachdeva commited on
Commit
b71b25c
Β·
1 Parent(s): 236d9fb

perf: force ST to CUDA, disable LLM tasks, reduce to 100k steps

Browse files
Files changed (2) hide show
  1. app.py +20 -1
  2. configs/training_config.yaml +3 -3
app.py CHANGED
@@ -105,6 +105,25 @@ def _training_thread():
105
  api = HfApi(token=HF_TOKEN)
106
  api.create_repo(repo_id=HF_REPO, repo_type="model", exist_ok=True)
107
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  # ── Patch env for simulate_specialists ──────────────
109
  _log("Loading environment...")
110
  from env.spindleflow_env import SpindleFlowEnv
@@ -286,7 +305,7 @@ def _training_thread():
286
  )
287
  periodic_push = PeriodicHubPush(
288
  api=api, hf_repo=HF_REPO, hf_token=HF_TOKEN,
289
- vec_env=vec_env, push_every=50_000,
290
  )
291
 
292
  model.learn(
 
105
  api = HfApi(token=HF_TOKEN)
106
  api.create_repo(repo_id=HF_REPO, repo_type="model", exist_ok=True)
107
 
108
+ # ── Force SentenceTransformer onto CUDA ─────────────
109
+ # encode() is called every step (scratchpad) + per specialist call.
110
+ # On CPU this costs ~250 ms/call β†’ ~1 s/step. On CUDA it's ~10 ms.
111
+ _log("Patching SentenceTransformer to CUDA...")
112
+ import torch as _torch_st
113
+ if _torch_st.cuda.is_available():
114
+ try:
115
+ from sentence_transformers import SentenceTransformer as _ST
116
+ _orig_st_init = _ST.__init__
117
+ def _fast_st_init(self, *args, **kwargs):
118
+ kwargs.setdefault("device", "cuda")
119
+ _orig_st_init(self, *args, **kwargs)
120
+ _ST.__init__ = _fast_st_init
121
+ _log("SentenceTransformer β†’ cuda βœ“")
122
+ except Exception as _ep:
123
+ _log(f"ST patch skipped: {_ep}")
124
+ else:
125
+ _log("WARNING: CUDA not available for SentenceTransformer β€” CPU mode (slow)")
126
+
127
  # ── Patch env for simulate_specialists ──────────────
128
  _log("Loading environment...")
129
  from env.spindleflow_env import SpindleFlowEnv
 
305
  )
306
  periodic_push = PeriodicHubPush(
307
  api=api, hf_repo=HF_REPO, hf_token=HF_TOKEN,
308
+ vec_env=vec_env, push_every=10_000,
309
  )
310
 
311
  model.learn(
configs/training_config.yaml CHANGED
@@ -1,7 +1,7 @@
1
  training:
2
  seed: 42
3
- total_timesteps: 500000
4
- n_envs: 4
5
  device: "auto" # "cuda" if available, else "cpu"
6
 
7
  ppo:
@@ -71,7 +71,7 @@ environment:
71
  sector:
72
  name: "software_engineering" # Change this to switch domains
73
  description: "Software product development including frontend, backend, databases, devops, and security"
74
- use_llm_task_generation: true # Set false to fall back to catalog-derived tasks
75
  llm_task_model: "gpt-4o-mini"
76
  task_cache_size: 200 # Large cache reduces refill frequency; background thread handles refills
77
  # Technology stack injected into ambiguous task descriptions by TaskDecomposer.
 
1
  training:
2
  seed: 42
3
+ total_timesteps: 100000
4
+ n_envs: 1
5
  device: "auto" # "cuda" if available, else "cpu"
6
 
7
  ppo:
 
71
  sector:
72
  name: "software_engineering" # Change this to switch domains
73
  description: "Software product development including frontend, backend, databases, devops, and security"
74
+ use_llm_task_generation: false # Set false to fall back to catalog-derived tasks
75
  llm_task_model: "gpt-4o-mini"
76
  task_cache_size: 200 # Large cache reduces refill frequency; background thread handles refills
77
  # Technology stack injected into ambiguous task descriptions by TaskDecomposer.