Skip to content

[ROCm] Add MoRI to the ROCm CI images - #206534

Closed
pablo-garay wants to merge 5 commits into
pytorch:mainfrom
ROCm:jeffdaily/rocm-ci-mori
Closed

pablo-garay wants to merge 5 commits into
pytorch:mainfrom
ROCm:jeffdaily/rocm-ci-mori

Conversation

@pablo-garay

@pablo-garay pablo-garay commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Linked issue or supporting maintainer

Supported by @jeffdaily

BC-breaking?

No

Summary (human written only)

The TokenSwitchMoRI tests from #201225 skip in CI because no CI image has MoRI. This adds MoRI to the ROCm CI images that run on MI300 and MI350. Single-node only; there are no multi-node ROCm CI runners yet.

Agent details (if applicable)

My agent came up with this analysis, but I've read and approved it.

install_rocm_mori.sh builds MoRI from source, pinned in ci_commit_pins/rocm-mori.txt to v1.2.5, since the amd_mori wheels on PyPI are cp310/cp312 only and the images use Python 3.11. It fetches only the two submodules the build uses and installs only the build requirements missing from requirements-ci.txt (MoRI's requirements-build.txt would also add a pytest plugin). The build needs no GPU and no torch: MoRI JIT-compiles its kernels on first use, so the background precompile and the optional torch extension are off. No NIC provider (USE_IONIC/USE_BNXT) is built.

It does not install flydsl: MoRI's flydsl EP backend uses the flydsl 0.3.4.1 that .ci/pytorch/test.sh already installs on the ROCm multi-GPU distributed shards, where the MoRI tests run, so other jobs see no new flydsl. The 4-GPU MI350 shard does not install flydsl, so the MoRI tests still skip there.

It runs for pytorch-linux-noble-rocm-n-py3.11 and pytorch-linux-noble-rocm-preview-py3.11. The jammy images run distributed tests only on MI210 and RX7900, which MoRI does not support.

Test plan, on an MI355X host with TheRock ROCm 10.1 wheels: the script's steps in a fresh Python 3.11 venv without torch, as at docker build time, build in about 20 s and import mori.cco.cco succeeds. The same build with a ROCm torch nightly and flydsl 0.3.4.1 passes TokenSwitchMoRITest 41/41 at 2 ranks, as on the 2-GPU CI runners, with a cold and a warm kernel cache. This PR's docker-builds CI exercises the image build itself, on ROCm 10.2.

HIP_VISIBLE_DEVICES=2,3 python test/distributed/test_token_switch.py -v

cc @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @jataylo @hongxiayang @naromero77amd @pragupta @jerrymannil @xinyazhang

The TokenSwitchMoRI tests from pytorch#201225 skip in CI because no CI image has MoRI. This adds MoRI to the ROCm CI images that run on MI300 and MI350. Single-node only; there are no multi-node ROCm CI runners yet.

`install_mori.sh` builds MoRI from source, pinned in `ci_commit_pins/mori.txt` to v1.2.5. It does not install flydsl: MoRI's flydsl EP backend uses the flydsl 0.3.4.1 that `.ci/pytorch/test.sh` already installs on the ROCm multi-GPU distributed shards, where the MoRI tests run, so other jobs see no new flydsl. The `amd_mori` wheels on PyPI are cp310/cp312 only and the images use Python 3.11. The build needs no GPU and no torch: MoRI JIT-compiles its kernels on first use, so the background precompile and the optional torch extension are off. No NIC provider (`USE_IONIC`/`USE_BNXT`) is built. It runs for `pytorch-linux-noble-rocm-n-py3.11` and `pytorch-linux-noble-rocm-preview-py3.11`; the jammy image runs only on MI210 (gfx90a), which MoRI does not support.

Test Plan:
On an MI355X host, the script's build steps in a fresh Python 3.11 venv without torch, as at docker build time, take about 20 s and `import mori.cco.cco` succeeds. The same build installed with a ROCm torch nightly and flydsl 0.3.4.1 passes TokenSwitchMoRITest 41/41 at 4 ranks, with a cold and a warm kernel cache:
```
python test/distributed/test_token_switch.py -v
```
The PR's docker-builds CI exercises the image build itself.

Authored with Claude.
Review follow-up. The recursive clone also fetched SPDK and redis-plus-plus, which the default build never uses; only spdlog and msgpack-c are needed. MoRI's requirements-build.txt also installs prettytable and pytest-assume, a pytest plugin that would load into every pytest run in these images, so only the build requirements missing from requirements-ci.txt are installed. The script and pin are renamed to install_rocm_mori.sh and rocm-mori.txt so the existing ROCm CODEOWNERS globs cover them.

Test Plan:
On an MI355X host with TheRock ROCm 10.1 wheels, the new steps in a fresh Python 3.11 venv without torch (requirements-ci pins of cmake, ninja and setuptools) clone and build in about 20 s, leave spdk and redis-plus-plus empty, and `import mori.cco.cco` succeeds. The same build with a ROCm torch nightly and flydsl 0.3.4.1 passes TokenSwitchMoRITest 41/41 at 2 ranks, as on the 2-GPU CI runners, with a cold and a warm kernel cache:
```
HIP_VISIBLE_DEVICES=2,3 python test/distributed/test_token_switch.py -v
```

Authored with Claude.
@pytorch-bot

pytorch-bot Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/206534

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit ed2d076 with merge base fac4ca8 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot

pytorch-bot Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Workflows were awaiting approval. CI has now been triggered for the ciflow labels on this PR.

@jithunnair-amd jithunnair-amd added the ciflow/periodic-rocm-mi300 Trigger "distributed" config CI on ROCm MI300/MI325 label Nov 24, 2026
env_run passes its arguments through as_jenkins as an unquoted $*, so the quoted -c string was split into words and the check failed with a SyntaxError after MoRI had built. Call python directly, as install_jax.sh does. Pin the build requirements: an unpinned setuptools-scm pulled 10.x, which upgraded the image's pinned packaging from 24.2 to 26.4.

Authored with Claude.
pybind11 3.0.1 and wheel 0.48.0 arrive in the image transitively; pinning older versions would downgrade them.

Authored with Claude.
@jeffdaily jeffdaily added the ciflow/trunk Trigger trunk jobs on your pull request label Nov 25, 2026
@jeffdaily

Copy link
Copy Markdown
Collaborator

I pushed a fix for the image builds. The script's last line ran its import check through env_run, which passes arguments through as_jenkins unquoted, so python -c "import mori.cco.cco" was split into words and failed with a SyntaxError after MoRI had built; it now calls python -c directly, as install_jax.sh does. The build dependencies are now pinned: the unpinned setuptools-scm had pulled in 10.x, whose new dependency upgraded the image's pinned packaging from 24.2 to 26.4. Checked on gfx942 in the image's Python environment: the pins install without changing packaging, MoRI builds, and the import works. I also added ciflow/trunk so the MI350 distributed shards run the TokenSwitchMoRI tests.

At the v1.2.5 pin, TokenSwitchMoRITest::test_combine_autograd_backward faults in MoRI's ep_combine_0 kernel on MI300X (HSA_STATUS_ERROR_MEMORY_FAULT) and the other rank hangs. MoRI main at 94c7f60f796 has the upstream fixes and passes; the install script's submodules and build deps are unchanged there.

Test Plan:

On MI300X (gfx942), 2 GPUs, torch built from this branch's base, MoRI installed with the script's steps at each pin:

```
python -bb distributed/test_token_switch.py -m '(multigpu)' -v -p no:xdist --use-pytest -x --reruns=0
```

At 41c5257d4b9 the first TokenSwitchMoRI test faults as in CI; at 94c7f60f796 all 54 tests pass (41 TokenSwitchMoRITest), 3 of 3 runs, and `import mori.cco.cco` passes with packaging still 24.2.

Authored with Claude.
@jeffdaily

Copy link
Copy Markdown
Collaborator

I pushed a maintainer commit moving the MoRI pin from v1.2.5 to 94c7f60f796. At v1.2.5, TokenSwitchMoRITest::test_combine_autograd_backward faults in MoRI's ep_combine_0 kernel on MI300X (HSA_STATUS_ERROR_MEMORY_FAULT) and the other rank hangs, as in the periodic MI300 distributed shard. At 94c7f60f796 the same test_token_switch.py command passes all 54 tests (41 TokenSwitchMoRITest) 3 of 3 runs on MI300X, and the install script works unchanged.

@jeffdaily jeffdaily left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. CI shows that MoRI builds into the ROCm images, and the TokenSwitchMoRI tests pass on both MI300 and MI350.

@jeffdaily

Copy link
Copy Markdown
Collaborator

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/docker ciflow/inductor ciflow/periodic-rocm-mi300 Trigger "distributed" config CI on ROCm MI300/MI325 ciflow/trunk Trigger trunk jobs on your pull request Merged module: rocm AMD GPU support for Pytorch open source topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants