Skip to content

Refactor TPU Observability DAGs to Remove Dynamic Task Mapping - #264

Open
yuna-tzeng wants to merge 5 commits into
devfrom
tpu-obs/user/yuna/remove_expand
Open

Refactor TPU Observability DAGs to Remove Dynamic Task Mapping#264
yuna-tzeng wants to merge 5 commits into
devfrom
tpu-obs/user/yuna/remove_expand

Conversation

@yuna-tzeng

Copy link
Copy Markdown

Description

This PR refactors the TPU observability DAGs to remove Airflow dynamic task mapping (the .expand() pattern). Instead, validations and operations across multiple pods are now executed sequentially inside a single Airflow task. This change simplifies the DAG structure, improves task-level logging, and streamlines error handling.

Removal of Dynamic Task Mapping (.expand())

Converted tasks that previously targeted a single pod using dynamic task mapping to accept a list of pod names (list[str]) and process them sequentially.
Removed complex nested TaskGroup structures and the usage of .zip() and chain(), resulting in cleaner and more maintainable DAG graphs.
Removed the @task decorator from parsing and helper validation functions (such as parse_tpu_info_output, validate_chips_table, validate_runtime_table, validate_tensorcore_table, and validate_latency_table), converting them back to standard Python functions to reduce Airflow task instantiation overhead.

Modified Files & Implementation Details

  1. dags/tpu_observability/jobset_ttr_kill_process.py

    • Refactored kill_tpu_pod_workload to kill_tpu_pod_workloads, taking pod_names: list[str].
    • Replaced .partial(...).expand(pod_name=startup.running_pods) in the DAG definition with a direct single-task invocation passing the list of running pods.
  2. dags/tpu_observability/tpu_info_format_validation_dags.py

    • Removed @task decorators from validate_chips_table, validate_runtime_table, validate_tensorcore_table, and validate_latency_table.
    • Introduced a new validate_tpu_info_format task to coordinate the tpu-info execution, parsing, and format checks for all pods.
    • Removed the verification_group TaskGroup and its dynamic mapping steps, replacing them with a single task.
  3. dags/tpu_observability/tpu_info_metrics_dag.py

    • Removed get_tpu_info_metric_from_pod and run_metric_verification tasks.
    • Created a new verify_metric_for_all_pods task to sequentially execute tpu-info --metric, parse outputs, query Cloud Monitoring, and run validation strategies for all pods.
    • Removed the TaskGroup and .zip mapping from the main DAG workflow.
  4. dags/tpu_observability/tpu_sdk_monitoring_validation_dag.py

    • Refactored validate_monitoring_sdk to accept pod_names: list[str].
    • Removed .expand(pod_name=startup.running_pods).
    • Added sequential pod validation loop and error aggregation logic.
  5. dags/tpu_observability/utils/tpu_info_util.py

    • Removed @task decorator from parse_tpu_info_output to keep it a standard utility function.

Checklist

Before submitting this PR, please make sure (put X in square brackets):

  • I have performed a self-review of my code.
  • I have necessary comments in my code, particularly in hard-to-understand areas.
  • I have run one-shot tests and provided workload links above if applicable.
  • I have made or will make corresponding changes to the doc if needed.

alfredyu-cienet and others added 5 commits May 26, 2026 15:41
…lity to standard Python functions to remove .expand() implement

- Remove `@task` decorators from internal validation helper functions (`verify_table_amount`, `validate_chips_table`, etc.) in `tpu_info_format_validation_dags.py`.
- Remove `@task` decorator from `parse_tpu_info_output` in `tpu_info_util.py` since it is only executed as an inline utility in active DAGs.
- Refactor verification execution logic in `tpu_info_metrics_dag.py` and `tpu_sdk_monitoring_validation_dag.py` to process pods sequentially within a single task, removing complex dynamic task mapping (`expand` / `partial`) to avoid quota issues and scheduler overhead.
@alfredyu-cienet

Copy link
Copy Markdown
Collaborator

FYI, Kim's change has been merged, so let's rebase this PR and resolve conflicts

@alfredyu-cienet alfredyu-cienet left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can apply TaskGroupWithTimeout for those DAGs in this PR as well?

create_node_pool,
*startup.tasks,
all_verification_groups,
all_verification_tasks,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
all_verification_tasks,
*all_verification_tasks,

@alfredyu-cienet
alfredyu-cienet force-pushed the dev branch 5 times, most recently from 7aeded5 to d43f051 Compare July 8, 2026 07:19
@alfredyu-cienet
alfredyu-cienet force-pushed the dev branch 2 times, most recently from a577785 to 71b8d8a Compare July 14, 2026 03:12
@alfredyu-cienet
alfredyu-cienet force-pushed the dev branch 4 times, most recently from b588728 to 0e938b1 Compare July 23, 2026 01:43
@alfredyu-cienet
alfredyu-cienet force-pushed the dev branch 2 times, most recently from 54f9a78 to 8e4ea82 Compare July 27, 2026 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants