"""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.preflight import checkout_commit from obliteratus.distributed.rank_local import _bounded_json, config_review 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) or job.get("workflow") != "verify": raise ValueError("qualification requires the complete verify workflow") config = DistributedPreflightConfig.from_file(job["profile"]).for_rank(int(os.environ["RANK"])) storage = config.rank_storage if storage is None or storage.scope != "qualification" or storage.tier != "LMS-E3" or config.device_kind != "cuda": raise ValueError("this bounded reference lane requires a reviewed E3 CUDA profile") 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, subprocess.SubprocessError): parser.exit(1, "rank-local qualification refused before worker admission\n") if __name__ == "__main__": raise SystemExit(main())