Skip to content

Conversation

@sbryngelson
Copy link
Member

@sbryngelson sbryngelson commented Dec 5, 2025

User description

User description

Fixing up templates across the board.


PR Type

Bug fix


Description

  • Replace ambiguous gpu boolean with explicit gpu_enabled, gpu_acc, gpu_mp flags

  • Fix GPU mode detection using gpuConfigOptions enum values

  • Update all HPC cluster templates to use new GPU mode variables

  • Ensure consistent GPU configuration across 16 template files


Diagram Walkthrough

flowchart LR
  A["run.py: Import gpuConfigOptions"] --> B["Compute GPU mode booleans"]
  B --> C["gpu_enabled, gpu_acc, gpu_mp"]
  C --> D["Pass to template renderer"]
  D --> E["16 HPC templates"]
  E --> F["Replace gpu with gpu_enabled"]
Loading

File Walkthrough

Relevant files
Bug fix
15 files
run.py
Add GPU mode boolean computation and pass to templates     
+11/-2   
bridges2.mako
Replace gpu with gpu_enabled in conditionals                         
+2/-2     
carpenter-cray.mako
Replace gpu with gpu_enabled in conditionals                         
+1/-1     
carpenter.mako
Replace gpu with gpu_enabled in conditionals                         
+1/-1     
default.mako
Replace gpu with gpu_enabled in GPU task count                     
+1/-1     
delta.mako
Replace gpu with gpu_enabled in conditionals                         
+2/-2     
deltaai.mako
Replace gpu with gpu_enabled in conditionals                         
+2/-2     
frontier.mako
Replace gpu != 'no' with gpu_enabled throughout                   
+4/-4     
hipergator.mako
Replace gpu with gpu_enabled in conditionals                         
+2/-2     
nautilus.mako
Replace gpu with gpu_enabled in conditionals                         
+2/-2     
oscar.mako
Replace gpu with gpu_enabled in conditionals                         
+2/-2     
phoenix-bench.mako
Replace gpu with gpu_enabled in conditionals                         
+2/-2     
phoenix.mako
Replace gpu with gpu_enabled in conditionals                         
+2/-2     
santis.mako
Replace gpu with gpu_enabled in conditionals                         
+2/-2     
summit.mako
Replace gpu with gpu_enabled in jsrun arguments                   
+7/-7     


CodeAnt-AI Description

Make GPU enablement explicit in job scripts and HPC templates

What Changed

  • Job-script rendering now exposes explicit GPU mode flags (gpu_enabled, gpu_acc, gpu_mp) instead of an ambiguous gpu boolean so templates can determine GPU mode reliably.
  • Many HPC templates (Cray, Bridges2, Delta, Frontier, Phoenix, Summit, etc.) were updated to use gpu_enabled when deciding module loads and scheduler directives; generated scripts will request GPUs and load GPU modules only when GPU mode is enabled.
  • Launcher and scheduler options (jsrun --smpiargs, --gpu_per_rs, sbatch --gres/--gpus-per-node/--gpus-per-task, MPICH GPU env) are now included or omitted based on the explicit GPU flags, preventing incorrect GPU flags in submitted jobs.

Impact

✅ Fewer incorrect GPU allocations
✅ Correct GPU module loading
✅ Consistent GPU resource requests across clusters

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

Summary by CodeRabbit

  • Refactor
    • Unified GPU configuration handling across platforms and exposed a single GPU-enabled flag used by job templates.
  • Bug Fixes
    • Added validation for GPU mode with clearer errors on invalid values.
    • Changed default GPU selection to "none" when unspecified.
  • Other
    • Removed one legacy batch template and updated remaining templates to rely on the new GPU-enabled flag.

✏️ Tip: You can customize this high-level summary in your review settings.

Copilot AI review requested due to automatic review settings December 5, 2025 15:19
@codeant-ai
Copy link

codeant-ai bot commented Dec 5, 2025

CodeAnt AI is reviewing your PR.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 5, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Compute and validate GPU mode in the run script (using gpuConfigOptions), expose gpu booleans (gpu_enabled, gpu_acc, gpu_mp) to template context, change many batch templates to use gpu_enabled instead of gpu, adjust default GPU arg to NONE, and remove summit.mako.

Changes

Cohort / File(s) Summary
Run script & args
toolchain/mfc/run/run.py, toolchain/mfc/args.py
Add import of gpuConfigOptions; compute gpu_mode from ARG('gpu'), validate it (raise MFCException on invalid), derive gpu_enabled, gpu_acc, gpu_mp and pass them into template context; change GPU CLI default from ACC to NONE.
Batch scheduler templates (many)
toolchain/templates/*.{mako}, toolchain/templates/bridges2.mako, toolchain/templates/carpenter-cray.mako, toolchain/templates/carpenter.mako, toolchain/templates/default.mako, toolchain/templates/delta.mako, toolchain/templates/deltaai.mako, toolchain/templates/frontier.mako, toolchain/templates/hipergator.mako, toolchain/templates/nautilus.mako, toolchain/templates/oscar.mako, toolchain/templates/phoenix-bench.mako, toolchain/templates/phoenix.mako, toolchain/templates/santis.mako
Replace usages and conditionals of gpu with the new boolean gpu_enabled across SBATCH directives, module-loading commands, and GPU resource specifications; minor template formatting tweak in phoenix.mako.
Removed template
toolchain/templates/summit.mako
The summit.mako template file was removed entirely.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Multiple templates changed with a consistent pattern (moderate review time to spot inconsistencies).
  • Run-time validation added in run.py and CLI default change in args.py warrant careful checks:
    • run.py: validation/exception path and correct mapping from gpuConfigOptions to booleans.
    • args.py: ensure default change to NONE is intentional and documented.
    • Templates: verify all conditional branches and module-load argument substitutions use gpu_enabled consistently.

Possibly related PRs

Suggested labels

Review effort 2/5, size:XS

Poem

🐰 I hopped through templates, tidy and keen,
Swapped flags for booleans, neat and clean.
GPUs now flagged with gpu_enabled flair,
Defaults set gentle, validations fair.
A tiny rabbit clap—jobs run with care! 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive Title is vague and non-descriptive; uses informal phrasing ('for real though') that doesn't convey meaningful information about the changeset. Revise title to be more specific and professional, e.g., 'Replace ambiguous gpu flag with explicit gpu_enabled, gpu_acc, gpu_mp across HPC templates' or 'Fix GPU mode detection and template rendering with explicit boolean flags'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed PR description covers the main changes and objectives well, with detailed file walkthrough and clear motivation, but most template-related testing checklist items remain unchecked.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@qodo-code-review
Copy link
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Possible Issue

The new GPU mode booleans rely on exact enum .value matches; if ARG('gpu') can be None or an unexpected string, templates may misconfigure GPU flags. Validate defaults and input normalization.

# Compute GPU mode booleans for templates
gpu_mode = ARG('gpu')
gpu_enabled = (gpu_mode != gpuConfigOptions.NONE.value)
gpu_acc = (gpu_mode == gpuConfigOptions.ACC.value)
gpu_mp = (gpu_mode == gpuConfigOptions.MP.value)

content = __get_template().render(
    **{**ARGS(), 'targets': targets},
    ARG=ARG,
    env=env,
    case=case,
    MFC_ROOT_DIR=MFC_ROOT_DIR,
    SIMULATION=SIMULATION,
    qsystem=queues.get_system(),
    profiler=shlex.join(__profiler_prepend()),
    gpu_enabled=gpu_enabled,
    gpu_acc=gpu_acc,
    gpu_mp=gpu_mp
Typo Bug

The non-MPI path uses ${rofiler} instead of ${profiler}, likely breaking profiling invocation.

echo

% for target in targets:
    ${helpers.run_prologue(target)}

    % if not mpi:
        (set -x; ${rofiler} "${target.get_install_binpath(case)}")
    % else:
        (set -x; ${profiler} \
            jsrun                                              \
                ${'--smpiargs="-gpu"' if gpu_enabled else ''}  \
                --nrs          ${tasks_per_node*nodes}         \
                --cpu_per_rs   1                               \
                --gpu_per_rs   ${1 if gpu_enabled else 0}      \
                --tasks_per_rs 1                               \
                "${target.get_install_binpath(case)}")
Conditional Logic

--gpu_per_rs is tied only to gpu_enabled; for multi-mode support (ACC vs MP), consider differentiating MPI flags or counts based on gpu_acc/gpu_mp.

% if not mpi:
    (set -x; ${profiler} "${target.get_install_binpath(case)}")
% else:
    if [ "$binary" == "jsrun" ]; then
        (set -x; ${profiler}   \
            jsrun --nrs          ${tasks_per_node*nodes} \
                --cpu_per_rs   1                       \
                --gpu_per_rs   ${1 if gpu_enabled else 0}      \
                --tasks_per_rs 1                       \
                "${target.get_install_binpath(case)}")

@codeant-ai codeant-ai bot added the size:M This PR changes 30-99 lines, ignoring generated files label Dec 5, 2025
Copilot finished reviewing on behalf of sbryngelson December 5, 2025 15:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR standardizes GPU configuration variable naming across all HPC cluster templates by replacing the ambiguous gpu variable with the more explicit gpu_enabled. The change ensures consistency in how GPU mode is checked throughout the templating system and adds additional GPU mode variables for future extensibility.

Key Changes

  • Replaced gpu with gpu_enabled across 14 template files for clarity
  • Added GPU mode boolean computation in run.py that derives gpu_enabled, gpu_acc, and gpu_mp from the gpuConfigOptions enum
  • Maintained backward compatibility by computing these booleans from the existing gpu argument value

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.

Show a summary per file
File Description
toolchain/mfc/run/run.py Added import of gpuConfigOptions, computed GPU mode booleans (gpu_enabled, gpu_acc, gpu_mp), and passed them to template rendering
toolchain/templates/summit.mako Updated GPU checks from gpu to gpu_enabled in module loading and jsrun configuration
toolchain/templates/santis.mako Updated GPU checks from gpu to gpu_enabled in module loading and SLURM GPU binding
toolchain/templates/phoenix.mako Updated GPU checks from gpu to gpu_enabled in SLURM directives and module loading
toolchain/templates/phoenix-bench.mako Updated GPU checks from gpu to gpu_enabled in SLURM directives and module loading
toolchain/templates/oscar.mako Updated GPU checks from gpu to gpu_enabled in SLURM GPU allocation and module loading
toolchain/templates/nautilus.mako Updated GPU checks from gpu to gpu_enabled in SLURM GPU binding and module loading
toolchain/templates/hipergator.mako Updated GPU checks from gpu to gpu_enabled in SLURM GPU task allocation and module loading
toolchain/templates/frontier.mako Updated GPU checks from gpu != 'no' and gpu to consistent gpu_enabled usage in SLURM directives, module loading, and MPICH GPU support configuration
toolchain/templates/deltaai.mako Updated GPU checks from gpu to gpu_enabled in SLURM GPU allocation and module loading
toolchain/templates/delta.mako Updated GPU checks from gpu to gpu_enabled in SLURM GPU allocation and module loading
toolchain/templates/default.mako Updated GPU check from gpu to gpu_enabled in jsrun GPU resource allocation
toolchain/templates/carpenter.mako Updated GPU check from gpu to gpu_enabled in module loading
toolchain/templates/carpenter-cray.mako Updated GPU check from gpu to gpu_enabled in module loading

@codeant-ai
Copy link

codeant-ai bot commented Dec 5, 2025

CodeAnt AI finished reviewing your PR.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6c380cd and 831a8ca.

📒 Files selected for processing (15)
  • toolchain/mfc/run/run.py (3 hunks)
  • toolchain/templates/bridges2.mako (2 hunks)
  • toolchain/templates/carpenter-cray.mako (1 hunks)
  • toolchain/templates/carpenter.mako (1 hunks)
  • toolchain/templates/default.mako (1 hunks)
  • toolchain/templates/delta.mako (2 hunks)
  • toolchain/templates/deltaai.mako (2 hunks)
  • toolchain/templates/frontier.mako (3 hunks)
  • toolchain/templates/hipergator.mako (2 hunks)
  • toolchain/templates/nautilus.mako (2 hunks)
  • toolchain/templates/oscar.mako (2 hunks)
  • toolchain/templates/phoenix-bench.mako (2 hunks)
  • toolchain/templates/phoenix.mako (2 hunks)
  • toolchain/templates/santis.mako (2 hunks)
  • toolchain/templates/summit.mako (2 hunks)
🧰 Additional context used
🧠 Learnings (8)
📚 Learning: 2025-11-24T21:50:16.713Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T21:50:16.713Z
Learning: Applies to src/simulation/**/*.{fpp,f90} : Ensure GPU code compiles with Cray ftn, NVIDIA nvfortran, GNU gfortran, and Intel ifx/ifort compilers

