<@U06RKAMK0UC> what is the default Parallelism for...
# ask-ai
w
@ancient-wolf-19325 what is the default Parallelism for map_tasks in Flyte v1?
a
In Flyte v1, the default parallelism for map_tasks (array tasks) is "unbounded," meaning all subtasks are executed in parallel unless the user explicitly sets the concurrency/parallelism parameter. This behavior is confirmed in the documentation and issues, which state that if concurrency is not specified, all mapped tasks will run simultaneously, potentially leading to resource contention if the input list is large. Users can limit parallelism by setting the concurrency argument in the map_task definition; otherwise, the system defaults to running all subtasks in parallel (map_tasks.md, Flyte Issue #3924, Flyte Issue #1230). Would you like more detail on how to configure or override this behavior? Sources: - map_tasks.md - Flyte Issue #3924 - Flyte Issue #1230 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
a
can you provide example code for above @ancient-wolf-19325
a
Certainly! Here is an example of a Flyte v1 map_task with default (unbounded) parallelism, and how to set the concurrency parameter to limit parallelism. By default, all subtasks run in parallel; to restrict, set concurrency in map_task:
Copy code
from flytekit import task, workflow, map_task

@task
def increment(x: int) -> int:
    return x + 1

@workflow
def default_parallelism_wf(data: list[int]) -> list[int]:
    # All subtasks run in parallel (default behavior)
    return map_task(increment)(x=data)

@workflow
def limited_parallelism_wf(data: list[int]) -> list[int]:
    # Only 2 subtasks run in parallel at a time
    return map_task(increment, concurrency=2)(x=data)
According to map_tasks.md, the concurrency argument controls the number of parallel executions; if omitted, all run in parallel. Would you like a more detailed explanation of how this works? Sources: - map_tasks.md 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.