Add some error handling to the Python-based bench script
Browse files- bench-TriLMs.py +8 -2
bench-TriLMs.py
CHANGED
|
@@ -58,7 +58,7 @@ def quantize(types: Sequence[str] = ALL_TYPES, sizes: Sequence[str] = MODEL_SIZE
|
|
| 58 |
source = MODEL_DIR / f"TriLM_{size}B_Unpacked-TQ1_0-F16.gguf"
|
| 59 |
for ty in types:
|
| 60 |
target = MODEL_DIR / f"TriLM_{size}B_Unpacked-{ty}.gguf"
|
| 61 |
-
if not target.exists():
|
| 62 |
command = shlex.join(
|
| 63 |
(
|
| 64 |
str(LLAMA_CPP_PATH / "build" / "bin" / "llama-quantize"),
|
|
@@ -69,7 +69,10 @@ def quantize(types: Sequence[str] = ALL_TYPES, sizes: Sequence[str] = MODEL_SIZE
|
|
| 69 |
)
|
| 70 |
)
|
| 71 |
logger.info("Running: %s", command)
|
| 72 |
-
os.system(command)
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
|
| 75 |
def llama_bench(
|
|
@@ -107,6 +110,9 @@ def llama_bench(
|
|
| 107 |
logger.info("Running: %s", " ".join(command))
|
| 108 |
result = subprocess.run(command, capture_output=True)
|
| 109 |
logger.debug(result.stderr.decode())
|
|
|
|
|
|
|
|
|
|
| 110 |
|
| 111 |
new_output = json.loads(result.stdout)
|
| 112 |
logger.info(json.dumps(new_output, indent=4))
|
|
|
|
| 58 |
source = MODEL_DIR / f"TriLM_{size}B_Unpacked-TQ1_0-F16.gguf"
|
| 59 |
for ty in types:
|
| 60 |
target = MODEL_DIR / f"TriLM_{size}B_Unpacked-{ty}.gguf"
|
| 61 |
+
if not target.exists() or target.is_file() and target.stat().st_size == 0:
|
| 62 |
command = shlex.join(
|
| 63 |
(
|
| 64 |
str(LLAMA_CPP_PATH / "build" / "bin" / "llama-quantize"),
|
|
|
|
| 69 |
)
|
| 70 |
)
|
| 71 |
logger.info("Running: %s", command)
|
| 72 |
+
ret = os.system(command)
|
| 73 |
+
if ret != 0:
|
| 74 |
+
logger.error("Failed to quantize to %s", target)
|
| 75 |
+
# Should it still continue?
|
| 76 |
|
| 77 |
|
| 78 |
def llama_bench(
|
|
|
|
| 110 |
logger.info("Running: %s", " ".join(command))
|
| 111 |
result = subprocess.run(command, capture_output=True)
|
| 112 |
logger.debug(result.stderr.decode())
|
| 113 |
+
if result.returncode != 0:
|
| 114 |
+
logger.error("Failed to run %s", " ".join(command))
|
| 115 |
+
break;
|
| 116 |
|
| 117 |
new_output = json.loads(result.stdout)
|
| 118 |
logger.info(json.dumps(new_output, indent=4))
|