ray.tune.schedulers.resource_changing_scheduler.DistributeResources#

class ray.tune.schedulers.resource_changing_scheduler.DistributeResources(add_bundles: bool = False, increase_by: Dict[str, float] | None = None, increase_by_times: int = -1, reserve_resources: Dict[str, float] | None = None)[source]#

This class creates a basic uniform resource allocation function.

The function naively balances free resources (CPUs and GPUs) between trials, giving them all equal priority, ensuring that all resources are always being used. The free resources will be placed in new bundles. The function assumes that all bundles are equal (there is no “head” bundle).

If for some reason a trial ends up with more resources than there are free ones, it will adjust downwards. It will also ensure that trial as at least as many resources as it started with (base_trial_resource).

The function returns a new PlacementGroupFactory with updated resource requirements, or None. If the returned PlacementGroupFactory is equal by value to the one the trial has currently, the scheduler will skip the update process internally (same with None).

If you wish to implement your own resource distribution logic, you can do so by extending this class, as it provides several generic methods. You can also implement a function instead.

Parameters:
  • add_bundles – If True, create new bundles from free resources. Otherwise, spread them among base_trial_resource bundles.

  • increase_by – A dict with key-value pairs representing an atomic unit of resources (name-amount) the trial will be increased by. If not set, the trial will increase by 1 CPU/GPU.

  • increase_by_times – If set to >=1 and increase_by is set, the trial will increase by maximum of increase_by_times * increase_by resources. If set to <1, no upper limit is set. Ignored if increase_by is not set.

  • reserve_resources – A dict of resource_name-amount pairs representing the resources that will not be allocated to resized trials.

PublicAPI (beta): This API is in beta and may change before becoming stable.

Methods