|
88 | 88 | ] |
89 | 89 |
|
90 | 90 |
|
91 | | -@task |
92 | | -def check_workload_goodput( |
93 | | - workload_id: str, |
94 | | - project_id: str, |
95 | | -) -> bool: |
96 | | - """ |
97 | | - Query and log Goodput/Badput metrics for the MaxText XPK workload. |
98 | | - """ |
99 | | - goodput_logger_name = f"goodput_{workload_id}" |
100 | | - os.environ["GOOGLE_CLOUD_PROJECT"] = project_id |
101 | | - goodput_calculator = goodput.GoodputCalculator( |
102 | | - job_name=workload_id, |
103 | | - logger_name=goodput_logger_name, |
104 | | - using_pathways=True, |
105 | | - ) |
106 | | - ( |
107 | | - current_goodput, |
108 | | - badput_breakdown, |
109 | | - last_step, |
110 | | - ) = goodput_calculator.get_job_goodput(include_badput_breakdown=True) |
111 | | - wasted_progress = badput_breakdown[ |
112 | | - goodput.BadputType.WASTED_PROGRESS_FROM_DISRUPTION |
113 | | - ] |
114 | | - checkpoint_save = badput_breakdown[ |
115 | | - goodput.BadputType.UNPRODUCTIVE_CHECKPOINT_SAVE_TIME |
116 | | - ] |
117 | | - checkpoint_restore = badput_breakdown[ |
118 | | - goodput.BadputType.UNPRODUCTIVE_CHECKPOINT_RESTORE_TIME |
119 | | - ] |
120 | | - other_badput = badput_breakdown[goodput.BadputType.OTHER] |
121 | | - |
122 | | - logging.info(f"Last step recorded: {last_step}") |
123 | | - logging.info(f"Goodput (%): {current_goodput:.2f}%") |
124 | | - logging.info( |
125 | | - "Badput due to TPU initialization (%): " |
126 | | - f"{badput_breakdown[goodput.BadputType.TPU_INITIALIZATION]:.2f}%" |
127 | | - ) |
128 | | - logging.info( |
129 | | - "Badput due to training preparation: " |
130 | | - f"{badput_breakdown[goodput.BadputType.TRAINING_PREP]:.2f}%" |
131 | | - ) |
132 | | - logging.info( |
133 | | - "Badput due to program startup: " |
134 | | - f"{badput_breakdown[goodput.BadputType.PROGRAM_STARTUP]:.2f}%" |
135 | | - ) |
136 | | - logging.info( |
137 | | - "Badput due to data loading: " |
138 | | - f"{badput_breakdown[goodput.BadputType.DATA_LOADING_SYNC]:.2f}%" |
139 | | - ) |
140 | | - logging.info( |
141 | | - f"Badput due to disruption and wasted progress: {wasted_progress:.2f}%" |
142 | | - ) |
143 | | - logging.info(f"Badput due to checkpoint save: {checkpoint_save:.2f}%") |
144 | | - logging.info(f"Badput due to checkpoint restore: {checkpoint_restore:.2f}%") |
145 | | - logging.info(f"Badput due to Unknown/Other: {other_badput:.2f}%") |
146 | | - |
147 | | - |
148 | 91 | @task.sensor(poke_interval=10, timeout=3600, mode="reschedule") |
149 | 92 | def check_goodput_logname( |
150 | 93 | project_id: str, |
@@ -189,6 +132,43 @@ def check_goodput_logname( |
189 | 132 | return True |
190 | 133 |
|
191 | 134 |
|
| 135 | +@task |
| 136 | +def check_workload_goodput( |
| 137 | + workload_id: str, |
| 138 | + project_id: str, |
| 139 | +) -> bool: |
| 140 | + """ |
| 141 | + Query and log Goodput/Badput metrics for the MaxText XPK workload. |
| 142 | + """ |
| 143 | + goodput_logger_name = f"goodput_{workload_id}" |
| 144 | + os.environ["GOOGLE_CLOUD_PROJECT"] = project_id |
| 145 | + goodput_calculator = goodput.GoodputCalculator( |
| 146 | + job_name=workload_id, |
| 147 | + logger_name=goodput_logger_name, |
| 148 | + using_pathways=True, |
| 149 | + ) |
| 150 | + ( |
| 151 | + current_goodput, |
| 152 | + badput_breakdown, |
| 153 | + last_step, |
| 154 | + ) = goodput_calculator.get_job_goodput(include_badput_breakdown=True) |
| 155 | + |
| 156 | + logging.info(f"Last step recorded: {last_step}") |
| 157 | + logging.info(f"Goodput (%): {current_goodput:.2f}%") |
| 158 | + logging.info("\n--- Badput Breakdown ---") |
| 159 | + |
| 160 | + for badput_type, percentage in badput_breakdown.items(): |
| 161 | + if badput_type == goodput.BadputType.CUSTOM_BADPUT_EVENTS: |
| 162 | + logging.info(f"Badput due to {badput_type}:") |
| 163 | + custom_events = percentage |
| 164 | + if isinstance(custom_events, dict): |
| 165 | + for event_name, event_percentage in custom_events.items(): |
| 166 | + logging.info(f" - {event_name}: {event_percentage:.2f}%") |
| 167 | + else: |
| 168 | + # Access the name attribute of the enum member |
| 169 | + logging.info(f"Badput due to {badput_type.name}: {percentage:.2f}%") |
| 170 | + |
| 171 | + |
192 | 172 | @task |
193 | 173 | def generate_commands( |
194 | 174 | dag_params: dict, derived_params: dict, recipe_instance: recipe_cfg.Recipe |
|
0 commit comments