Skip to content

fix(train): pass the total rank count to mpirun -np in the MPI driver - #6440

Open
AkshayShah03 wants to merge 1 commit into
aws:masterfrom
AkshayShah03:fix/mpi-driver-total-processes
Open

AkshayShah03 wants to merge 1 commit into
aws:masterfrom
AkshayShah03:fix/mpi-driver-total-processes

Conversation

@AkshayShah03

Copy link
Copy Markdown

Issue #, if available: N/A

Description of changes:

mpi_driver.main() passes the per-host process count as num_processes, and get_mpirun_command emits it as mpirun -np. -np is the total number of ranks, and the hosts are listed with per-host slots:

mpirun --host algo-1:8,algo-2:8 -np 8 ...

Open MPI fills slots in order, so a 2-node job with process_count_per_node=8 runs all 8 ranks on algo-1 and none on algo-2. With one process per node, only one rank runs in total. The sagemaker-training-toolkit this logic follows uses processes_per_host * len(hosts) (MasterRunner in mpi.py).

This change passes process_count * host_count, in both the sagemaker-train and the sagemaker-core copies of the driver. The remote-function mpirun script in remote_function/job.py has the same pattern but predates v3, so I left it out of this PR.

Testing:

  • test_mpi_driver_master now asserts host_list == ["algo-1:2", "algo-2:2"] and num_processes == 4. It fails before this change with num_processes == 2.
  • container_drivers tests: 32 passed (train) and 78 passed (core).
  • I couldn't run a real mpirun locally; the fix follows Open MPI's -np semantics and the toolkit's behaviour.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

mpi_driver.main() passed the per-host process count as num_processes, which
get_mpirun_command emits as 'mpirun -np'. -np is the total number of ranks,
and the hosts are listed with per-host slots (algo-1:8,algo-2:8), so Open
MPI placed all ranks on the first host: a 2-node job with
process_count_per_node=8 ran 8 ranks on algo-1 and none on algo-2, and with
one process per node only a single rank ran in total. The
sagemaker-training-toolkit this logic follows uses
processes_per_host * len(hosts).

Pass process_count * host_count, in the sagemaker-train and sagemaker-core
copies of the driver.

This branch is waiting to be deployed

1 waiting deployment
manual-approval — 0b41d197 Waiting Oct 12, 2026 by AkshayShah03 via wait-for-approval #624
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant