Skip to content

Automatically detect when IS_FANOUT_STAGE should be set to True #1613

Description

@sarahyurick

Whenever a stage does def process(self, task: Task) -> list[Task], it is considered a fanout stage. We should add logic to the base ProcessingStage to automatically do this, instead of the child stages having to do it every time.

For example, in https://github.com/NVIDIA-NeMo/Curator/blob/main/nemo_curator/stages/text/download/base/url_generation.py we explicitly do:

def ray_stage_spec(self) -> dict[str, Any]:
    return {
        "is_fanout_stage": True,
    }

but since def process(self, task: _EmptyTask) -> list[FileGroupTask] is returning a list, the base ProcessingStage should just have some extra logic to automatically do it instead. That way, we can remove it from our existing stages like URLGenerationStage, and contributors do not need to remember to explicitly set it when creating new stages.

This could be done with get_type_hints or something similar.

We should make sure we are handling cases like def process(self, task: Task) -> Task | list[Task], etc. appropriately too. When we do IS_FANOUT_STAGE, there is a perf cost to it. Under the hood it runs StreamingRepartition which is an expensive operation at scale.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions