Files
OBLITERATUS/tests/conditional/test_gpu_qualification.py
T
2026-10-18 15:15:36 -04:00

47 lines
2.3 KiB
Python

"""Required ordinary GPU placement lane: missing devices fail, without skips."""
from __future__ import annotations
import json
import os
import sys
from pathlib import Path
import pytest
from scripts import gpu_qualification as driver
pytestmark = pytest.mark.gpu
@pytest.mark.parametrize("tie_word_embeddings", [False, True])
def test_complete_module_lifecycle_on_every_requested_gpu(tmp_path, tie_word_embeddings):
count = int(os.environ.get("OBLITERATUS_GPU_QUALIFICATION_DEVICES", "2"))
output = Path(os.environ.get("OBLITERATUS_GPU_QUALIFICATION_OUTPUT", str(tmp_path / "qualification")))
if tie_word_embeddings:
output = output.with_name(output.name + "-tied")
command = [sys.executable, str(Path(__file__).parents[2] / "scripts/gpu_qualification.py"),
"--output", str(output), "--devices", str(count),
"--offload", os.environ.get("OBLITERATUS_GPU_QUALIFICATION_OFFLOAD", "none"),
"--admission-mode", os.environ.get("OBLITERATUS_GPU_QUALIFICATION_ADMISSION", "strict")]
command.extend(["--require-link", os.environ.get("OBLITERATUS_GPU_QUALIFICATION_LINK", "any")])
if os.environ.get("OBLITERATUS_GPU_QUALIFICATION_UUIDS"):
command.extend(["--uuids", *os.environ["OBLITERATUS_GPU_QUALIFICATION_UUIDS"].split(",")])
if tie_word_embeddings:
from obliteratus.qualification_runtime import create_fixture
source = tmp_path / "tied-source"
create_fixture(source, max(4, count + 2), 17, tie_word_embeddings=True)
workload = driver.configuration(driver.parser().parse_args(command[2:]))["workload"]
workload_path = tmp_path / "workload.json"
workload_path.write_text(json.dumps(workload))
command.extend(["--model", str(source), "--workload", str(workload_path)])
completed = driver.run_supervisor(command, timeout=1200)
assert completed.returncode == 0, completed.stdout + completed.stderr
evidence = json.loads(next(output.glob("evidence-*.json")).read_text())["payload"]
assert evidence["status"] == "passed"
assert evidence["claim"] == "ordinary_module_placement"
for device in (f"cuda:{index}" for index in range(count)):
assert evidence["workers"]["edit"]["occupancy"]["modules"][device]
assert evidence["workers"]["reload"]["occupancy"]["modules"][device]