Skip to content

Commit 33545e6

Browse files
make jax_remove_size_one_mesh_axis_from_type param setting in try block, todo: remove this after updating jax. Configure ICI data parallelism for decoupled mode
1 parent c9cd347 commit 33545e6

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

tests/attention_test_util.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
from MaxText import max_utils
2626
from MaxText import maxtext_utils
2727
from MaxText import pyconfig
28+
from MaxText.gcloud_stub import is_decoupled
29+
from maxtext.tests.test_utils import get_test_config_path
2830
from MaxText.common_types import AttentionType, DECODING_ACTIVE_SEQUENCE_INDICATOR, EP_AS_CONTEXT, MODEL_MODE_PREFILL, MODEL_MODE_TRAIN, ShardMode
2931
from MaxText.globals import MAXTEXT_PKG_DIR
3032
from MaxText.layers.attention_mla import MLA
@@ -52,10 +54,23 @@ class MLATestBase(parameterized.TestCase):
5254
def setUp(self):
5355
"""Initializes the configuration for each test"""
5456
super().setUp()
55-
jax.config.update("jax_remove_size_one_mesh_axis_from_type", True)
57+
config_args = dict(self.config_arguments)
58+
if is_decoupled(): # TODO(gulsumgudukbay): remove this after jax is updated.
59+
# Older/newer JAX versions may not recognize this flag; ignore if absent.
60+
try:
61+
jax.config.update("jax_remove_size_one_mesh_axis_from_type", True)
62+
except AttributeError:
63+
pass
64+
# In decoupled mode, adapt mesh/ICI parallelism to local devices so
65+
# fill_unspecified_mesh_axes matches the available device count.
66+
config_args.setdefault("mesh_axes", ["data"])
67+
config_args.setdefault("ici_data_parallelism", -1)
68+
else:
69+
jax.config.update("jax_remove_size_one_mesh_axis_from_type", True)
70+
5671
config = pyconfig.initialize(
57-
[sys.argv[0], os.path.join(MAXTEXT_PKG_DIR, "configs", "base.yml")],
58-
**self.config_arguments,
72+
[sys.argv[0], get_test_config_path()],
73+
**config_args,
5974
)
6075
self.cfg = config
6176
self.rng = jax.random.PRNGKey(0)

0 commit comments

Comments
 (0)