Skip to content

Commit 72366cd

Browse files
committed
resolve comments
1 parent 75f532b commit 72366cd

2 files changed

Lines changed: 19 additions & 17 deletions

File tree

src/maxtext/common/goodput.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -135,21 +135,22 @@ def create_goodput_recorder(config):
135135
if config.enable_goodput_recording and jax.process_index() == 0:
136136
max_logging.log("[GOODPUT NO-OP] recorder skipped (decoupled stub).")
137137
return None
138-
if config.enable_goodput_recording:
139-
logger_name = f"goodput_{config.run_name}"
140138

141-
# Detect if we should use the elastic-aware recorder
142-
recorder = None
143-
if config.elastic_enabled:
144-
try:
145-
from ml_goodput_measurement import goodput_elastic
146-
from maxtext.utils import elastic_utils
147-
recorder = goodput_elastic.ElasticGoodputRecorder(config.run_name, logger_name, jax.process_index() == 0)
148-
elastic_utils.record_slice_state(recorder)
149-
except ImportError:
150-
pass
151-
152-
if recorder is None:
153-
recorder = goodput.GoodputRecorder(config.run_name, logger_name, jax.process_index() == 0)
154-
return recorder
155-
return None
139+
if not config.enable_goodput_recording:
140+
return None
141+
142+
logger_name = f"goodput_{config.run_name}"
143+
144+
# Detect if we should use the elastic-aware recorder
145+
if config.elastic_enabled:
146+
try:
147+
from ml_goodput_measurement import goodput_elastic
148+
from maxtext.utils import elastic_utils
149+
recorder = goodput_elastic.ElasticGoodputRecorder(config.run_name, logger_name, jax.process_index() == 0)
150+
elastic_utils.record_slice_state(recorder)
151+
except ImportError as e:
152+
max_logging.log(f"Could not create elastic goodput recorder: {e}")
153+
else:
154+
return recorder
155+
156+
return goodput.GoodputRecorder(config.run_name, logger_name, jax.process_index() == 0)

tests/unit/elastic_utils_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def setUp(self):
7272
self.fake_pathwaysutils.is_pathways_backend_used.return_value = True
7373
self.fake_pathwaysutils.elastic = Mock()
7474
self.fake_pathwaysutils.elastic.get_active_slice_indices.return_value = [0, 1]
75+
self.fake_pathwaysutils.elastic.get_slice_to_devices.return_value = {0: [FakeDevice()], 1: [FakeDevice()]}
7576
self.fake_jax.process_index.return_value = 0
7677

7778
# Inject fakes into elastic_utils namespace

0 commit comments

Comments
 (0)