Spaces:
Runtime error
Runtime error
Update app.py
Browse filesAdding log information to know the time of each quantize steps.
app.py
CHANGED
|
@@ -12,6 +12,7 @@ from apscheduler.schedulers.background import BackgroundScheduler
|
|
| 12 |
from datetime import datetime
|
| 13 |
import numpy as np
|
| 14 |
|
|
|
|
| 15 |
os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
|
| 16 |
CONVERSION_SCRIPT = "./llama.cpp/convert_hf_to_gguf.py"
|
| 17 |
|
|
@@ -225,13 +226,14 @@ def process_model(model_id, q_method, use_imatrix, imatrix_q_method, private_rep
|
|
| 225 |
|
| 226 |
with tempfile.TemporaryDirectory(dir=downloads_dir) as tmpdir:
|
| 227 |
local_dir = Path(tmpdir)/model_name
|
|
|
|
| 228 |
api.snapshot_download(repo_id=model_id, local_dir=local_dir, local_dir_use_symlinks=False, allow_patterns=dl_pattern)
|
| 229 |
|
| 230 |
config_dir = local_dir/"config.json"
|
| 231 |
adapter_config_dir = local_dir/"adapter_config.json"
|
| 232 |
if os.path.exists(adapter_config_dir) and not os.path.exists(config_dir):
|
| 233 |
raise Exception("adapter_config.json is present. If converting LoRA, use GGUF-my-lora.")
|
| 234 |
-
|
| 235 |
result = subprocess.run(["python", CONVERSION_SCRIPT, local_dir, "--outtype", "f16", "--outfile", fp16], shell=False, capture_output=True)
|
| 236 |
if result.returncode != 0:
|
| 237 |
raise Exception(f"Error converting to fp16: {result.stderr.decode()}")
|
|
@@ -245,7 +247,7 @@ def process_model(model_id, q_method, use_imatrix, imatrix_q_method, private_rep
|
|
| 245 |
|
| 246 |
quant_methods = [imatrix_q_method] if use_imatrix else (q_method if isinstance(q_method, list) else [q_method])
|
| 247 |
suffix = "imat" if use_imatrix else None
|
| 248 |
-
|
| 249 |
gguf_files = []
|
| 250 |
for method in quant_methods:
|
| 251 |
name = f"{model_name.lower()}-{method.lower()}-{suffix}.gguf" if suffix else f"{model_name.lower()}-{method.lower()}.gguf"
|
|
|
|
| 12 |
from datetime import datetime
|
| 13 |
import numpy as np
|
| 14 |
|
| 15 |
+
HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 16 |
os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
|
| 17 |
CONVERSION_SCRIPT = "./llama.cpp/convert_hf_to_gguf.py"
|
| 18 |
|
|
|
|
| 226 |
|
| 227 |
with tempfile.TemporaryDirectory(dir=downloads_dir) as tmpdir:
|
| 228 |
local_dir = Path(tmpdir)/model_name
|
| 229 |
+
print(datetime.now().strftime("%Y-%m-%d %H:%M:%S") + " Start download")
|
| 230 |
api.snapshot_download(repo_id=model_id, local_dir=local_dir, local_dir_use_symlinks=False, allow_patterns=dl_pattern)
|
| 231 |
|
| 232 |
config_dir = local_dir/"config.json"
|
| 233 |
adapter_config_dir = local_dir/"adapter_config.json"
|
| 234 |
if os.path.exists(adapter_config_dir) and not os.path.exists(config_dir):
|
| 235 |
raise Exception("adapter_config.json is present. If converting LoRA, use GGUF-my-lora.")
|
| 236 |
+
print(datetime.now().strftime("%Y-%m-%d %H:%M:%S")+" Download finished and start converting to fp16")
|
| 237 |
result = subprocess.run(["python", CONVERSION_SCRIPT, local_dir, "--outtype", "f16", "--outfile", fp16], shell=False, capture_output=True)
|
| 238 |
if result.returncode != 0:
|
| 239 |
raise Exception(f"Error converting to fp16: {result.stderr.decode()}")
|
|
|
|
| 247 |
|
| 248 |
quant_methods = [imatrix_q_method] if use_imatrix else (q_method if isinstance(q_method, list) else [q_method])
|
| 249 |
suffix = "imat" if use_imatrix else None
|
| 250 |
+
print(datetime.now().strftime("%Y-%m-%d %H:%M:%S")+" Converting finished, start to quantize")
|
| 251 |
gguf_files = []
|
| 252 |
for method in quant_methods:
|
| 253 |
name = f"{model_name.lower()}-{method.lower()}-{suffix}.gguf" if suffix else f"{model_name.lower()}-{method.lower()}.gguf"
|