TiGa-RCE commited on
Commit
7740aa9
·
verified ·
1 Parent(s): bd2dad5

Load 8B directly inside allocated ZeroGPU call

Browse files
Files changed (2) hide show
  1. app.py +13 -9
  2. 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 = AutoModel.from_pretrained(
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
- family_model = qwen8_model
297
- load_seconds = 0.0
298
- loading_strategy = "root-module-cuda-emulation"
299
- owns_model = False
 
 
 
 
 
 
 
 
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