This repository has been archived by the owner on Mar 19, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
103 additions
and
100 deletions.
There are no files selected for viewing
22 changes: 0 additions & 22 deletions
22
configs/config/benchmark/slurm_evaluations/slurm_evaluation_example.json
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
configs/config/benchmark/suite/benchmark_suite_scheduler_example.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"params": { | ||
"training_checkpoint_dir": "(str) Training checkpoint directory. That is the CHECKPOINT.DIR of the training config", | ||
"benchmarks": [ | ||
{ | ||
"evaluation_name": "(str) Name of benchmark for convenience", | ||
"config_files": [ | ||
"config=path/to/evaluation/config", | ||
"config.OVERRIDES=new_value" | ||
] | ||
} | ||
], | ||
"evaluation_iter_freq": "(int, default=-1) Evaluate the checkpoint every N iterations", | ||
"evaluation_phase_freq": "(int, default=-1) Evaluate the checkpoint every N phases", | ||
"evaluate_final_phase": "(bool, default=True) Evaluate the final phase", | ||
"autoload_slurm_evaluator_checkpoint": "(bool, default=False) Whether or not to automatically load the benchmark checkpoint", | ||
"slurm_evaluator_checkpoint": "(str, default=None) Path to load the benchmark checkpoint", | ||
"max_training_iterations": "(int, default=None) Max training iterations", | ||
"auto_retry_evaluations": "(bool, default=False) Whether or not to automatically retry the evaluations", | ||
"retry_evaluation_job_ids": "(array[int], default=[]) Array of job_ids to retry", | ||
"max_retries": "(int, default=3) Maximum number of retries" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import sys | ||
|
||
import submitit | ||
from fvcore.common.file_io import PathManager | ||
from vissl.utils.io import load_file | ||
from vissl.engines.benchmark_suite_scheduler import BenchmarkSuiteScheduler | ||
|
||
# Default slurm options to pass to the executor. | ||
_DEFAULT_SLURM_OPTIONS = { | ||
"NAME": "vissl", | ||
"COMMENT": "vissl evaluation job", | ||
"PARTITION": "learnfair", | ||
"CONSTRAINT": "", | ||
"TIMEOUT_MIN": 4320, # Timeout in minutes. | ||
"CPUS_PER_TASK": 8, | ||
"MEM_GB": 16, | ||
"ADDITIONAL_PARAMETERS": {}, | ||
} | ||
|
||
class SlurmEvaluatorJob: | ||
def __init__(self, benchmark_suite_scheduler: BenchmarkSuiteScheduler): | ||
self.benchmark_suite_scheduler = benchmark_suite_scheduler | ||
|
||
def __call__(self): | ||
self.benchmark_suite_scheduler.evaluate() | ||
|
||
def checkpoint(self): | ||
self.benchmark_suite_scheduler.save_evaluation_results() | ||
self.benchmark_suite_scheduler.autoload_benchmark_suite_scheduler_checkpoint = True | ||
|
||
trainer = SlurmEvaluatorJob(benchmark_suite_scheduler=self.benchmark_suite_scheduler) | ||
return submitit.helpers.DelayedSubmission(trainer) | ||
|
||
def launch_benchmark_suite_scheduler(config_file): | ||
assert PathManager.exists(config_file), "Slurm evaluator config file must exist." | ||
|
||
config = load_file(config_file) | ||
benchmark_suite_scheduler = BenchmarkSuiteScheduler(**config["params"]) | ||
benchmark_suite_scheduler.evaluate() | ||
benchmark_suite_scheduler_job = SlurmEvaluatorJob(benchmark_suite_scheduler=benchmark_suite_scheduler) | ||
executor = submitit.AutoExecutor(folder=benchmark_suite_scheduler.evaluation_dir()) | ||
|
||
override_slurm_options = config.get("slurm_options", {}) | ||
slurm_options = {**_DEFAULT_SLURM_OPTIONS, **override_slurm_options} | ||
slurm_options = AttrDict(slurm_options) | ||
|
||
executor.update_parameters( | ||
name=slurm_options.NAME, | ||
slurm_comment=slurm_options.COMMENT, | ||
slurm_partition=slurm_options.PARTITION, | ||
slurm_constraint=slurm_options.CONSTRAINT, | ||
timeout_min=slurm_options.TIMEOUT_MIN, | ||
nodes=1, | ||
cpus_per_task=slurm_options.CPUS_PER_TASK, | ||
tasks_per_node=1, | ||
mem_gb=slurm_options.MEM_GB, | ||
slurm_additional_parameters=slurm_options.ADDITIONAL_PARAMETERS, | ||
) | ||
|
||
job = executor.submit(benchmark_suite_scheduler_job) | ||
print(f"SUBMITTED EVALUATION JOB: {job.job_id}") | ||
|
||
return job | ||
|
||
|
||
if __name__ == "__main__": | ||
""" | ||
Example usage: | ||
python -u "./vissl/engines/benchmark_suite_scheduler.py" \ | ||
"/path/to/checkpoint_file/checkpoint.torch" | ||
""" | ||
config_file = sys.argv[1] | ||
launch_benchmark_suite_scheduler(config_file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters