Skip to content

Fix: CPE-19432: Get GPUs per node and use value for tool daemon launches - #2

Merged
ardangelo merged 4 commits into
mainfrom
bugfix/CPE-19432
Nov 23, 2026
Merged

ardangelo merged 4 commits into
mainfrom
bugfix/CPE-19432

Conversation

@ardangelo

Copy link
Copy Markdown
Collaborator

When a step requests a total job GPU count (instead of per node), Slurm
allocates the GPUs for each node:

  • Non-overlap launch: Allocate the
    maximum number of GPUs on that node and subtract from total
  • Overlap launch: Allocate one GPU for that node, except for the last node in the list, try to get the rest of the GPUs from the last node If the last node
    doesn't have enough GPUs, it fails with "Insufficient GRES"

This is causing CTI tool daemon launches (using `--overlap) to fail, and in turn TotalView MRNet launches to fail on Perlmutter (Slurm 25.11.8). CTI currently has GRES workarounds:

  • Attach: CTI passes no --gres option, CTI_SLURM_DAEMON_GRES is ignored.
  • Launch: CTI passes --gres=none unless the user's srun has --gres=gpu:.... The daemons start but can't see any GPUs.
  • CPE-15394 workaround: based on SchedMD 23832, which fixed a different problem.

Behavior changes

The old ceil(SLURM_GPUS / SLURM_NNODES) GPU count setting did not fully fix the problem. Indeed, this PR does not fix all problems with GRES GPU allocation, but it gets closer. Nodes can have different numbers of GPUs per nodes, but even with the old workaround, the tool daemon launches
could only supply a fixed number of GPUs per node. This PR implements an additional option to use heterogeneous srun syntax to supply multiple
GPU counts in a single tool daemon launch.

CTI_SLURM_DAEMON_GRES_SPLIT disabled (default)

By default, CTI will pick the safe solution and request the minimum number of GPUs per node that satisfies the allocation settings. Depending on whether Slurm ended up allocating an even number of GPUs per node, or uneven, this can either work fine (even allocation), or result in some GPUs not being visible to the tool daemons (uneven allocation).

Even GPUs (e.g. 4+4)

  • Tool daemons start as one srun with --gres=gpu:4 on every node, and CTI removes SLURM_GPUS from that srun's environment.
  • Every daemon sees all of the job's GPUs on its node, and there's no warning.

Uneven GPUs (e.g. 4+2)

  • CTI expands the job's node lists from scontrol show job -d with scontrol show hostnames. It
    matches them against the node names in the step layout (sattach --layout), and chooses the number of GPUs to request:
    • Application on nodes with the same count, e.g. only on the 4-GPU node: one srun with
      --gres=gpu:4, no warning.
    • Application on nodes with different
      counts:
      one srun with the smallest count on every node (--gres=gpu:2). Daemons on the larger nodes see only some of that node's GPUs. CTI prints a warning, listing those nodes and recommending CTI_SLURM_DAEMON_GRES_SPLIT=1, or an even GPU allocation.

CTI_SLURM_DAEMON_GRES_SPLIT=1

This enables using a heterogeneous job launch to start the tool daemon. It relies on more hostname parsing, so can fail (thus behind the flag), but supports tool daemons running on nodes with an uneven GPU allocation split with full GPU visibility.

Even GPUs (e.g. 4+4)

  • Same as the default: one srun with --gres=gpu:4 and no warning.

Uneven GPUs (e.g. 4+2)

  • When the application's nodes have different GPU counts, CTI starts the daemons as one srun with a separate component per count, and removes SLURM_GPUS from its environment:
    srun --nodes=1 --gres=gpu:2 --nodelist=<2-GPU nodes> … : --nodes=1 --gres=gpu:4 --nodelist=<4-GPU nodes> …
  • Every daemon sees all of the job's GPUs on its node, and there's no warning. - If CTI can't use the
    job launch workaround, it tries the default single smallest GPU request and prints a warning that the flag couldn't be used.
    • the job is a heterogeneous job (HetJobId= in scontrol show job -d)
    • the GPU request came from the launcher or from CTI_SLURM_DAEMON_GRES
    • CTI couldn't determine the GPU count of an application node.

Code changes

Per-node GPU request from the job allocation

SLURMApp runs scontrol show job -d for both launch and attach, and turns the per-node GPU counts into a per-node --gres, using the smallest count seen on the nodes:

// SLURMApp constructor
, m_jobGpus { query_job_gpus(m_jobId) } // scontrol show job -d
, m_appGpuGroups { get_app_gpu_groups(m_jobGpus, m_stepLayout) } // uneven only: scontrol show hostnames
, m_requestNodeGpus { get_request_node_gpus(m_jobGpus, m_appGpuGroups) } // application's nodes, else all job nodes
, m_gresSetting { get_daemon_gres(m_requestNodeGpus) } // "gpu:<min>", "none", or ""

When CTI launches the application itself, get_gres_setting() returns the request together with a flag if the GRES was from an allocation (i.e. from Slurm, and not calculated by CTI as part of the previous fallback).
Later on, it will only apply the split GRES request if the GRES setting
was from CTI.

appPtr->setGres(detail::get_gres_setting(launcher_args, appPtr->getGres())); // {gres, fromAllocation} ```

### Don't inherit the job's GPU total

Every tool daemon `srun` that uses CTI's calculated GRES setting now
blacklists `SLURM_GPUS`:
```cpp
cti::ManagedArgv
SLURMApp::daemonLauncherEnv() const {
    // ... existing CTIBLACKLIST_ entries
    if (!m_gresSetting.empty()) {
        result.add("CTIBLACKLIST_SLURM_GPUS=");
    }
}

Optional split GRES request for tool daemon launches

With CTI_SLURM_DAEMON_GRES_SPLIT=1, generateDaemonLauncherArgv()
builds a heterogeneous srun command, one per GPU count, so that it can
properly supply the GPU counts for each specific node (instead of the
global minimum GPU setting without the flag).

bool
SLURMApp::canSplitDaemonGres() const {
    return (m_appGpuGroups.size() >= 2) && !m_jobGpus.hetJob &&
(m_stepLayout.size() == 1)
        && m_gresFromAllocation;
}
// generateDaemonLauncherArgv(): one component per GPU count, separated
by ":" for (auto&& [gpus, hostnames] : gpuGroups) {
    result.add("--nodes=" + std::to_string(hostnames.size()));
    result.add((gpus > 0) ? "--gres=gpu:" + std::to_string(gpus) :
"--gres=none");
    // ... daemon args, --nodelist=<hostnames>, daemon command
}

Andrew D'Angelo added 4 commits November 20, 2026 20:35
- Print a warning naming the node groups whose GPU count exceeds the per-node
  --gres request: one srun applies the same --gres=gpu:N to every node, so on
  uneven allocations tool daemons only get N GPUs on the larger nodes and GPU
  debugging there may fail.
- Split allocation parsing (get_job_node_gpus) from the --gres choice so the
  warning can name the affected nodes.
…ON_GRES_SPLIT

- On uneven allocations, expand the job's node lists (scontrol show hostnames)
  and look up the GPU count of each node in the sattach step layout, then size
  --gres=gpu:N from the application's nodes: an application on the larger nodes
  of a 4+2 job got only 2 GPUs per daemon.
- Remove SLURM_GPUS from every daemon srun that carries CTI's --gres: the
  inherited -G total made single-node and subset daemon steps fail with
  "Invalid generic resource (gres) specification".
- With CTI_SLURM_DAEMON_GRES_SPLIT=1, launch daemons as a heterogeneous step with
  one component per GPU count, so every node gets all its GPUs; off by default
  and recommended by the uneven-allocation warning.
- Split only CTI's own allocation-based request (tracked, not string-compared)
  and never inside heterogeneous jobs (HetJobId= in scontrol show job -d), where
  Slurm rejects heterogeneous steps.
- Return no --gres from get_gres_setting when CTI_SLURM_DAEMON_GPUS_PER_NODE is
  set: launches without a GPU request fell back to --gres=none, which next to
  --gpus-per-node gave tool daemons no GPUs.
- Document that the knob also replaces a --gres taken from the launcher.
Comment thread doc/man/cti.1.md
**srun** command. If *CTI_SLURM_DAEMON_GRES* is also set, both are passed.

- *CTI_SLURM_DAEMON_GRES_SPLIT*: Set to `1` when the job's nodes have
different numbers of GPUs, to give tool daemons all of the GPUs on each

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this comma should be here.

Comment thread doc/man/cti.1.md

- *CTI_SLURM_DAEMON_GRES_SPLIT*: Set to `1` when the job's nodes have
different numbers of GPUs, to give tool daemons all of the GPUs on each
node. CTI then starts tool daemons as a heterogeneous job step with one

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Try this on:
"If set, CTI creates a separate job step component for each distinct gpu count to provide the correct --gres option for each."

Is this not the default behavior because it can't be applied no heterogenous jobs?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it doesn't work with heterogeneous jobs. There are some other cases too where it's incompatible, I'd rather put it behind a flag.

@ardangelo
ardangelo merged commit f8d7d83 into main Nov 23, 2026
@ardangelo
ardangelo deleted the bugfix/CPE-19432 branch November 23, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants