File size: 2,158 Bytes
714625a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | #!/usr/bin/env python3
from __future__ import annotations
import os
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent
RUNTIME = ROOT / "runtime"
TEST_SCRIPT = RUNTIME / "lab/scripts/test_checkpoint_capabilities.py"
OUTPUT = ROOT / "cpu-smoke-results.json"
def main() -> int:
if not TEST_SCRIPT.is_file():
print(f"ERROR: missing capability runner: {TEST_SCRIPT}", file=sys.stderr)
return 1
if not (ROOT / "lit_model.pth").is_file():
print("ERROR: missing lit_model.pth", file=sys.stderr)
return 1
if not (ROOT / "model_config.yaml").is_file():
print("ERROR: missing model_config.yaml", file=sys.stderr)
return 1
env = os.environ.copy()
env["CUDA_VISIBLE_DEVICES"] = ""
env["MULTISCREEN_BACKEND"] = "torch"
env["TOKENIZERS_PARALLELISM"] = "false"
env["PYTHONUNBUFFERED"] = "1"
old_pythonpath = env.get("PYTHONPATH", "")
env["PYTHONPATH"] = (
str(RUNTIME)
if not old_pythonpath
else str(RUNTIME) + os.pathsep + old_pythonpath
)
command = [
sys.executable,
"-u",
str(TEST_SCRIPT),
"--checkpoint-dir",
str(ROOT),
"--tokenizer-dir",
str(ROOT),
"--dtype",
"float32",
"--device",
"cpu",
"--seed",
"1337",
"--output",
str(OUTPUT),
]
print(f"Checkpoint: {ROOT}")
print("Device: cpu")
print("Backend: torch")
print("Triton imported: False")
print()
result = subprocess.run(command, cwd=ROOT, env=env)
if result.returncode != 0:
print(
f"CPU-only smoke: FAIL ({result.returncode})",
file=sys.stderr,
)
return result.returncode
if not OUTPUT.is_file() or OUTPUT.stat().st_size == 0:
print(f"ERROR: result was not created: {OUTPUT}", file=sys.stderr)
return 1
print()
print("CPU-only smoke: PASS")
print("Backend: torch")
print("Triton imported: False")
print(f"Results: {OUTPUT}")
return 0
if __name__ == "__main__":
raise SystemExit(main())
|