Spaces:
Running on Zero
Running on Zero
Load 8B directly inside allocated ZeroGPU call
Browse files- app.py +13 -9
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -42,11 +42,7 @@ gte_model = None
|
|
| 42 |
|
| 43 |
QWEN8_MODEL_PATH = Path("/models/qwen3-embedding-8b")
|
| 44 |
qwen8_tokenizer = AutoTokenizer.from_pretrained(QWEN8_MODEL_PATH, padding_side="left")
|
| 45 |
-
qwen8_model =
|
| 46 |
-
QWEN8_MODEL_PATH,
|
| 47 |
-
dtype=torch.bfloat16,
|
| 48 |
-
trust_remote_code=True,
|
| 49 |
-
).to("cuda").eval()
|
| 50 |
|
| 51 |
|
| 52 |
def detailed_instruction(query: str) -> str:
|
|
@@ -293,10 +289,18 @@ def _run_family_bf16_control(family: str) -> dict:
|
|
| 293 |
allocation_before = int(torch.cuda.memory_allocated())
|
| 294 |
if family == "qwen3-embedding-8b":
|
| 295 |
family_tokenizer = qwen8_tokenizer
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 300 |
else:
|
| 301 |
raise RuntimeError("GTE 1.5B BF16 control is offline during the 8B phase")
|
| 302 |
allocation_after_load = int(torch.cuda.memory_allocated())
|
|
|
|
| 42 |
|
| 43 |
QWEN8_MODEL_PATH = Path("/models/qwen3-embedding-8b")
|
| 44 |
qwen8_tokenizer = AutoTokenizer.from_pretrained(QWEN8_MODEL_PATH, padding_side="left")
|
| 45 |
+
qwen8_model = None
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
|
| 48 |
def detailed_instruction(query: str) -> str:
|
|
|
|
| 289 |
allocation_before = int(torch.cuda.memory_allocated())
|
| 290 |
if family == "qwen3-embedding-8b":
|
| 291 |
family_tokenizer = qwen8_tokenizer
|
| 292 |
+
load_started = time.perf_counter()
|
| 293 |
+
family_model = AutoModel.from_pretrained(
|
| 294 |
+
QWEN8_MODEL_PATH,
|
| 295 |
+
dtype=torch.bfloat16,
|
| 296 |
+
trust_remote_code=True,
|
| 297 |
+
low_cpu_mem_usage=True,
|
| 298 |
+
device_map={"": "cuda"},
|
| 299 |
+
).eval()
|
| 300 |
+
torch.cuda.synchronize()
|
| 301 |
+
load_seconds = time.perf_counter() - load_started
|
| 302 |
+
loading_strategy = "in-call-direct-cuda-device-map"
|
| 303 |
+
owns_model = True
|
| 304 |
else:
|
| 305 |
raise RuntimeError("GTE 1.5B BF16 control is offline during the 8B phase")
|
| 306 |
allocation_after_load = int(torch.cuda.memory_allocated())
|
requirements.txt
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
transformers>=4.51,<5
|
|
|
|
| 2 |
numpy>=2,<3
|
| 3 |
spaces>=0.45
|
| 4 |
torch>=2.8
|
|
|
|
| 1 |
transformers>=4.51,<5
|
| 2 |
+
accelerate>=1,<2
|
| 3 |
numpy>=2,<3
|
| 4 |
spaces>=0.45
|
| 5 |
torch>=2.8
|