File size: 2,996 Bytes
de071e9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import yaml
from yaml import Loader

import subprocess
import argparse


parser = argparse.ArgumentParser(description="Experiment Settings")

parser.add_argument("--slurm", default="nlprun -g 1 -d a6000 -r 80G -a model-tracing", type=str)
parser.add_argument("--python", default="python experiment.py", type=str)
parser.add_argument("--models", default="config/llama_flat.yaml", type=str)
parser.add_argument("--save", default="/juice4/scr4/nlp/model-tracing", type=str)
parser.add_argument("--flat", default="all", type=str)

args = parser.parse_args()

model_paths = yaml.load(open(args.models, "r"), Loader=Loader)

subprocess.run(f"mkdir -p {args.save}/logs", shell=True)
subprocess.run(f"mkdir -p {args.save}/results", shell=True)

if args.flat == "all":
    for i in range(len(model_paths)):
        for j in range(i + 1, len(model_paths)):
            model_a = model_paths[i]
            model_b = model_paths[j]

            job_id = model_a.replace("/", "-") + "_AND_" + model_b.replace("/", "-")
            if "miqu" not in job_id:
                continue
            if job_id[0] == "-":
                job_id = job_id[1:]

            log_path = args.save + "/logs/" + job_id + ".out"
            results_path = args.save + "/results/" + job_id + ".p"

            job = (
                args.slurm + f" -o {log_path} -n {job_id}"
                f" '{args.python}"
                + f" --base_model_id {model_a} --ft_model_id {model_b} --save {results_path}'"
            )
            subprocess.run(job, shell=True)

elif args.flat == "split":
    base_models = model_paths["base_models"]
    ft_models = model_paths["ft_models"]

    for base_model in base_models:
        for ft_model in ft_models:
            job_id = base_model.replace("/", "-") + "_AND_" + ft_model.replace("/", "-")

            log_path = args.save + "/logs/" + job_id + ".out"
            results_path = args.save + "/results/" + job_id + ".p"

            job = (
                args.slurm + f" -o {log_path} -n {job_id}"
                f" '{args.python}"
                + f" --base_model_id {base_model} --ft_model_id {ft_model} --save {results_path}'"
            )
            subprocess.run(job, shell=True)

elif args.flat == "specified":
    models_1 = model_paths["models_1"]
    models_2 = model_paths["models_2"]

    names_1 = model_paths["names_1"]
    names_2 = model_paths["names_2"]

    for i in range(len(models_1)):
        model_a = models_1[i]
        model_b = models_2[i]

        name_a = names_1[i]
        name_b = names_2[i]

        job_id = name_a.replace("/", "-") + "_AND_" + name_b.replace("/", "-")

        log_path = args.save + "/logs/" + job_id + ".out"
        results_path = args.save + "/results/" + job_id + ".p"

        job = (
            args.slurm + f" -o {log_path} -n {job_id}"
            f" '{args.python}"
            + f" --base_model_id {model_a} --ft_model_id {model_b} --save {results_path}'"
        )
        subprocess.run(job, shell=True)