Files
OBLITERATUS/scripts/run_rank_local_qualification.py
Joseph Magly afde716070 feat(distributed): add rank-local LMS-E4 workload admission and a streaming reference
Adds the two-host E4 workload path. A bounded streaming reference is built from the immutable source with one layer resident at a time, so it works for models larger than any single host. run_rank_local_qualification.py admits a fully bound E4 job only when its workload exceeds the local host's physical RAM, and the worker requires both ranks to agree over Gloo before PROBE. Registry and final qualification checks are unchanged; the stack stays not_qualified. The PROBE RAM refresh was already delivered in 002e6e5.

Refs #287
2026-11-27 11:23:49 -05:00

59 lines
2.8 KiB
Python

"""Consume an externally scheduled exact-profile worker; never launch hosts or GPUs."""
from __future__ import annotations
import argparse
import os
import subprocess
from pathlib import Path
from obliteratus.distributed.config import DistributedPreflightConfig
from obliteratus.distributed.contracts import ContractError
from obliteratus.distributed.preflight import checkout_commit
from obliteratus.distributed.rank_local import _bounded_json, config_review
from obliteratus.distributed.rank_local_e4 import admit_e4_job, physical_host_memory_bytes
def admit_job(job: object, config: object, *, physical_host_bytes: int) -> str:
"""Admit only a reviewed E3 reference job or a fully bound E4 workload job."""
if not isinstance(job, dict) or job.get("workflow") != "verify":
raise ValueError("qualification requires the complete verify workflow")
storage = config.rank_storage
if storage is None or storage.scope != "qualification" or config.device_kind != "cuda":
raise ValueError("qualification requires a reviewed CUDA qualification profile")
if storage.tier == "LMS-E3":
# The tiny full-reference job is E3-only; an E4 claim needs the E4 path.
if job.get("tier", "LMS-E3") != "LMS-E3":
raise ValueError("the E3 reference lane cannot run a job for another tier")
return "LMS-E3"
if storage.tier == "LMS-E4":
admit_e4_job(job, storage, physical_host_bytes=physical_host_bytes, source=config.source_path)
return "LMS-E4"
raise ValueError("qualification tier is not admitted by this worker")
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--job", type=Path, required=True)
args = parser.parse_args()
try:
job = _bounded_json(args.job)
if not isinstance(job, dict):
raise ValueError("qualification job is invalid")
config = DistributedPreflightConfig.from_file(job["profile"]).for_rank(int(os.environ["RANK"]))
admit_job(job, config, physical_host_bytes=physical_host_memory_bytes())
if config.commit_sha != checkout_commit() or config.commit_sha != job["candidate_sha"]:
raise ValueError("qualification requires the exact selected candidate")
config_review(config)
subprocess.run(["git", "verify-commit", "HEAD"], check=True, timeout=10,
stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
cwd=Path(__file__).resolve().parents[1])
from tests.conditional.test_distributed_llama_tp_cuda import _run_worker
return _run_worker(args.job)
except (OSError, ValueError, TypeError, KeyError, ContractError, subprocess.SubprocessError):
parser.exit(1, "rank-local qualification refused before worker admission\n")
if __name__ == "__main__":
raise SystemExit(main())