|
23 | 23 | import jax |
24 | 24 | from enum import Enum |
25 | 25 | from maxtext.utils import max_logging |
| 26 | +from maxtext.utils import pathwaysutils |
26 | 27 | from maxtext.common.gcloud_stub import goodput_modules |
27 | 28 |
|
28 | 29 | goodput, monitoring, _GOODPUT_STUB = goodput_modules() |
@@ -66,31 +67,30 @@ def maybe_monitor_goodput(config): |
66 | 67 | enable_gcp_goodput_metrics=config.enable_gcp_goodput_metrics, |
67 | 68 | enable_gcp_step_deviation_metrics=config.enable_gcp_step_deviation_metrics, |
68 | 69 | ) |
69 | | - use_elastic = False |
70 | | - if getattr(config, "elastic_enabled", False): |
| 70 | + monitor_class = monitoring.GoodputMonitor |
| 71 | + use_elastic = getattr(config, 'elastic_enabled', False) and pathwaysutils.is_pathways_backend_used() |
| 72 | + if use_elastic: |
71 | 73 | try: |
72 | | - import pathwaysutils |
73 | | - use_elastic = pathwaysutils.is_pathways_backend_used() |
| 74 | + from ml_goodput_measurement import monitoring_elastic |
| 75 | + monitor_class = monitoring_elastic.ElasticGoodputMonitor |
74 | 76 | except ImportError: |
75 | 77 | pass |
76 | 78 |
|
77 | | - if use_elastic and hasattr(monitoring, "ElasticGoodputMonitor"): |
78 | | - monitor_class = monitoring.ElasticGoodputMonitor |
79 | | - else: |
80 | | - monitor_class = monitoring.GoodputMonitor |
81 | | - |
82 | | - goodput_monitor = monitor_class( |
| 79 | + kwargs = dict( |
83 | 80 | job_name=config.run_name, |
84 | 81 | logger_name=f"goodput_{config.run_name}", |
85 | 82 | tensorboard_dir=config.tensorboard_dir, |
86 | 83 | upload_interval=config.goodput_upload_interval_seconds, |
87 | 84 | monitoring_enabled=True, |
88 | | - pathway_enabled=config.enable_pathways_goodput, |
89 | 85 | include_badput_breakdown=True, |
90 | 86 | include_step_deviation=config.monitor_step_time_deviation, |
91 | 87 | step_deviation_interval_seconds=config.step_deviation_interval_seconds, |
92 | 88 | gcp_options=gcp_options, |
93 | 89 | ) |
| 90 | + if monitor_class == monitoring.GoodputMonitor: |
| 91 | + kwargs["pathway_enabled"] = config.enable_pathways_goodput |
| 92 | + |
| 93 | + goodput_monitor = monitor_class(**kwargs) |
94 | 94 | goodput_monitor.start_goodput_uploader() |
95 | 95 | max_logging.log("Started Goodput upload to Tensorboard & GCM in the background!") |
96 | 96 | yield |
@@ -138,16 +138,16 @@ def create_goodput_recorder(config): |
138 | 138 | logger_name = f"goodput_{config.run_name}" |
139 | 139 |
|
140 | 140 | # Detect if we should use the elastic-aware recorder |
141 | | - use_elastic = False |
142 | | - if getattr(config, "elastic_enabled", False): |
| 141 | + use_elastic = getattr(config, 'elastic_enabled', False) and pathwaysutils.is_pathways_backend_used() |
| 142 | + recorder = None |
| 143 | + if use_elastic: |
143 | 144 | try: |
144 | | - import pathwaysutils |
145 | | - use_elastic = pathwaysutils.is_pathways_backend_used() |
| 145 | + from ml_goodput_measurement import goodput_elastic |
| 146 | + recorder = goodput_elastic.ElasticGoodputRecorder(config.run_name, logger_name, jax.process_index() == 0) |
146 | 147 | except ImportError: |
147 | 148 | pass |
148 | | - if use_elastic and hasattr(goodput, "ElasticGoodputRecorder"): |
149 | | - recorder = goodput.ElasticGoodputRecorder(config.run_name, logger_name, jax.process_index() == 0) |
150 | | - else: |
| 149 | + |
| 150 | + if recorder is None: |
151 | 151 | recorder = goodput.GoodputRecorder(config.run_name, logger_name, jax.process_index() == 0) |
152 | 152 | return recorder |
153 | 153 | return None |
0 commit comments