Applied to files:

  • toolchain/templates/frontier.mako
  • toolchain/templates/bridges2.mako
  • toolchain/templates/delta.mako
  • toolchain/templates/hipergator.mako
  • toolchain/templates/summit.mako
  • toolchain/mfc/run/run.py
  • toolchain/templates/oscar.mako
  • toolchain/templates/phoenix.mako
  • toolchain/templates/phoenix-bench.mako
  • toolchain/templates/carpenter-cray.mako
  • toolchain/templates/carpenter.mako
  • toolchain/templates/default.mako
  • toolchain/templates/nautilus.mako
  • toolchain/templates/santis.mako
📚 Learning: 2025-11-24T21:50:46.909Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .cursor/rules/mfc-agent-rules.mdc:0-0
Timestamp: 2025-11-24T21:50:46.909Z
Learning: Applies to src/simulation/**/*.{fpp,f90} : Mark GPU-callable helpers with `$:GPU_ROUTINE(function_name='...', parallelism='[seq]')` immediately after declaration

Applied to files:

  • toolchain/templates/frontier.mako
  • toolchain/templates/delta.mako
  • toolchain/templates/hipergator.mako
  • toolchain/templates/summit.mako
  • toolchain/templates/oscar.mako
  • toolchain/templates/phoenix-bench.mako
  • toolchain/templates/carpenter.mako
  • toolchain/templates/santis.mako
📚 Learning: 2025-11-24T21:50:46.909Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .cursor/rules/mfc-agent-rules.mdc:0-0
Timestamp: 2025-11-24T21:50:46.909Z
Learning: Applies to src/simulation/**/*.{fpp,f90} : Wrap tight loops with `$:GPU_PARALLEL_FOR(private='[...]', copy='[...]')` macro; add `collapse=n` for safe nested loop merging

Applied to files:

  • toolchain/templates/frontier.mako
  • toolchain/templates/hipergator.mako
  • toolchain/templates/summit.mako
  • toolchain/templates/oscar.mako
  • toolchain/templates/phoenix-bench.mako
📚 Learning: 2025-11-24T21:50:16.713Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T21:50:16.713Z
Learning: Applies to src/simulation/**/*.{fpp,f90} : Wrap tight GPU loops with !$acc parallel loop gang vector default(present) reduction(...); add collapse(n) when safe; declare loop-local variables with private(...)

Applied to files:

  • toolchain/templates/frontier.mako
  • toolchain/templates/hipergator.mako
  • toolchain/templates/summit.mako
  • toolchain/templates/oscar.mako
  • toolchain/templates/phoenix-bench.mako
📚 Learning: 2025-11-24T21:50:46.909Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .cursor/rules/mfc-agent-rules.mdc:0-0
Timestamp: 2025-11-24T21:50:46.909Z
Learning: Applies to src/simulation/**/*.{fpp,f90} : Declare loop-local variables with `private='[...]'` in GPU parallel loop macros

Applied to files:

  • toolchain/templates/summit.mako
📚 Learning: 2025-11-24T21:50:16.713Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T21:50:16.713Z
Learning: Applies to src/simulation/**/*.{fpp,f90} : Avoid stop/error stop inside GPU device code

Applied to files:

  • toolchain/templates/oscar.mako
📚 Learning: 2025-11-24T21:50:46.909Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .cursor/rules/mfc-agent-rules.mdc:0-0
Timestamp: 2025-11-24T21:50:46.909Z
Learning: Compile with Cray `ftn` or NVIDIA `nvfortran` for GPU offloading; also build CPU-only with GNU `gfortran` and Intel `ifx`/`ifort` for portability

Applied to files:

  • toolchain/templates/phoenix-bench.mako
📚 Learning: 2025-11-24T21:50:46.909Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .cursor/rules/mfc-agent-rules.mdc:0-0
Timestamp: 2025-11-24T21:50:46.909Z
Learning: Draft a step-by-step plan before making changes; build after each step using `./mfc.sh build -t pre_process simulation -j $(nproc)`

Applied to files:

  • toolchain/templates/carpenter-cray.mako
🧬 Code graph analysis (1)
toolchain/mfc/run/run.py (1)
toolchain/mfc/state.py (4)
  • ARG (85-93)
  • ARGS (95-98)
  • CFG (100-103)
  • gpuConfigOptions (5-8)
🪛 GitHub Actions: Lint Toolchain
toolchain/mfc/run/run.py

[error] 104-106: Pylint identified unnecessary parentheses after assignment in lines 104-106. Process exited with code 16.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (23)
  • GitHub Check: Detect File Changes
  • GitHub Check: Detect File Changes
  • GitHub Check: Georgia Tech | Phoenix (NVHPC) (gpu)
  • GitHub Check: Oak Ridge | Frontier (CCE) (gpu)
  • GitHub Check: Georgia Tech | Phoenix (NVHPC) (cpu)
  • GitHub Check: Self Hosted (cpu, none, frontier)
  • GitHub Check: Self Hosted (gpu, omp, gt)
  • GitHub Check: Self Hosted (cpu, none, gt)
  • GitHub Check: Github (macos, mpi, no-debug, false)
  • GitHub Check: Self Hosted (gpu, acc, frontier)
  • GitHub Check: Self Hosted (gpu, omp, frontier)
  • GitHub Check: Github (ubuntu, no-mpi, single, no-debug, false)
  • GitHub Check: Github (macos, mpi, debug, false)
  • GitHub Check: Self Hosted (gpu, acc, gt)
  • GitHub Check: Github (ubuntu, mpi, no-debug, true)
  • GitHub Check: Github (ubuntu, mpi, debug, false)
  • GitHub Check: Github (ubuntu, mpi, debug, true)
  • GitHub Check: Github (ubuntu, mpi, no-debug, false)
  • GitHub Check: Coverage Test on CodeCov
  • GitHub Check: Code Cleanliness Check
  • GitHub Check: Agent
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Build & Publish
🔇 Additional comments (19)
toolchain/templates/carpenter.mako (1)

28-28: LGTM!

Consistent with the gpu → gpu_enabled refactoring.

toolchain/templates/phoenix-bench.mako (2)

20-23: LGTM!

GPU resource allocation correctly gated by gpu_enabled.


34-34: LGTM!

Module loading mode selection correctly uses gpu_enabled.

toolchain/templates/oscar.mako (2)

17-21: LGTM!

SBATCH GPU directives correctly gated by gpu_enabled.


35-35: LGTM!

Module loading correctly uses gpu_enabled.

toolchain/templates/deltaai.mako (2)

17-21: LGTM!

SBATCH GPU configuration correctly gated by gpu_enabled.


35-35: LGTM!

Module loading mode correctly uses gpu_enabled.

toolchain/templates/default.mako (1)

51-51: LGTM!

GPU allocation for jsrun correctly uses gpu_enabled. The conditional expression properly assigns 1 GPU per resource set when GPU mode is enabled, 0 otherwise.

toolchain/templates/santis.mako (2)

62-62: LGTM!

Module loading mode correctly uses gpu_enabled for batch engine.


77-79: LGTM!

srun GPU allocation correctly gated by gpu_enabled.

toolchain/templates/nautilus.mako (2)

17-20: LGTM!

SBATCH GPU directives correctly gated by gpu_enabled.


34-34: LGTM!

Module loading mode correctly uses gpu_enabled.

toolchain/templates/carpenter-cray.mako (1)

28-28: LGTM! Verify all templates updated.

The rename from gpu to gpu_enabled improves clarity and aligns with the broader refactoring. Run the following to verify no templates still reference the old gpu variable:

rg -n '\$\{\s*gpu\s*[:\}]|%\s+if\s+gpu\s*:|if\s+gpu\s+else' toolchain/templates/ --type mako
toolchain/templates/bridges2.mako (1)

17-20: Swapping to gpu_enabled in SBATCH and load command looks correct

Using gpu_enabled to gate GPU SBATCH directives and to choose -m g vs -m c in mfc.sh load keeps the template consistent with the new boolean from run.py and avoids the old truthiness issue of string values.

Also applies to: 34-34

toolchain/templates/delta.mako (1)

17-21: GPU resource gating via gpu_enabled is consistent and fixes prior string-truthiness

Conditioning --gpus-per-node, --mem, and --gpu-bind plus the mfc.sh -m mode on gpu_enabled aligns this template with the new GPU-mode booleans and should prevent requesting GPUs when gpu='no'.

Also applies to: 35-35

toolchain/templates/phoenix.mako (1)

20-23: Phoenix template now correctly follows gpu_enabled

Using gpu_enabled for the GPU SBATCH block and for selecting GPU vs CPU module mode is consistent with the new run-time flags and keeps behavior in sync with other templates.

Also applies to: 34-34

toolchain/templates/summit.mako (1)

19-19: Summit GPU enablement wiring via gpu_enabled looks good

Choosing -m g vs -m c in mfc.sh load and toggling --smpiargs="-gpu" / --gpu_per_rs based on gpu_enabled matches the intended GPU-mode boolean semantics and keeps CPU-only jobs free of GPU flags.

Also applies to: 30-35

toolchain/templates/hipergator.mako (1)

12-15: Hipergator GPU flags now correctly keyed off gpu_enabled

Gating --gpus-per-task / --gpu-bind and the mfc.sh -m argument on gpu_enabled is consistent with the new run-time GPU booleans and keeps CPU jobs from requesting GPUs or GPU modules.

Also applies to: 38-38

toolchain/templates/frontier.mako (1)

13-16: Frontier template correctly centralizes GPU behavior on gpu_enabled

Switching SBATCH GPU directives, MPICH_GPU_SUPPORT_ENABLED, interactive srun GPU flags, and the mfc.sh -m mode to use gpu_enabled unifies GPU control and keeps CPU-only runs from accidentally enabling GPU-related options.

Also applies to: 37-37, 42-46, 69-71

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 15 files

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
toolchain/mfc/run/run.py (1)

102-115: GPU mode validation and boolean derivation are logically sound

  • gpu_mode = ARG('gpu') plus valid_gpu_modes = {e.value for e in gpuConfigOptions} and the membership check ensure only known modes (NONE/ACC/MP) are accepted before template rendering.
  • The derived flags
    • gpu_enabled = gpu_mode != gpuConfigOptions.NONE.value,
    • gpu_acc = gpu_mode == gpuConfigOptions.ACC.value,
    • gpu_mp = gpu_mode == gpuConfigOptions.MP.value
      are mutually consistent and cover all enum cases, which matches how templates are expected to gate GPU behaviors.

This should give templates a clear, unambiguous view of the GPU state.

If Ruff’s TRY003 warning about the long MFCException message becomes noisy, you could optionally factor the mode list into a small helper (or constant) to shorten the raise site, but that’s stylistic and not functionally required.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 831a8ca and 5d6f9ae.

📒 Files selected for processing (5)
  • toolchain/mfc/args.py (1 hunks)
  • toolchain/mfc/run/run.py (3 hunks)
  • toolchain/templates/frontier.mako (3 hunks)
  • toolchain/templates/phoenix.mako (2 hunks)
  • toolchain/templates/summit.mako (0 hunks)
💤 Files with no reviewable changes (1)
  • toolchain/templates/summit.mako
🚧 Files skipped from review as they are similar to previous changes (2)
  • toolchain/templates/frontier.mako
  • toolchain/templates/phoenix.mako
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: 2025-11-24T21:50:46.909Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .cursor/rules/mfc-agent-rules.mdc:0-0
Timestamp: 2025-11-24T21:50:46.909Z
Learning: Applies to src/simulation/**/*.{fpp,f90} : Do not use OpenACC or OpenMP directives directly; use Fypp macros from `src/common/include/parallel_macros.fpp` instead

Applied to files:

  • toolchain/mfc/run/run.py
📚 Learning: 2025-11-24T21:50:46.909Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .cursor/rules/mfc-agent-rules.mdc:0-0
Timestamp: 2025-11-24T21:50:46.909Z
Learning: Applies to src/simulation/**/*.{fpp,f90} : Mark GPU-callable helpers with `$:GPU_ROUTINE(function_name='...', parallelism='[seq]')` immediately after declaration

Applied to files:

  • toolchain/mfc/run/run.py
📚 Learning: 2025-11-24T21:50:16.713Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T21:50:16.713Z
Learning: Applies to src/simulation/**/*.{fpp,f90} : Wrap tight GPU loops with !$acc parallel loop gang vector default(present) reduction(...); add collapse(n) when safe; declare loop-local variables with private(...)

Applied to files:

  • toolchain/mfc/run/run.py
📚 Learning: 2025-11-24T21:50:16.713Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T21:50:16.713Z
Learning: Applies to src/simulation/**/*.{fpp,f90} : Ensure GPU code compiles with Cray ftn, NVIDIA nvfortran, GNU gfortran, and Intel ifx/ifort compilers

Applied to files:

  • toolchain/mfc/run/run.py
🧬 Code graph analysis (1)
toolchain/mfc/args.py (1)
toolchain/mfc/state.py (1)
  • gpuConfigOptions (5-8)
🪛 Ruff (0.14.7)
toolchain/mfc/run/run.py

108-110: Avoid specifying long messages outside the exception class

(TRY003)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: Coverage Test on CodeCov
  • GitHub Check: Code Cleanliness Check
  • GitHub Check: Github (ubuntu, mpi, no-debug, false)
  • GitHub Check: Github (ubuntu, mpi, debug, false)
  • GitHub Check: Github (ubuntu, no-mpi, single, no-debug, false)
  • GitHub Check: Github (macos, mpi, no-debug, false)
  • GitHub Check: Github (macos, mpi, debug, false)
  • GitHub Check: Github (ubuntu, mpi, no-debug, true)
  • GitHub Check: Github (ubuntu, mpi, debug, true)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Build & Publish
🔇 Additional comments (3)
toolchain/mfc/args.py (1)

60-66: GPU CLI default semantics look correct and align with new gpu mode handling

The --gpu / --no-gpu setup with nargs='?', const=gpuConfigOptions.ACC.value, and default=gpuConfigOptions.NONE.value correctly gives:

  • CPU by default (NONE),
  • ACC when --gpu is passed without an argument,
  • and an explicit mode when --gpu {acc,mp,no} is used,

while --no-gpu forces NONE. This matches the gpuConfigOptions enum and the downstream ARG('gpu') handling in run.py.

toolchain/mfc/run/run.py (2)

10-10: Importing gpuConfigOptions here is appropriate

Pulling gpuConfigOptions into run.py alongside ARG/ARGS/CFG is the right place for centralizing GPU mode handling and keeps run-time validation close to argument access.


124-127: Template context wiring for GPU/profiler flags looks consistent

Adding profiler=shlex.join(__profiler_prepend()) and exposing gpu_enabled, gpu_acc, and gpu_mp in the render context is coherent with the new GPU semantics and keeps templates free from direct ARG('gpu') parsing. Assuming the templates have been updated to use these flags (as described in the PR), this wiring should support the intended conditional GPU configuration cleanly.

@codecov
Copy link

codecov bot commented Dec 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 44.16%. Comparing base (6c380cd) to head (5d6f9ae).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1077   +/-   ##
=======================================
  Coverage   44.16%   44.16%           
=======================================
  Files          71       71           
  Lines       20197    20197           
  Branches     1970     1970           
=======================================
  Hits         8921     8921           
  Misses      10148    10148           
  Partials     1128     1128           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sbryngelson sbryngelson requested a review from Copilot December 5, 2025 19:31
@sbryngelson
Copy link
Member Author

/improve

Comment on lines 34 to 36
cd "${MFC_ROOTDIR}"
. ./mfc.sh load -c o -m ${'g' if gpu else 'c'}
. ./mfc.sh load -c o -m ${'g' if gpu_enabled else 'c'}
cd - > /dev/null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Correct the typo in the environment variable from ${MFC_ROOTDIR} to ${MFC_ROOT_DIR} in the oscar.mako template. [possible issue, importance: 9]

Suggested change
cd "${MFC_ROOTDIR}"
. ./mfc.sh load -c o -m ${'g' if gpu else 'c'}
. ./mfc.sh load -c o -m ${'g' if gpu_enabled else 'c'}
cd - > /dev/null
cd "${MFC_ROOT_DIR}"
. ./mfc.sh load -c o -m ${'g' if gpu_enabled else 'c'}
cd - > /dev/null

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

@sbryngelson sbryngelson merged commit 8d9a83b into MFlowCode:master Dec 5, 2025
52 of 55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review effort 3/5 size:M This PR changes 30-99 lines, ignoring generated files

Development

Successfully merging this pull request may close these issues.

1 participant