Spaces:
Running on Zero
Running on Zero
Private BF16 ZeroGPU model bring-up
Browse files- README.md +13 -7
- app.py +45 -0
- packages.txt +7 -0
- requirements.txt +14 -0
README.md
CHANGED
|
@@ -1,13 +1,19 @@
|
|
| 1 |
---
|
| 2 |
-
title: RAP
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
-
python_version:
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
|
|
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: RAP — Paper to Poster
|
| 3 |
+
emoji: 📰
|
| 4 |
+
colorFrom: purple
|
| 5 |
+
colorTo: blue
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 5.50.0
|
| 8 |
+
python_version: 3.10
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
| 11 |
+
startup_duration_timeout: 1h
|
| 12 |
+
short_description: Turn a research paper into an editable academic poster
|
| 13 |
---
|
| 14 |
|
| 15 |
+
# RAP — Paper to Poster
|
| 16 |
+
|
| 17 |
+
Deployment validation in progress. RL checkpoint-240, BF16, no quantization.
|
| 18 |
+
The model repository remains private; its access token is a server-side Secret.
|
| 19 |
+
ZeroGPU xlarge is requested per generation. No dedicated paid GPU is used.
|
app.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Private bring-up app. Replaced by the paper-to-poster UI after validation."""
|
| 2 |
+
import spaces
|
| 3 |
+
import os
|
| 4 |
+
import json
|
| 5 |
+
import shutil
|
| 6 |
+
import time
|
| 7 |
+
import torch
|
| 8 |
+
import gradio as gr
|
| 9 |
+
import psutil
|
| 10 |
+
from transformers import AutoModelForImageTextToText, AutoProcessor
|
| 11 |
+
|
| 12 |
+
REPO = "VincentHancoder/RAP-Qwen3.8-27B-SFT-RL"
|
| 13 |
+
REVISION = "50f3adc4ebb9b19e53ef9c21c293993a77bf3fd7"
|
| 14 |
+
print("STARTUP", json.dumps({"ram_gib": psutil.virtual_memory().total / 2**30,
|
| 15 |
+
"disk_free_gib": shutil.disk_usage(".").free / 2**30,
|
| 16 |
+
"torch": torch.__version__}), flush=True)
|
| 17 |
+
processor = AutoProcessor.from_pretrained(REPO, revision=REVISION, token=os.environ.get("HF_TOKEN"))
|
| 18 |
+
model = AutoModelForImageTextToText.from_pretrained(
|
| 19 |
+
REPO, revision=REVISION, token=os.environ.get("HF_TOKEN"), dtype=torch.bfloat16,
|
| 20 |
+
device_map="cuda:0", attn_implementation="sdpa",
|
| 21 |
+
)
|
| 22 |
+
model.eval()
|
| 23 |
+
model.config.use_cache = True
|
| 24 |
+
model.config.text_config.use_cache = True
|
| 25 |
+
print("RAP_MODEL_READY", flush=True)
|
| 26 |
+
|
| 27 |
+
@spaces.GPU(size="xlarge", duration=120)
|
| 28 |
+
def probe(prompt):
|
| 29 |
+
start = time.monotonic()
|
| 30 |
+
messages = [{"role": "user", "content": [{"type": "text", "text": prompt[:1000]}]}]
|
| 31 |
+
inputs = processor.apply_chat_template(messages, tokenize=True, add_generation_prompt=True,
|
| 32 |
+
enable_thinking=False, return_dict=True, return_tensors="pt").to("cuda")
|
| 33 |
+
with torch.inference_mode():
|
| 34 |
+
result = model.generate(**inputs, max_new_tokens=64, do_sample=False, use_cache=True,
|
| 35 |
+
repetition_penalty=1.1, temperature=None, top_p=None, top_k=None)
|
| 36 |
+
output = processor.decode(result[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
|
| 37 |
+
return {"text": output, "seconds": round(time.monotonic()-start, 2),
|
| 38 |
+
"gpu": torch.cuda.get_device_name(), "dtype": str(next(model.parameters()).dtype)}
|
| 39 |
+
|
| 40 |
+
with gr.Blocks() as demo:
|
| 41 |
+
gr.Markdown("# RAP deployment validation\nRL checkpoint-240 · BF16 · ZeroGPU xlarge")
|
| 42 |
+
p = gr.Textbox(value="Write a short HTML heading for a research poster.")
|
| 43 |
+
out = gr.JSON()
|
| 44 |
+
gr.Button("Validate GPU").click(probe, p, out, api_name="probe")
|
| 45 |
+
demo.queue(default_concurrency_limit=1, max_size=8).launch(show_error=False)
|
packages.txt
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
chromium
|
| 2 |
+
fonts-dejavu-core
|
| 3 |
+
fonts-liberation
|
| 4 |
+
fonts-noto-core
|
| 5 |
+
fonts-noto-cjk
|
| 6 |
+
libgl1
|
| 7 |
+
libglib2.0-0
|
requirements.txt
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
torch==2.9.1
|
| 2 |
+
torchvision==0.24.1
|
| 3 |
+
transformers==5.2.0
|
| 4 |
+
accelerate>=1.10,<2
|
| 5 |
+
flash-linear-attention==0.5.2
|
| 6 |
+
fla-core==0.5.2
|
| 7 |
+
pymupdf==1.27.2.3
|
| 8 |
+
pillow>=11,<13
|
| 9 |
+
beautifulsoup4>=4.13,<5
|
| 10 |
+
playwright==1.58.0
|
| 11 |
+
spaces
|
| 12 |
+
psutil
|
| 13 |
+
timm==0.9.16
|
| 14 |
+
sentencepiece
|