Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -57,12 +57,23 @@ files_to_download = [
|
|
57 |
"tokenizer_config.json"
|
58 |
]
|
59 |
|
60 |
-
|
61 |
# Directory to store downloaded files
|
62 |
model_dir = f"./{model_id}"
|
63 |
os.makedirs(model_dir, exist_ok=True)
|
|
|
64 |
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
|
68 |
'''
|
@@ -87,6 +98,7 @@ with fp8_autocast(): # Enables FP8 computations
|
|
87 |
model = transformers.AutoModelForCausalLM.from_pretrained(model_dir, quantization_config=quantization_config)
|
88 |
tokenizer = transformers.AutoTokenizer.from_pretrained(model_dir)
|
89 |
|
|
|
90 |
'''
|
91 |
model.to(dtype=torch.float16) # Load as FP16 first
|
92 |
model = model.half() # Convert to FP8-like (closest possible)
|
|
|
57 |
"tokenizer_config.json"
|
58 |
]
|
59 |
|
60 |
+
'''
|
61 |
# Directory to store downloaded files
|
62 |
model_dir = f"./{model_id}"
|
63 |
os.makedirs(model_dir, exist_ok=True)
|
64 |
+
'''
|
65 |
|
66 |
+
|
67 |
+
# Use /data for persistent storage
|
68 |
+
model_dir = f"/data/{model_id}"
|
69 |
+
os.makedirs(model_dir, exist_ok=True)
|
70 |
+
|
71 |
+
|
72 |
+
# snapshot_download(repo_id=model_id, ignore_patterns="*.bin", token=auth_token)
|
73 |
+
|
74 |
+
# Download model to persistent storage (if not already there)
|
75 |
+
if not os.path.exists(model_dir) or not os.listdir(model_dir):
|
76 |
+
snapshot_download(repo_id=model_id, local_dir=model_dir, ignore_patterns="*.bin", token=auth_token)
|
77 |
|
78 |
|
79 |
'''
|
|
|
98 |
model = transformers.AutoModelForCausalLM.from_pretrained(model_dir, quantization_config=quantization_config)
|
99 |
tokenizer = transformers.AutoTokenizer.from_pretrained(model_dir)
|
100 |
|
101 |
+
|
102 |
'''
|
103 |
model.to(dtype=torch.float16) # Load as FP16 first
|
104 |
model = model.half() # Convert to FP8-like (closest possible)
|