← Back to Pull requests

Add ntasks to SlurmExecutor (#381) #589

Closed
unknown closed this pull request without merging on Oct 02, 2026 17:58 UTC
View on GitHub
unknown unknown commented on Aug 19, 2026 08:00 UTC
Author

Closes #381.

Why this was awkward before

SlurmExecutor.SBATCH_FLAGS already contains "ntasks", and SlurmBatchRequest builds its sbatch parameters as asdict(executor) filtered through that list. So the flag was reachable in principle but the field never existed, which left additional_parameters={"ntasks": 8} as the only route, and that still emitted --ntasks-per-node=1 alongside it from the field default. @activatedgeek's point in the issue is exactly that: the user ends up hand-deriving a per-node topology for what Slurm can size directly.

Change

  • New field ntasks: Optional[int] = None. Being in SBATCH_FLAGS already, it renders as #SBATCH --ntasks=<n> with no plumbing.

  • When ntasks is set, ntasks_per_node is dropped from the emitted flags. Slurm treats --ntasks-per-node as a per-node maximum when --ntasks is also present, so leaving the default of 1 in place would cap an explicit --ntasks=8 at one task per node. The same exclusion is applied in the interactive srun() helper, since SRUN_ARGS lists both names and would otherwise drift from the sbatch path.

  • ntasks with heterogeneous=True is rejected in __post_init__. Het groups get their sizes from resource_group entries, which carry their own ntasks_per_node, so a top-level total would be silently overridden. A clear assertion beats that.
  • Default behaviour is unchanged: with ntasks unset, the script still renders #SBATCH --ntasks-per-node=1 and no --ntasks.

    Tests

    Four in test/core/execution/test_slurm_templates.py:

  • test_dummy_batch_request_ntasks materializes with ntasks=8 and asserts --ntasks=8 is present and --ntasks-per-node is gone.

  • test_dummy_batch_request_ntasks_per_node_default pins the unchanged default path.

  • test_srun_ntasks_drops_ntasks_per_node asserts the interactive srun command agrees with sbatch, so the two copies of the rule cannot diverge.

  • test_ntasks_rejected_for_heterogeneous covers the assertion.
  • Verified locally: 42 passed in that file, 142 passed across test_slurm.py, test_slurm_templates.py, test_slurm_job_name.py and test/run/test_experiment.py. Reverting only the nemo_run/ half fails 3 of the 4 new tests. ruff format --diff and ruff check clean. No Slurm cluster here, so the verification is at the rendered-script level, and the flag semantics are per the sbatch and srun man pages rather than measured.

    @ko3n1g one design question worth your call: I made ntasks win over ntasks_per_node because the latter is a field default rather than an explicit choice. If you would rather have ntasks_per_node win, or have both emitted and let Slurm reject the combination, say which and I will switch it.

    Diff: 340 lines (+255 / -85) across 4 files Reviewer: CodersAcademy006 Review duration: 63958m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 340 lines diff across 4 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.349
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #589"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.3% (MEDIUM) · Higher = larger blast radius
    42.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.7% · Safe to merge
    16.7%