diff --git a/tests/jax/distributed_test_base.py b/tests/jax/distributed_test_base.py index 5e05947399..c65ffbf62b 100644 --- a/tests/jax/distributed_test_base.py +++ b/tests/jax/distributed_test_base.py @@ -168,13 +168,16 @@ def count_collectives(splitted_hlo): is_sync_collective = "collective_backend_config" in line and sync_symb in line if is_async_start or is_sync_collective: - if is_sync_collective: - is_all_reduce = re.search(r"\ball-reduce\s*\(", line) - is_all_gather = re.search(r"\ball-gather\s*\(", line) - else: + # Some direct *-start instructions are tagged with + # `"is_sync":true`. Classify the explicit async form first so + # it is not mistaken for an unsuffixed synchronous collective. + if is_async_start: called_collective = get_called_collective_type(line) is_all_reduce = COLL_AR_KEY in txt[0] or called_collective == COLL_AR_KEY is_all_gather = COLL_AG_KEY in txt[0] or called_collective == COLL_AG_KEY + else: + is_all_reduce = re.search(r"\ball-reduce\s*\(", line) + is_all_gather = re.search(r"\ball-gather\s*\(", line) if is_all_reduce: result[COLL_AR_KEY] += count_bytes(txt)