Spaces:
Running on Zero
Running on Zero
Run on a full H200 slice (xlarge)
Browse filesFiles changed (2)
- app.py+3-1
- run_examples.pyAdded+47
97 unmodified lines989910010110210310480 unmodified lines18518618718818919097 unmodified linesif not MOCK:@spaces.GPU(duration=_gpu_seconds)def generate(inputs, thinking, n_frames):"""Greedy generation on the GPU, streaming text as it is produced."""batch = {k: (v.to("cuda") if hasattr(v, "to") else v) for k, v in inputs.items()}80 unmodified linesif time.time() - last > 0.25:last = time.time()yield msg(stage="generating", partial=acc)reasoning, answer = None, acc.strip()if thinking: # no closing tag = the reasoning used the whole budget = no answerhead, sep, tail = acc.partition("</think>")97 unmodified lines989910010110210310480 unmodified lines18518618718818919019119297 unmodified linesif not MOCK:@spaces.GPU(duration=_gpu_seconds, size="xlarge") # 54.7 GB of bf16 weights: a "large" slice has ~51 GBdef generate(inputs, thinking, n_frames):"""Greedy generation on the GPU, streaming text as it is produced."""batch = {k: (v.to("cuda") if hasattr(v, "to") else v) for k, v in inputs.items()}80 unmodified linesif time.time() - last > 0.25:last = time.time()yield msg(stage="generating", partial=acc)if t1 is None:raise gr.Error("The GPU run failed before generating. Try again in a minute.")reasoning, answer = None, acc.strip()if thinking: # no closing tag = the reasoning used the whole budget = no answerhead, sep, tail = acc.partition("</think>")
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647"""Run example clips through the live Space (release config, thinking on) and save outputs for build_examples.py.
python3 app/space/run_examples.py galaxea_047 steps ... (needs HF_TOKEN with access to the private Space)"""import jsonimport osimport sysimport time
from gradio_client import Client
HERE = os.path.dirname(os.path.abspath(__file__))SPACE = os.environ.get("TEMPORA_SPACE", "infinitylogesh/tempora-27b")EXAMPLES = {e["id"]: e for e in json.load(open(os.path.join(HERE, "static", "examples.json")))}
def run(client, ex_id, thinking=True): ex = EXAMPLES[ex_id] t0, last = time.time(), None job = client.submit(video=None, example=ex_id, instruction=ex["instruction"], task=ex["task"], fields=json.dumps(ex["fields"]), thinking=thinking, api_name="/segment") for out in job: d = json.loads(out) if d["stage"] != last: print(f" {ex_id} [{time.time() - t0:5.0f}s] {d['stage']}" + (f" frames={d.get('frames')} input_tokens={d.get('input_tokens')}" if d["stage"] == "queued" else ""), flush=True) last = d["stage"] d = json.loads(job.outputs()[-1]) assert d["stage"] == "done", d assert d["prompt"] == ex["prompt"], "the Space built a different prompt than the example's" return d
def main(): client = Client(SPACE, token=os.environ["HF_TOKEN"], verbose=False) os.makedirs(os.path.join(HERE, "example_outputs"), exist_ok=True) for ex_id in sys.argv[1:]: d = run(client, ex_id) st = d.get("stats", {}) print(f"{ex_id}: {len(d['chunks'] or [])} chunks, {st.get('output_tokens')} output tokens, " f"{st.get('generate_s')} s generating, {st.get('seconds')} s total, truncated={d.get('truncated')}") json.dump(d, open(os.path.join(HERE, "example_outputs", f"{ex_id}.json"), "w"), indent=1, ensure_ascii=False)
if __name__ == "__main__": main()app.py+3-1
run_examples.pyAdded+47