Placement¶
Placement decides on which node each population runs, and on which GPUs its simulations run. Locally, and under Dragon on one node, nothing is placed: everything runs on that node.
Nodes¶
Under one Dragon runtime that spans several nodes, the campaign uses every node:
- Populations go to the nodes in contiguous blocks: population
iofPgoes to nodei × N // P, the mini-app's node being node 0. 6 populations on 3 nodes give 2 per node; 6 on 4 give 2, 1, 2, 1. With fewer populations than nodes, some nodes get none: 2 on 4 go to the first and the third. - A population's process runs on its node, and its engine's native backend keeps its workers
there (RHAPSODY's
hosts=). Give each population its node's share of cores inworkers. - The store: RaDEX's dictionary has
store_managersmanagers on every node. - The services: the MCP servers and the tool services run on the mini-app's node, with all their queues. Each population puts its requests and gets its replies across the nodes.
- The model servers are not placed: every population sends to every server.
A population names its node through its AsyncFlow task's process_template: a Dragon host policy, and
cwd, so that RHAPSODY starts it as a process of its own rather than in the mini-app's pool. This
stands in for AsyncFlow placement keys, which do not exist yet.
Rules¶
- Populations with CPU workers on several nodes need RHAPSODY's native backend with
hosts=(rhapsody#169), which RHAPSODY 0.8.0 brings. With an older RHAPSODY each population's backend would start its CPU workers on every node, so the campaign refuses to start. GPU-only populations (workers=0) start no CPU workers and run without it. - The run directory, and the directory the mini-app starts in, must be on a filesystem every node shares: each population writes its records from its own node, and starts in the mini-app's directory.
GPUs¶
CampaignConfig.simulation_gpus names the simulations' GPUs on each node:
| Value | GPUs on each node |
|---|---|
| None (default) | none: simulations run on CPUs |
"all" |
every GPU the job has on the node, when the model servers run in a job of their own |
a list, as [2, 3] |
the same ids on every node: those the model servers leave, when they share the job |
a dict, as {"node-a": "all", "node-b": [0]} |
per node; it must name every node that runs populations |
Ids are the job's numbering on each node, from 0 (see GPU ids), so GPU 0 of one node is not GPU 0 of another.
The populations on a node share its GPUs: with at least as many GPUs as
populations, each gets every P-th GPU; with fewer, each gets one GPU that others share.
PopulationConfig.gpu_slots (1) is how many simulations run at once on each GPU.
- Locally the simulations run on
autonmi.pools.GpuPools: a pool of spawned processes per GPU, whose workers see only their GPU. Each simulation goes to the GPU with the fewest in flight. The script needs theif __name__ == "__main__":guard (GPUs for simulations). - Under Dragon each population's task tools are pinned to its GPU on its node (a Dragon policy
that names the host and the GPU), so RHAPSODY's native backend runs them on pool workers started for
that GPU, which see only it. A population of scripted agents may have several GPUs: each new run
goes to the GPU with the fewest of its runs in flight. A population of tool-calling agents takes
one: AUTONMI does not use Flowgentic 0.7.0's placement of each call (
ToolRuntime(place=...)) yet. - Simulations on CPUs see no GPU when they run in processes of their own (under Dragon, or on a process pool): each task empties the GPU variables in its worker first, since Dragon gives its CPU workers every GPU of the job. On a thread pool they run in the agents' process, which AUTONMI leaves as it is.
GPU ids and their variables¶
- Under Dragon the ids are those Dragon lists on the node. Dragon pins each GPU worker:
CUDA_VISIBLE_DEVICESon NVIDIA GPUs,ROCR_VISIBLE_DEVICESon AMD ones. - Locally they are positions in the list of the variable that lists the job's GPUs:
CUDA_VISIBLE_DEVICESwhen it names a GPU, elseROCR_VISIBLE_DEVICESwhen it is set. WithCUDA_VISIBLE_DEVICES=4,6, GPU 1 is device 6. With neither set, an id is the device's own number.
What each variable holds in a local pool's worker, for GPU 1 of a job:
| Variable | The job sets CUDA's and ROCr's to 4,6 |
CUDA's alone, 4,6 |
ROCr's alone, 4,6 |
A worker of CPU simulations |
|---|---|---|---|---|
CUDA_VISIBLE_DEVICES |
6 |
6 |
as the job set it | empty |
ROCR_VISIBLE_DEVICES |
4,6, as the job set it |
as the job set it | 6 |
empty |
HIP_VISIBLE_DEVICES |
1 |
6 |
0 |
empty |
CUDA's comes first because Slurm can set both CUDA's and ROCr's, to the same list. On AMD GPUs ROCr's
applies first, and HIP's and CUDA's are positions among the GPUs it leaves. HIP reads its own
variable before CUDA's, and PyTorch's device count can ignore CUDA's when ROCr's is set, so every
GPU's worker gets HIP's: its position among the GPUs ROCr's leaves. With both CUDA's and ROCr's set,
that position assumes they hold the same list, as Slurm sets them. NVIDIA's CUDA ignores HIP's and
ROCr's. Under Dragon, a worker of CPU simulations gets the three variables emptied as well. Other
variables that Slurm may set, such as GPU_DEVICE_ORDINAL and ZE_AFFINITY_MASK, are left as they
are.
Rules¶
- Give
simulation_gpusorPopulationConfig.gpus, not both. - The campaign checks every GPU id against what Dragon lists on its node before anything starts.
- Two settings are refused only in a population's process, once the services and the other
populations have started:
- under Dragon, a population of tool-calling agents with more than one GPU (give the campaign at least as many populations as GPUs on each node);
- locally, a population with both GPUs and an
executor. Under Dragon the campaign ignoresexecutor, with a warning.
- Set
workers=0when every simulation runs on a GPU, so that no CPU workers start. - Dragon must list the GPU. Where it lists none, it needs the CUDA runtime's unversioned
libcudart.soonLD_LIBRARY_PATH. - An application's own process pool (
PopulationConfig.executor) gets its GPU variables emptied too, with a warning: give the population GPUs to run its simulations on GPUs.
Tested¶
Across nodes, with Dragon 0.15 and RHAPSODY with hosts=: 3,000 agents in 6 populations on one, two
and three nodes, with the same agents' results on each. GPUs: on one node, and on two nodes with one
GPU each, "all" with 2 populations and [0] with 4: every simulation ran on its population's node
and GPU. More GPUs per node across nodes, and AMD GPUs, are covered only by the Dragon GPU tests, without
PyTorch. The local pools' variables on AMD GPUs are checked only by unit tests.