-
Notifications
You must be signed in to change notification settings - Fork 122
Updated template to not request GPU resources on CPU builds #1055
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
base: master
Are you sure you want to change the base?
Changes from all commits
bd058f8
985a861
3503f95
90e5f36
214ee17
e5315b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. High-level SuggestionThe logic for checking GPU usage is duplicated across 14 template files. This should be centralized into a single helper function or variable to improve maintainability and consistency. [High-level, importance: 8] Solution Walkthrough:Before:// In toolchain/templates/bridges2.mako
<%! from mfc.state import gpuConfigOptions %>
...
% if gpu != gpuConfigOptions.NONE.value:
#SBATCH --gres=gpu:v100-16:${tasks_per_node}
% endif
// In toolchain/templates/delta.mako
<%! from mfc.state import gpuConfigOptions %>
...
% if gpu != gpuConfigOptions.NONE.value:
#SBATCH --gpus-per-node=${tasks_per_node}
% endif
// ... and so on for many other template files
After:// In a central Python file that renders templates:
from mfc.state import gpuConfigOptions
...
is_gpu_active = (gpu_mode != gpuConfigOptions.NONE.value)
template.render(..., is_gpu_active=is_gpu_active)
// In toolchain/templates/bridges2.mako (and all others)
// No import or complex check needed
...
% if is_gpu_active:
#SBATCH --gres=gpu:v100-16:${tasks_per_node}
% endif
// In toolchain/templates/delta.mako (and all others)
...
% if is_gpu_active:
#SBATCH --gpus-per-node=${tasks_per_node}
% endif
|
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -14,7 +14,7 @@ | |||||
| % if account: | ||||||
| #SBATCH --account="${account}" | ||||||
| % endif | ||||||
| % if gpu: | ||||||
| % if gpu != gpuConfigOptions.NONE.value: | ||||||
| #SBATCH --gpus-per-node=${tasks_per_node} | ||||||
| #SBATCH --mem=208G | ||||||
| #SBATCH --gpu-bind=closest | ||||||
|
Comment on lines
+17
to
20
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: To ensure consistency and prevent potential New proposed code:-% if gpu != gpuConfigOptions.NONE.value:
+% if is_gpu_active:
#SBATCH --gpus-per-node=${tasks_per_node}
#SBATCH --mem=208G
#SBATCH --gpu-bind=closest
% endif |
||||||
|
|
@@ -32,7 +32,7 @@ ${helpers.template_prologue()} | |||||
|
|
||||||
| ok ":) Loading modules:\n" | ||||||
| cd "${MFC_ROOT_DIR}" | ||||||
| . ./mfc.sh load -c d -m ${'g' if gpu else 'c'} | ||||||
| . ./mfc.sh load -c d -m ${'g' if gpu != gpuConfigOptions.NONE.value else 'c'} | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Prompt for AI agents✅ Addressed in
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Prompt for AI agents
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: To maintain consistency and prevent potential errors, replace the inline GPU check with the
Suggested change
|
||||||
| cd - > /dev/null | ||||||
| echo | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -14,7 +14,7 @@ | |||||
| % if account: | ||||||
| #SBATCH --account="${account}" | ||||||
| % endif | ||||||
| % if gpu: | ||||||
| % if is_gpu_active: | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Guard the SBATCH GPU directives with a context lookup so missing |
||||||
| #SBATCH --gpus-per-node=${tasks_per_node} | ||||||
| #SBATCH --mem=64G | ||||||
| #SBATCH --gpu-bind=closest | ||||||
|
|
@@ -32,7 +32,7 @@ ${helpers.template_prologue()} | |||||
|
|
||||||
| ok ":) Loading modules:\n" | ||||||
| cd "${MFC_ROOTDIR}" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Correct the typo in the environment variable from
Suggested change
|
||||||
| . ./mfc.sh load -c o -m ${'g' if gpu else 'c'} | ||||||
| . ./mfc.sh load -c o -m ${'g' if is_gpu_active else 'c'} | ||||||
| cd - > /dev/null | ||||||
| echo | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,7 +17,7 @@ | |||||||||||||||||
| % if quality_of_service: | ||||||||||||||||||
| #SBATCH --qos=${quality_of_service} | ||||||||||||||||||
| % endif | ||||||||||||||||||
| % if gpu: | ||||||||||||||||||
| % if is_gpu_active: | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Prompt for AI agents |
||||||||||||||||||
| #SBATCH --gres=gpu:V100:${tasks_per_node} | ||||||||||||||||||
| #SBATCH --mem-per-gpu=16G\ | ||||||||||||||||||
| % endif | ||||||||||||||||||
|
Comment on lines
+20
to
23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GPU SBATCH directives updated, but trailing backslash needs removal. The condition change from Apply this diff to remove the trailing backslash: -#SBATCH --mem-per-gpu=16G\
+#SBATCH --mem-per-gpu=16G📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
@@ -31,7 +31,7 @@ ${helpers.template_prologue()} | |||||||||||||||||
|
|
||||||||||||||||||
| ok ":) Loading modules:\n" | ||||||||||||||||||
| cd "${MFC_ROOT_DIR}" | ||||||||||||||||||
| . ./mfc.sh load -c p -m ${'g' if gpu else 'c'} | ||||||||||||||||||
| . ./mfc.sh load -c p -m ${'g' if is_gpu_active else 'c'} | ||||||||||||||||||
| cd - > /dev/null | ||||||||||||||||||
| echo | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
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.
Suggestion: Use a guarded lookup such as
globals().get('is_gpu_active', False)for the GPU block so that rendering still works even if only the oldgpuflag is provided. [possible bug]