Skip to content

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

Closed
ardangelo wants to merge 9 commits into
masterfrom
bugfix/CPE-19432
Closed

ardangelo wants to merge 9 commits into
masterfrom
bugfix/CPE-19432

Conversation

@ardangelo

Copy link
Copy Markdown
Contributor

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 hetereogeneous 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 is more fragile (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:

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.dangelo@hpe.com and others added 9 commits March 30, 2026 08:39
Open source buildable CTI

This is the first version that should be entirely buildable without HPE internal repositories.
- replace autotools build with meson
- made flux and PALS support optional
- rely on system installed libssh2, libarchive, libsodium, boost, and dynast
- 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.
@ardangelo
ardangelo requested a review from johnlvogt November 20, 2026 20:10
@ardangelo

Copy link
Copy Markdown
Contributor Author

Opened PR in new public repo HPE/common-tools-interface#2

@ardangelo ardangelo closed this Nov 23, 2026
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