summaryrefslogtreecommitdiff
path: root/experiments/resnet_crossover_r2.py
diff options
context:
space:
mode:
Diffstat (limited to 'experiments/resnet_crossover_r2.py')
-rw-r--r--experiments/resnet_crossover_r2.py62
1 files changed, 24 insertions, 38 deletions
diff --git a/experiments/resnet_crossover_r2.py b/experiments/resnet_crossover_r2.py
index a9d5dfe..a7e78d7 100644
--- a/experiments/resnet_crossover_r2.py
+++ b/experiments/resnet_crossover_r2.py
@@ -10,6 +10,15 @@ import time
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+sys.path.insert(0, ROOT)
+from experiments.crossover_hardware import (
+ DEFAULT_PROFILE,
+ physical_gpu_report,
+ policy_for_report,
+ profile_choices,
+)
+
+
PROTOCOL = os.path.join(ROOT, "RESNET_CROSSOVER.md")
RESULT_ROOT = os.path.join(ROOT, "results", "resnet_crossover")
DEFAULT_SELECTOR = os.path.join(RESULT_ROOT, "p1_selector.json")
@@ -113,6 +122,7 @@ def source_report(selector_path):
os.path.join(ROOT, "experiments", "analyze_resnet_crossover_r2.py"),
os.path.join(ROOT, "experiments", "resnet_crossover_native.py"),
os.path.join(ROOT, "experiments", "conv_run.py"),
+ os.path.join(ROOT, "experiments", "crossover_hardware.py"),
os.path.join(ROOT, "sdil", "conv_crossover.py"),
os.path.join(ROOT, "sdil", "conv.py"),
os.path.join(ROOT, "sdil", "data.py"),
@@ -295,7 +305,7 @@ def registry_sha256(jobs):
return hashlib.sha256(encoded).hexdigest()
-def ensure_launch(source, selector, jobs):
+def ensure_launch(source, selector, jobs, hardware_policy):
path = os.path.join(RESULT_ROOT, "r2_launch.json")
expected = {
"stage": "r2",
@@ -303,7 +313,9 @@ def ensure_launch(source, selector, jobs):
"selector": selector,
"registry_sha256": registry_sha256(jobs),
"num_jobs": len(jobs),
- "allowed_physical_gpus": [5, 7],
+ "hardware_policy": hardware_policy,
+ "allowed_physical_gpus":
+ hardware_policy["allowed_physical_gpu_indices"],
}
if os.path.isfile(path):
if read_json(path) != expected:
@@ -326,40 +338,6 @@ def assert_source_unchanged(source):
raise RuntimeError(f"ResNet R2 source drift: {relative}")
-def physical_gpu_report(dry_run=False):
- visible = os.environ.get("CUDA_VISIBLE_DEVICES")
- if dry_run:
- return {
- "cuda_visible_devices": visible,
- "physical_gpu_index": None,
- "physical_gpu_uuid": None,
- }
- if visible not in {"5", "7"}:
- raise RuntimeError("ResNet R2 requires physical GPU 5 or 7")
- query = subprocess.run(
- [
- "nvidia-smi",
- "--query-gpu=index,uuid,name",
- "--format=csv,noheader,nounits",
- ],
- check=True,
- capture_output=True,
- text=True,
- ).stdout.splitlines()
- rows = {}
- for line in query:
- index, uuid, name = [value.strip() for value in line.split(",", 2)]
- rows[index] = {"uuid": uuid, "name": name}
- if visible not in rows:
- raise RuntimeError(f"physical GPU {visible} not found")
- return {
- "cuda_visible_devices": visible,
- "physical_gpu_index": int(visible),
- "physical_gpu_uuid": rows[visible]["uuid"],
- "physical_gpu_name": rows[visible]["name"],
- }
-
-
def run_job(job, source, selector, gpu, dry_run):
if not dry_run:
assert_source_unchanged(source)
@@ -414,16 +392,24 @@ def main():
parser.add_argument("--num-shards", type=int, default=1)
parser.add_argument("--method", choices=METHODS)
parser.add_argument("--depth", type=int, choices=DEPTHS)
+ parser.add_argument(
+ "--hardware-profile",
+ choices=profile_choices(),
+ default=os.environ.get("SDIL_HARDWARE_PROFILE", DEFAULT_PROFILE),
+ )
parser.add_argument("--dry-run", action="store_true")
args = parser.parse_args()
if not 0 <= args.shard_index < args.num_shards:
raise ValueError("invalid ResNet R2 shard")
selector = selector_report(args.selector)
source = source_report(args.selector)
- gpu = physical_gpu_report(args.dry_run)
+ gpu = physical_gpu_report(args.hardware_profile, args.dry_run)
complete_jobs = r2_jobs(selector["selected_rates"])
if not args.dry_run:
- launch = ensure_launch(source, selector, complete_jobs)
+ hardware_policy = policy_for_report(args.hardware_profile, gpu)
+ launch = ensure_launch(
+ source, selector, complete_jobs, hardware_policy
+ )
print(f"R2 launch lock: {launch}", flush=True)
jobs = complete_jobs
if args.method: