Skip to content

Fix Primus Llama-3.1-8B scaleout: NCCL_NET_PLUGIN for v26.4 RCCL overlay etc.#1

Closed
i-kosarev wants to merge 3 commits into
mkuznet1:aicomnet_dev_publicfrom
i-kosarev:workload1-primus-8b-fixes
Closed

Fix Primus Llama-3.1-8B scaleout: NCCL_NET_PLUGIN for v26.4 RCCL overlay etc.#1
i-kosarev wants to merge 3 commits into
mkuznet1:aicomnet_dev_publicfrom
i-kosarev:workload1-primus-8b-fixes

Conversation

@i-kosarev

@i-kosarev i-kosarev commented Jul 3, 2026

Copy link
Copy Markdown

Summary

Fixes required to run the Primus Llama-3.1-8B scaleout workload (PR ROCm#174
workload-1) on real multi-node AINIC hardware with a swappable RCCL overlay.
All hit during validation on mia1. Two are runtime, one is the overlay-injection
build fix.

Build — RCCL overlay actually takes effect

  1. docker/primus_megatron_train_rccl_overlay.ubuntu.amd.Dockerfile: patch
    _rocm_sdk_libraries + global on-disk librccl sweep and gate.

    v26.4 splits ROCm libs into _rocm_sdk_libraries/lib (runtime .so) and
    _rocm_sdk_devel/lib (dev). torch maps librccl.so.1 from
    _rocm_sdk_libraries at runtime (soname wins once loaded), which the
    targeted /opt/rocm + torch/lib overwrites did not cover — so the
    candidate RCCL was built and shipped but the stock base librccl actually
    ran
    , silently invalidating the whole overlay validation. Stage 2 now sweeps
    every non-symlink librccl.so* on disk and overwrites it with the candidate
    (+add-needed librocm_smi64); the final gate asserts every on-disk librccl
    (not just 3 fixed paths) is RCCL 2.x with a baked git hash matching the built
    SHA. This is the injection robustness the RCCL-swap workflow depends on.

Runtime

  1. GBS normalization for the 8B branch of
    scripts/primus_scaleout/megatron-lm/primus_megatron-lm_benchmark_report.sh.
    The 70B branch already normalizes GBS to the world size and passes explicit
    --micro_batch_size/--global_batch_size; the 8B branch did neither. At any
    node count where GBS % (MBS * world_size) != 0 (3-node/24-GPU: 512 % 96 != 0)
    Megatron aborts at startup with global batch size ... not divisible by micro batch size ... times data parallel size. Fix mirrors the 70B branch.
  2. NCCL_NET_PLUGIN=none in assets/manifests/primus_llama-3.1-8b.template.json
    (both env blocks). rocm/primus:v26.4 defaults NCCL_NET_PLUGIN=librccl-anp.so;
    that ANP plugin is incompatible with a bundled RCCL overlay and RCCL init hangs.

Docs

  1. references/gotchas.md — documents the GBS and NCCL_NET_PLUGIN pitfalls.

Validation

Primus Llama-3.1-8B scaleout, 3-node / 24-GPU MI355X (mia1). With the
_rocm_sdk_libraries sweep, the NCCL banner shows the candidate develop
86f60f9
(before the sweep it silently ran stock d34cbb6). AINIC RoCE
transport confirmed. 50 iters, 0 nan / 0 skipped, ~1550 TFLOP/s/GPU,
~30067 tokens/s/GPU (BF16). Without fix #2 the run aborts before iter 1; without
fix ROCm#3 RCCL init hangs.

Test plan

  • Overlay librccl SHA in the runtime NCCL banner == candidate build SHA (not stock)
  • Llama-3.1-8B scaleout completes 50 iters where GBS is not divisible by MBS * world_size
  • NCCL banner shows AINIC RoCE transport
  • JSON template parses; bash -n on the edited script passes
  • Re-confirm on the default 2-node template shape (GBS divisible → normalize is a no-op)

🤖 Generated with Claude Code

i-kosarev added 2 commits July 3, 2026 11:03
….4 RCCL overlay

- benchmark_report.sh: normalize the 8B global batch size to the world size
  (mirroring the 70B branch) and pass explicit --micro_batch_size/--global_batch_size,
  so runs at node counts where GBS % (MBS * world_size) != 0 (e.g. 3-node/24-GPU)
  no longer abort with Megatron's "global batch size not divisible" assertion.
- primus_llama-3.1-8b.template.json: set NCCL_NET_PLUGIN=none in both env blocks.
  rocm/primus:v26.4 defaults NCCL_NET_PLUGIN=librccl-anp.so, which deadlocks RCCL
  init when the image carries a bundled RCCL overlay.
- gotchas.md: document both pitfalls.

Validated: Primus 8B scaleout, 3-node/24-GPU MI355X, RCCL develop 86f60f9 + AINIC
RoCE, 50 iters, ~1550 TFLOP/s/GPU BF16.
… gate

The v26.4 base splits ROCm libs into _rocm_sdk_libraries/lib (runtime) and
_rocm_sdk_devel/lib (dev). torch maps librccl.so.1 from _rocm_sdk_libraries at
runtime (soname wins once loaded), which the targeted /opt/rocm + torch/lib
overwrites did not cover -- so the candidate RCCL was built and shipped but the
stock base librccl actually ran, silently invalidating the overlay validation.

- stage 2: after the targeted overwrites, sweep every non-symlink librccl.so* on
  disk and overwrite it with the candidate (+add-needed librocm_smi64), so
  whichever copy the loader maps is the candidate regardless of ROCm layout.
- final gate: assert EVERY librccl on disk (not just 3 fixed paths) is RCCL 2.x
  with a baked git hash matching the built SHA.

This is the injection robustness the RCCL-swap workflow depends on.
@i-kosarev i-kosarev changed the title Fix Primus Llama-3.1-8B scaleout: GBS normalize + NCCL_NET_PLUGIN for v26.4 RCCL overlay Fix Primus Llama-3.1-8B scaleout: NCCL_NET_PLUGIN for v26.4 RCCL overlay etc. Jul 4, 2026
…nto _rocm_sdk_devel/bin)

v26.4 ships ROCm as pip wheels; the amdclang++ wrapper in _rocm_sdk_devel/bin/
looks for its clang++/clang-23 helpers next to itself, but they live only in
_rocm_sdk_devel/lib/llvm/bin/. RCCL's device-code compile calls bin/amdclang++
directly (--offload-device-only) and fails:
  amdclang++: binary '.../_rocm_sdk_devel/bin/clang++' does not exist.
Symlink clang/clang++/clang-23 into bin/ so the wrapper resolves. Guarded to be
a no-op on v26.3 / non-wheel bases. Validated: full RCCL build+install exit 0
on rocm/primus:v26.4 (CC/CXX=hipcc alone does NOT fix the device-compile path).

Co-authored-by: Cursor <cursoragent@cursor.com>
mkuznet1 added a commit that referenced this pull request Jul 7, 2026
Adapt the fixes from #1 to the current branch.

- docker/primus_megatron_train_rccl_overlay.ubuntu.amd.Dockerfile: after the
  targeted /opt/rocm + torch/lib overwrites, sweep every non-symlink
  librccl.so* on disk and overwrite it with the candidate (+add-needed
  librocm_smi64), and tighten the final gate to assert EVERY on-disk librccl
  (not just 3 fixed paths) is RCCL 2.x with a baked git hash matching the built
  SHA. v26.4 splits ROCm libs into _rocm_sdk_libraries/lib (runtime) and
  _rocm_sdk_devel/lib (dev); torch maps librccl.so.1 from _rocm_sdk_libraries
  at runtime, which the targeted overwrites did not cover, so the stock base
  librccl silently ran and invalidated the overlay validation.

- assets/manifests/primus_llama-3.1-8b.template.json: set NCCL_NET_PLUGIN=none
  in both env blocks. rocm/primus:v26.4 defaults NCCL_NET_PLUGIN=librccl-anp.so,
  which deadlocks RCCL init when the image carries a bundled RCCL overlay.

- references/gotchas.md: document the NCCL_NET_PLUGIN pitfall, and the GBS
  normalization requirement (adapted to this branch: the GBS fix from the PR's
  scripts/primus_scaleout/megatron-lm/primus_megatron-lm_benchmark_report.sh is
  already generalized here by scaleout_gbs_override in
  scripts/primus/megatron-lm/primus_megatron-lm_benchmark_report.sh after the
  primus_scaleout consolidation, so no per-branch code change is ported).

Ref: #1
@mkuznet1

mkuznet1 commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Used in d0fa669

@mkuznet1 mkuznet1 closed this Jul 7, 2026
mkuznet1 added a commit that referenced this pull request Jul 8, 2026
sglang_disagg_mori_io_ep.sh is a functional superset of server.sh
(models.yaml-driven config, mori/mooncake/nixl backends via
KV_TRANSFER_BACKEND, DP_MODE support), and run_xPyD_models.slurm
already always uses it. run.sh was the only remaining consumer of
server.sh, so route both RUN_MORI branches to the unified launcher
and drop the duplicate. Also port server.sh's KV_TRANSFER_BACKEND
allowlist guard (against eval injection) into mori_io_ep.sh, and
update the README and mad-slurm-multinode skill docs accordingly.

Addresses PR ROCm#174 review feedback (basemam #1: stale/duplicate
server.sh).
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.

2 participants