HK2184 commited on
Commit
944516b
·
verified ·
1 Parent(s): ed840c4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -17,13 +17,18 @@ print("Loading model...")
17
  DTYPE = torch.bfloat16 if torch.cuda.is_available() else torch.float32
18
  base = AutoModelForCausalLM.from_pretrained(
19
  BASE_MODEL,
20
- dtype=DTYPE,
21
- device_map="auto",
22
  trust_remote_code=True,
23
- low_cpu_mem_usage=True,
 
 
 
 
 
24
  )
25
- model = PeftModel.from_pretrained(base, ADAPTER_PATH)
26
  model = model.merge_and_unload()
 
27
  model.eval()
28
  print("Ready!")
29
 
 
17
  DTYPE = torch.bfloat16 if torch.cuda.is_available() else torch.float32
18
  base = AutoModelForCausalLM.from_pretrained(
19
  BASE_MODEL,
20
+ torch_dtype=DTYPE,
21
+ device_map="cpu", # load to CPU first, avoids meta tensor issue
22
  trust_remote_code=True,
23
+ low_cpu_mem_usage=False, # disable — this is what triggers meta tensors
24
+ )
25
+ model = PeftModel.from_pretrained(
26
+ base,
27
+ ADAPTER_PATH,
28
+ is_trainable=False,
29
  )
 
30
  model = model.merge_and_unload()
31
+ model = model.to(DTYPE)
32
  model.eval()
33
  print("Ready!")
34