-
Notifications
You must be signed in to change notification settings - Fork 43
Add support for PBS/Torque scheduler #1159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Sbozzolo
wants to merge
3
commits into
llnl:develop
Choose a base branch
from
Sbozzolo:develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -297,6 +297,10 @@ def determine_allocation(self, v): | |
| if not v.n_threads_per_proc: | ||
| v.n_threads_per_proc = 1 | ||
|
|
||
| # Calculate n_ranks_per_node if not explicitly set | ||
| if not v.n_ranks_per_node and v.n_ranks and v.n_nodes: | ||
| v.n_ranks_per_node = math.ceil(v.n_ranks / v.n_nodes) | ||
|
|
||
| # Final check, make sure the above arithmetic didn't result in an | ||
| # unreasonable allocation request. | ||
| for var, val in v.defined(): | ||
|
|
@@ -466,13 +470,67 @@ def pjm_instructions(self, v): | |
| v.batch_submit = "pjsub {execute_experiment}" | ||
| v.allocation_directives = "\n".join(batch_directives) | ||
|
|
||
| def pbs_instructions(self, v): | ||
| batch_opts, cmd_opts = Allocation._init_batch_and_cmd_opts(v) | ||
|
|
||
| if v.n_ranks and v.n_nodes and v.n_ranks_per_node: | ||
| expected_ranks = v.n_nodes * v.n_ranks_per_node | ||
| if v.n_ranks != expected_ranks: | ||
|
||
| raise ValueError( | ||
| f"Inconsistent rank specification: n_ranks ({v.n_ranks}) != " | ||
| f"n_nodes ({v.n_nodes}) * n_ranks_per_node ({v.n_ranks_per_node})" | ||
| ) | ||
|
|
||
| if v.n_ranks: | ||
| cmd_opts.append(f"-np {v.n_ranks}") | ||
|
|
||
| if v.n_nodes: | ||
| node_spec = f"nodes={v.n_nodes}" | ||
| if v.n_ranks_per_node: | ||
| node_spec += f":ppn={v.n_ranks_per_node}" | ||
|
|
||
| if v.n_gpus and v.sys_gpus_per_node: | ||
| if v.n_gpus > v.n_nodes * v.sys_gpus_per_node: | ||
|
||
| raise ValueError( | ||
| f"Requested GPUs ({v.n_gpus}) exceeds available GPUs " | ||
| f"({v.n_nodes * v.sys_gpus_per_node}) on {v.n_nodes} nodes" | ||
| ) | ||
| # Distribute GPUs as evenly as possible | ||
| gpus_per_node = v.n_gpus // v.n_nodes | ||
| if v.n_gpus % v.n_nodes > 0: | ||
| gpus_per_node += 1 | ||
| gpus_per_node = min(gpus_per_node, v.sys_gpus_per_node) | ||
| node_spec += f":gpus={gpus_per_node}" | ||
| elif v.n_gpus: | ||
| raise ValueError( | ||
| "GPU allocation requested but sys_gpus_per_node not specified" | ||
| ) | ||
|
|
||
| batch_opts.append(f"-l {node_spec}") | ||
|
|
||
| if v.queue: | ||
| batch_opts.append(f"-q {v.queue}") | ||
|
|
||
| if v.timeout: | ||
| batch_opts.append(f"-l walltime={TimeFormat.as_hhmmss(v.timeout)}") | ||
|
|
||
| if v.bank: | ||
| batch_opts.append(f"-A {v.bank}") | ||
|
|
||
| batch_directives = list(f"#PBS {x}" for x in batch_opts) | ||
|
|
||
| v.mpi_command = f"mpiexec {' '.join(cmd_opts)}" | ||
| v.batch_submit = "qsub {execute_experiment}" | ||
| v.allocation_directives = "\n".join(batch_directives) | ||
|
|
||
| def determine_scheduler_instructions(self, v): | ||
| handler = { | ||
| "slurm": self.slurm_instructions, | ||
| "flux": self.flux_instructions, | ||
| "mpi": self.mpi_instructions, | ||
| "lsf": self.lsf_instructions, | ||
| "pjm": self.pjm_instructions, | ||
| "pbs": self.pbs_instructions, | ||
| } | ||
| if v.scheduler not in handler: | ||
| raise ValueError( | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
pbsalways requires settingn_ranks_per_node(or in particular whenn_ranksandn_nodesare set) I think that might best be done inpbs_instructions(based on reading it I assume it is not required, and in that case as well I think it might be best to skip this): this function implicitly ensures that eithern_nodesorn_ranksis set by the end of it, and scheduler option functions tend to work with that; if this also sets n_ranks_per_node itself, it could over-specify (e.g. the potential mismatch from callingceil).Perhaps if
n_nodesis set but notn_ranks/n_ranks_per_nodethen I should be settingn_ranks_per_node=sys_cores_per_nodein this function. I assumed schedulers were doing that automatically; nearly all experiments in benchpark setn_ranks.