mache.parallel.placement.ResourcePlacement

class mache.parallel.placement.ResourcePlacement(nodes: Sequence[str], cores: Sequence[Sequence[int]], gpus: int = 0, gpu_ids: Sequence[int] | None = None)[source]

Where a single parallel launch should run.

A placement says which nodes a launch may use, which cores it may use on each of them, and how many GPUs it needs in total. It is machine independent: each ParallelSystem renders it into whatever its launcher needs.

Variables:
  • nodes (tuple of str) – The hostnames the launch may run on. An empty tuple leaves the choice of nodes to the scheduler, which is only useful when nothing else is running concurrently.

  • cores (tuple of tuple of int) –

    The cores the launch may use, one set per entry in nodes, in the order they should be handed out to the tasks that land on that node. These are node-local core numbers, so two nodes may perfectly well both offer core 0, and each set is an explicit set rather than a count because the usable cores on a node may not be contiguous and may not start at zero.

    Where nodes is empty there is exactly one set, holding the cores for the whole launch, since there is no node to divide them between.

    Whether the exact sets are honored depends on the machine: launchers that bind explicitly use them as given, while a scheduler that reserves resources uses only how many cores there are and picks which ones itself.

  • gpus (int) – The number of GPUs the launch needs in total, not per task. A per-task count does not confine a launch on the GPU machines mache supports, whereas a total does. The default of 0 is rendered as an explicit request for no GPUs, since a launch that says nothing about GPUs is read as claiming every one on the node.

  • gpu_ids (tuple of int or None) – Which of the node’s GPUs to use, as indices from 0 to gpus_per_node - 1. This is needed only where the batch system does not assign GPUs itself and mache has to name them, which is the case on PBS with PALS. Only the caller knows about every concurrent launch, so only the caller can assign disjoint GPUs; mache renders what it is given and never guesses. None where the scheduler assigns GPUs from gpus.

__init__(nodes: Sequence[str], cores: Sequence[Sequence[int]], gpus: int = 0, gpu_ids: Sequence[int] | None = None) → None

Methods

__init__(nodes, cores[, gpus, gpu_ids])

Attributes

gpu_ids

gpus

total_cores

How many cores this placement gives the launch, over all nodes.

nodes

cores