Skip to content

Commit c7a185a

Browse files
erwinzhang7zcbenz
andauthored
chore: Check malformed jaccl hostfile that miss rdma in pairs (#4284)
Co-authored-by: Cheng <git@zcbenz.com>
1 parent 1038679 commit c7a185a

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

python/mlx/_distributed_utils/launch.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,31 @@ def launch_jaccl(parser, hosts, args, command):
376376

377377
jaccl_ring = args.backend == "jaccl-ring"
378378
have_rdmas = all(len(h.rdma) == len(hosts) for h in hosts)
379+
if not have_rdmas:
380+
parser.error(
381+
"The hostfile is malformed: number of RDMA devices does not match hosts"
382+
)
379383
have_nulls = all(h.rdma[i] is None for i, h in enumerate(hosts))
380-
if not have_rdmas or not have_nulls:
381-
parser.error("Malformed hostfile for jaccl backend")
384+
if not have_nulls:
385+
parser.error("The hostfile is malformed: RDMA device of self should be null")
386+
387+
# Find pairs that miss rmda in hostfile.
388+
n = len(hosts)
389+
missing_rdma = [
390+
(i, j)
391+
for i, h in enumerate(hosts)
392+
for j in (((i - 1) % n, (i + 1) % n) if jaccl_ring else range(n))
393+
if i != j and h.rdma[j] is None
394+
]
395+
396+
if missing_rdma:
397+
pairs = ", ".join(
398+
f"{hosts[i].ssh_hostname} to {hosts[j].ssh_hostname}"
399+
for i, j in missing_rdma[:3]
400+
)
401+
if len(missing_rdma) > 3:
402+
pairs += f" and {len(missing_rdma) - 3} more"
403+
parser.error(f"The hostfile is malformed: no RDMA device is listed for {pairs}")
382404

383405
coordinator = hosts[0].ips[0]
384406
env = args.env

0 commit comments

Comments
 (0)