Skip to content

fix(mpi): --efa runs the EFA installer's Open MPI under /opt/amazon/openmpi (#1491) - #1506

Merged
scttfrdmn merged 3 commits into
mainfrom
fix/1491-efa-openmpi
Nov 2, 2026
Merged

scttfrdmn merged 3 commits into
mainfrom
fix/1491-efa-openmpi

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #1491

What (owner decision)

With --mpi --efa, rank 0's mpirun is now the EFA installer's Open MPI, /opt/amazon/openmpi/bin/mpirun, which is AWS's documented EFA path. Before this, the distribution's Open MPI was installed first and was first on PATH. Without --efa, nothing changes.

Design (pkg/userdata/mpi.go; rationale is in the Go comment, not the user data)

  • Install: with --efa, the yum/apt-get Open MPI install is skipped. The script prints Using the EFA installer's Open MPI (#1491). The installer installs Open MPI 4.1 at /opt/amazon/openmpi, and by default (since 1.30.0) Open MPI 5 at /opt/amazon/openmpi5. An image that already has a distribution Open MPI keeps it, but out of the script's PATH.

  • Fail closed: after efa_installer.sh, the script requires /opt/amazon/openmpi/bin/mpirun. Without it, it exits 1 and the --mpi on an AL2 --ami dies at the jq hostfile step (jq not installed); no SPAWN_COMPLETE, so the cohort bills until TTL #1483 trap records mpi-bootstrap, rather than PATH falling through to /usr/bin/mpirun on Ubuntu.

  • mpi.sh with --efa:

    Without --efa it is byte-identical to main.

  • Peers / orted: non-interactive ssh reads no profile.d. ompi_info on the installer's build shows --enable-orterun-prefix-by-default ("mpirun default --prefix: yes"), so orted on the peers gets the prefix's PATH and library path. The mpirun line itself is unchanged.

  • Root: --allow-run-as-root stays.

  • cd /tmp became cd /tmp/. They are equivalent; the change lets the sandbox relocate the installer's working directory, so the test never writes to the host's /tmp.

Container check (ubuntu:24.04, EFA installer 1.51.0, -y --skip-kmod --skip-limit-conf --no-verify, as root)

  • openmpi40-aws 4.1.8-1 and openmpi50-aws 5.0.9, libfabric-aws 2.7.0amzn2.0. /opt/amazon/efa/bin has fi_info fi_mon_sampler fi_pingpong fi_strerror.
  • 4.1.8 run as root with this script's --mca orte_base_help_aggregate 0:
    • without the flag: "mpirun has detected an attempt to run as root", rc=1
    • with --allow-run-as-root -np 2: rc=0
    • 5.0.9 with the flag: rc=0
  • With spawn's PATH, command -v mpirun gives /opt/amazon/openmpi/bin/mpirun, both in the shell and inside the ranks.
  • ompi_info: MCA mtl: ofi and MCA btl: ofi, --with-ofi=/opt/amazon/efa/.
  • The installer's zippy_efa.sh (login shells) also prepends /opt/amazon/openmpi/bin, so login shells and the user data now agree.
  • Ubuntu's /etc/sysctl.d/10-ptrace.conf stays at kernel.yama.ptrace_scope = 1; the installer does not change it. AWS says to disable it for libfabric's CMA shared memory. Spawn's ranks run as root, and CAP_SYS_PTRACE bypasses yama scope 1, so this should not bite. It is in the live-check list.

Distros

Gates (pkg/userdata/mpi_efa_openmpi_test.go, whole-script sandbox, rank 0 plus 2 peers running their own scripts)

The sandbox has a marked mpirun stand-in in each place: the distribution's on PATH, and the one the stand-in EFA installer writes to /opt/amazon/openmpi/bin. The test reads which one rank 0 actually ran. /opt/ is added to the sandbox's relocated prefixes.

Every revert below kept go vet clean, and the named gate failed against it:

