|
25 | 25 | from MaxText import max_utils |
26 | 26 | from MaxText import maxtext_utils |
27 | 27 | from MaxText import pyconfig |
| 28 | +from MaxText.gcloud_stub import is_decoupled |
| 29 | +from maxtext.tests.test_utils import get_test_config_path |
28 | 30 | from MaxText.common_types import AttentionType, DECODING_ACTIVE_SEQUENCE_INDICATOR, EP_AS_CONTEXT, MODEL_MODE_PREFILL, MODEL_MODE_TRAIN, ShardMode |
29 | 31 | from MaxText.globals import MAXTEXT_PKG_DIR |
30 | 32 | from MaxText.layers.attention_mla import MLA |
@@ -52,10 +54,23 @@ class MLATestBase(parameterized.TestCase): |
52 | 54 | def setUp(self): |
53 | 55 | """Initializes the configuration for each test""" |
54 | 56 | 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 | + |
56 | 71 | 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, |
59 | 74 | ) |
60 | 75 | self.cfg = config |
61 | 76 | self.rng = jax.random.PRNGKey(0) |
|
0 commit comments