跳到内容

StepResources

StepResources

基类: RuntimeParametersMixin, BaseModel

一个用于定义分配给 _Step 的资源的类。

属性

名称 类型 描述
replicas RuntimeParameter[PositiveInt]

步骤的副本数。

cpus Optional[RuntimeParameter[PositiveInt]]

分配给每个步骤副本的 CPU 数量。

gpus Optional[RuntimeParameter[PositiveInt]]

分配给每个步骤副本的 GPU 数量。

memory Optional[RuntimeParameter[PositiveInt]]

每个步骤副本所需的内存大小(字节)。

resources Optional[RuntimeParameter[Dict[str, int]]]

一个字典,包含每个步骤副本所需的自定义资源数量。

源代码位于 src/distilabel/steps/base.py
class StepResources(RuntimeParametersMixin, BaseModel):
    """A class to define the resources assigned to a `_Step`.

    Attributes:
        replicas: The number of replicas for the step.
        cpus: The number of CPUs assigned to each step replica.
        gpus: The number of GPUs assigned to each step replica.
        memory: The memory in bytes required for each step replica.
        resources: A dictionary containing the number of custom resources required for
            each step replica.
    """

    replicas: RuntimeParameter[PositiveInt] = Field(
        default=1, description="The number of replicas for the step."
    )
    cpus: Optional[RuntimeParameter[PositiveInt]] = Field(
        default=None, description="The number of CPUs assigned to each step replica."
    )
    gpus: Optional[RuntimeParameter[PositiveInt]] = Field(
        default=None, description="The number of GPUs assigned to each step replica."
    )
    memory: Optional[RuntimeParameter[PositiveInt]] = Field(
        default=None, description="The memory in bytes required for each step replica."
    )
    resources: Optional[RuntimeParameter[Dict[str, int]]] = Field(
        default=None,
        description="A dictionary containing names of custom resources and the"
        " number of those resources required for each step replica.",
    )