Gate Revert Failure
TestMPIWithEFARunsTheInstallersOpenMPI (image with distro mpirun; yum, none; apt-get, none) --efa mpi.sh gets the old /usr/lib64/openmpi/bin PATH ran mpirun "distro" / "", want the EFA installer's
same distro install not skipped the distribution's Open MPI was installed: ["yum install -y openmpi openmpi-devel"], and the same for apt-get
TestMPIWithEFAFailsClosedWithoutTheInstallersOpenMPI -x check removed rank 0 exited 0, want 1, mpirun "distro" ran although the EFA installer installed no Open MPI
TestMPIWithoutEFARunsTheDistributionsOpenMPI (an /opt/amazon/openmpi exists on the image) the --efa mpi.sh used always without --efa, rank 0 ran mpirun "efa", mpi.sh names /opt/amazon

Follow-ups filed (no milestone)

Checks

These pass:

  • make check, from /private/tmp.
  • make lint: 0 issues in all 10 modules.
  • semgrep scan --config=auto --error .: rc 0.
  • The rendered-script shellcheck test.

No help text changed, so docs need no regeneration. There were no AWS calls.

Live on c7gn.16xlarge, Ubuntu 24.04: with --efa the Open MPI apt install,
which ran the only apt-get update, is skipped, so the installer ran against
the AMI's stale indexes and failed ('Unable to locate package
environment-modules'); every member then failed closed at enrolment.
AL2023 passed (EFA traffic and /opt/amazon/openmpi mpirun verified).
@scttfrdmn
scttfrdmn force-pushed the fix/1491-efa-openmpi branch from e8ead70 to 65a482b Compare November 2, 2026 20:55
@scttfrdmn

Copy link
Copy Markdown
Contributor Author

Live test on EFA hardware (c7gn.16xlarge Spot, us-east-1a, CLI built from 060fdf6c)

AL2023: PASS

  • Nodes: 2-node --mpi --efa (i-011558b555c69667b, i-09239f110c62e9df1), in placement group spawn-mpi-liveefa-al-us-east-1a.
  • EFA: fi_info -p efa -t FI_EP_RDM shows provider: efa / fabric: efa-direct. The installer's own fi_pingpong printed SUCCESS.
  • Which Open MPI: mpi.sh resolves mpirun to /opt/amazon/openmpi/bin/mpirun, Open MPI 4.1.8, and the ranks used the same one. The distro packages openmpi and openmpi-devel are not installed.
  • Completion: SPAWN_COMPLETE was completed/mpi, exit 0, on both nodes.
  • Inter-node traffic: fi_pingpong -e rdm -p efa measured 8.22 µs/xfer at 8 B over 10k transfers. rdmap0s31 tx_pkts went from 126 to 10996, so the traffic crossed the EFA device.

Ubuntu 24.04 arm64: FAIL, regression found and fixed in e8ead702

  • Symptom: both cohorts died with PhaseBudgetExceeded at enrollment.
  • Reproduction: on a single node, efa_installer.sh -y -g failed with E: Unable to locate package environment-modules. With --efa, this PR skips the apt Open MPI install, and that install held the only apt-get update, so the installer saw the AMI's stale indexes. After a manual apt-get update the installer succeeded.
  • Fix: apt-get update now runs before the installer on apt-get systems, with the same 10-try bound as the Open MPI install. It is recorded as mpi-bootstrap if it gives up.
  • Tests:
    • The stand-in installer now fails as the real one does when indexes are stale.
    • New tests: TestMPIWithEFARefreshesAptIndexes (a busy lock is retried) and TestMPIWithEFAAptGivesUpAndFailsClosed.
    • Revert gate: removing the fix fails both new tests and the existing apt-get, no mpirun subtest.

Rebased on main (65a482be) after #1503. The Ubuntu re-run is going on #1508's branch, which carries this fix and is the final code for both PRs.

Teardown

All 7 instances are terminated. The placement group and 3 SGs are deleted, the Spot request is cancelled, and no EIPs were used. I checked the leak diff independently. Cost was about $0.80.

Separate bug found during the run: #1509 (--keep-on-error is ignored for failed --mpi cohorts).

@codecov

codecov Bot commented Nov 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 5177096 into main Nov 2, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1491-efa-openmpi branch November 2, 2026 21:21
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.

--mpi --efa runs the distribution's Open MPI, not the EFA installer's /opt/amazon/openmpi

1 participant