Spaces:
Running on Zero
Running on Zero
atakan Claude Sonnet 5 commited on
Commit ·
01c9d8d
1
Parent(s): a22c85e
debug: Add timing/token-count diagnostics and explicit EOS to PyTorch generate()
Browse filesGeneration is taking 3-5+ minutes even confirmed on a real GPU
(RTX Pro 6000), which no longer fits a "just needs a bigger duration
budget" explanation. Two changes: (1) explicitly pass eos_token_id
(<|im_end|> / <|endoftext|>) and clear conflicting sampling params
instead of relying on the loaded GenerationConfig, in case that's why
it isn't stopping early; (2) log prompt token count, generated token
count, elapsed time, and tok/s around the actual generate() call so
the next attempt tells us definitively whether it's stuck before
generation, silently running the full max_new_tokens ceiling, or
genuinely just slow per-token.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
controlai_agent/orchestrator.py
CHANGED
|
@@ -283,16 +283,31 @@ class ControlAIAgent:
|
|
| 283 |
verbose=False,
|
| 284 |
).strip()
|
| 285 |
else:
|
|
|
|
| 286 |
import torch
|
| 287 |
inputs = self.hf_tokenizer(prompt, return_tensors="pt").to(self.model.device)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 288 |
with torch.no_grad():
|
| 289 |
outputs = self.model.generate(
|
| 290 |
**inputs,
|
| 291 |
max_new_tokens=max_tokens,
|
| 292 |
do_sample=False,
|
| 293 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 294 |
)
|
| 295 |
-
new_tokens = outputs[0][
|
|
|
|
|
|
|
| 296 |
return self.hf_tokenizer.decode(new_tokens, skip_special_tokens=True).strip()
|
| 297 |
|
| 298 |
def _get_grounded_instruction(self, user_prompt: str, base_instruction: str) -> str:
|
|
|
|
| 283 |
verbose=False,
|
| 284 |
).strip()
|
| 285 |
else:
|
| 286 |
+
import time as _time
|
| 287 |
import torch
|
| 288 |
inputs = self.hf_tokenizer(prompt, return_tensors="pt").to(self.model.device)
|
| 289 |
+
prompt_tokens = inputs["input_ids"].shape[1]
|
| 290 |
+
eos_ids = [
|
| 291 |
+
tid
|
| 292 |
+
for tid in (self.hf_tokenizer.eos_token_id, self.hf_tokenizer.convert_tokens_to_ids("<|im_end|>"))
|
| 293 |
+
if tid is not None and tid >= 0
|
| 294 |
+
] or None
|
| 295 |
+
t0 = _time.time()
|
| 296 |
+
print(f"[_generate] starting: prompt_tokens={prompt_tokens} max_new_tokens={max_tokens} eos_ids={eos_ids}")
|
| 297 |
with torch.no_grad():
|
| 298 |
outputs = self.model.generate(
|
| 299 |
**inputs,
|
| 300 |
max_new_tokens=max_tokens,
|
| 301 |
do_sample=False,
|
| 302 |
+
temperature=None,
|
| 303 |
+
top_p=None,
|
| 304 |
+
top_k=None,
|
| 305 |
+
eos_token_id=eos_ids,
|
| 306 |
+
pad_token_id=self.hf_tokenizer.pad_token_id or self.hf_tokenizer.eos_token_id,
|
| 307 |
)
|
| 308 |
+
new_tokens = outputs[0][prompt_tokens:]
|
| 309 |
+
elapsed = _time.time() - t0
|
| 310 |
+
print(f"[_generate] done: generated_tokens={len(new_tokens)} elapsed={elapsed:.1f}s ({len(new_tokens)/max(elapsed,0.001):.1f} tok/s)")
|
| 311 |
return self.hf_tokenizer.decode(new_tokens, skip_special_tokens=True).strip()
|
| 312 |
|
| 313 |
def _get_grounded_instruction(self, user_prompt: str, base_instruction: str) -> str:
|