Skip to content

[AMD] Qwen4-Exp SP: overlap the reduce-scatter and both all-gathers with compute over SDMA (mori) - #89

Merged
apinge merged 17 commits into
apinge:qwen38-flash-next-amd-current-fix-installfrom
yicyang:qwen4-sp-sdma-mori
Nov 10, 2026
Merged

apinge merged 17 commits into
apinge:qwen38-flash-next-amd-current-fix-installfrom
yicyang:qwen4-sp-sdma-mori

Conversation

@yicyang

@yicyang yicyang commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

[AMD] Qwen4-Exp SP: overlap the reduce-scatter and both all-gathers with compute over SDMA (mori)

Follow-up to #80 (sequence-parallel HC residual).

Motivation

With sequence parallelism, every TP prefill sublayer runs three collectives on the compute stream, all fully exposed:

  • a reduce-scatter after attention / GDN / MoE;
  • an all-gather before attention / GDN;
  • an all-gather before the MoE.

Per 12k-token step on TP-0 they cost 128 ms at TP2 and 84 ms at TP4. This PR moves them to the SDMA copy engines and
overlaps each with the compute next to it.

What this PR does

what_this_pr_does
  • Orange push / wait kernels run on the compute stream; the blue copies run on the SDMA engines under the next
    compute kernel.
  • The MoE output, computed whole, is reduce-scattered with the same chunked pushes.
  • Every overlap keeps exact per-row math:
    • GEMMs and HC ops are row-independent;
    • the reduce order is unchanged.
  • Greedy outputs are bit-identical to the baseline.

The copies are posted with mori:

  • One-wave kernels on the compute stream write the SDMA packets (mori CCO put_ptr with an engine-side completion
    signal).
  • The consumer waits with a one-wave spin kernel on the same stream.
  • There are no side streams and no cross-stream events; each push costs about 5 us on the compute stream.
  • Only mori's SDMA queues and signal pool are used. Destinations are our hipIpc buffers, not mori's VMM windows, so
    hosts without CONFIG_DMABUF_MOVE_NOTIFY work too.

Changes

  • layers/sdma_reduce_scatter.py (new):
    • SdmaReduceScatter: chunked push, bf16 or fp8 wire;
    • SdmaAllGather: per-block consume, plus begin / AllGatherWriter for range-by-range pushes.
  • layers/sdma_mori.py (new):
    • MoriSdmaHub: one mori DevComm shared by all SDMA collectives;
    • FlyDSL push / wait kernels;
    • sdma_available() / mori_unavailable_reason().
  • layers/hyperconnection.py: row-range combine_rows / mix_rows.
  • models/qwen4_exp.py:
    • chunked o_proj / out_proj;
    • per-block in_proj consumer;
    • _sp_pipelined_mlp_input (HC row ranges + MoE-input pushes).
  • python/pyproject_other.toml: pins mori in srt_hip / srt_hip_rocm724, next to PyHIP.
  • environ.py, MI308X launch script, benchmark/qwen4_seq_parallel/{README.md, bench_sdma_rs.py}.

Dependencies

This PR adds one dependency, mori, used only by the SDMA path:

Item Where Notes
mori python/pyproject_other.toml (srt_hip, srt_hip_rocm724) pinned to apinge/mori qwen3.8-flash-sdma, next to PyHIP. The branch includes the MI308X SDMA engine spread (apinge/mori#1); without it, two of a GPU's xGMI links can share one SDMA engine at TP4. Built with mori's defaults (BUILD_CCO_SDMA=ON).
libibverbs-dev system package mori's build checks for it
  • Runtime: the launch script sets these:
    • MORI_ENABLE_SDMA=1, MORI_SOCKET_IFNAME=lo;
    • an LD_PRELOAD of ROCm's rocm_sysdeps libdrm. mori and the HIP runtime must share one libdrm, otherwise
      mori's KFD setup cannot acquire the GPU VM.
  • Fallback: sglang checks for mori and the libdrm preload before touching mori. If either is missing, it logs one
    warning and keeps [AMD] Qwen4-Exp: sequence-parallel hyper-connection residual for TP prefill #80's aiter reduce-scatter / all-gather.

New environment variables

All of them act only with SGLANG_QWEN4_SEQ_PARALLEL=1 (default since #80), on ROCm with mori available.

Variable Default Meaning
SGLANG_QWEN4_SP_SDMA_RS 1 reduce-scatters over SDMA, chunked with the producing projection
SGLANG_QWEN4_SP_SDMA_AG 1 attention / GDN input all-gather over SDMA, consumed per block by the input projection
SGLANG_QWEN4_SP_SDMA_AG_MOE 1 MoE input all-gather over SDMA, pushed per HC row range
SGLANG_QWEN4_SP_SDMA_RS_TRANSPORT bf16 bf16 (exact) or fp8 (peers' rows as fp8 + a bf16 scale per 32; lossy)
SGLANG_QWEN4_SP_SDMA_RS_CHUNKS auto row chunks per owner block; auto = 2 at TP2, 1 above (measured)
SGLANG_QWEN4_SP_SDMA_AG_MOE_CHUNKS auto minimum HC row ranges; auto = 4 at TP2, 2 above (measured)

Results

Setup:

Prefill step (12000 tokens, median of steps 2-4, TP-0, ms):

TP2 baseline TP2 mori TP4 baseline TP4 mori
step 677.1 605.1 (-10.6%) 425.0 395.2 (-7.0%)
compute kernels 545.5 562.3 338.5 346.6
exposed communication 127.9 37.3 84.0 43.9
of which aiter RS / AG / AR 59.6 / 60.5 / 7.8 - / 0.7 / 7.9 42.4 / 36.3 / 5.3 - / 0.4 / 5.1
of which SDMA waits - 28.7 - 38.4
push kernels - 1.9 - 1.9
  • Compute rises by 17 ms (TP2) / 8 ms (TP4): the SDMA traffic competes with GEMMs for HBM.
  • The remaining all-reduce belongs to the layers before the PLE layer.

QPS (req/s from benchmark duration, two interleaved rounds):

conc TP2 baseline TP2 mori gain TP4 baseline TP4 mori gain
1 0.303 0.309 +2.1% 0.355 0.354 -0.3%
4 0.614 0.640 +4.2% 0.825 0.838 +1.6%
8 0.838 0.889 +6.0% 1.122 1.157 +3.1%
16 0.994 1.078 +8.4% 1.398 1.447 +3.5%
32 1.079 1.183 +9.7% 1.578 1.654 +4.8%

c1 TTFT: TP2 731 -> 657 ms, TP4 477 -> 450 ms.

Accuracy

Traces

Before (baseline: SP, aiter RS / AG)

  1. all-gather before attention / GDN
image
  1. reduce-scatter after attention / GDN
image
  1. all-gather before the MoE
image

After (SP + SDMA overlapped over mori)

  1. all-gather before attention / GDN(overlaped with in_proj)
image
  1. reduce-scatter after attention / GDN(overlapped with out_proj)
image
  1. all-gather before the MoE (overlapped with hc)
image

Limitations

  • The MoE-output reduce-scatter is pushed after the whole MoE, with no compute to hide under. It is the largest
    remaining SDMA wait:
    • TP2: 18.1 of 28.7 ms per step;
    • TP4: 15.3 of 38.4 ms per step. TP4 also waits 10.9 ms on the attention RS, since its last peer block overlaps
      only the own-block GEMM.
  • Decode, captured graphs, prefills below SGLANG_QWEN4_SEQ_PARALLEL_MIN_TOKENS and the layers before the PLE layer
    keep the all-reduce. Decode messages are a few KB with nothing to overlap, so SDMA's fixed latency would not pay
    off.
  • mori-shmem (mori.ccl) collectives must not post SDMA in the same process: they keep separate write pointers on
    the same SDMA queues.

Reproduce

apt-get update && apt-get install -y libibverbs-dev
pip install "amd_mori @ git+https://github.com/apinge/[email protected]"   # once
TP_SIZE=2 bash scripts/launch_qwen38_flash_next_fp8_mi308x_pure_tp_4_or_8_or_2.sh
bash scripts/run_pure_text_bench.sh
# baseline (SP only): SGLANG_QWEN4_SP_SDMA_RS=0 SGLANG_QWEN4_SP_SDMA_AG=0 SGLANG_QWEN4_SP_SDMA_AG_MOE=0

…mpute over SDMA

On top of the sequence-parallel residual, each communication runs on the SDMA
copy engines under compute:
- reduce-scatter: o_proj / GDN out_proj run in row chunks, peers' blocks first,
  and each chunk is pushed to its owner as soon as it is computed; the owner
  waits per chunk right before combining it (the MoE output is pushed the same way);
- attention / GDN input all-gather: the input projection runs on the local rows
  while peers' rows land, then on each peer block as it arrives;
- MoE input all-gather: hc_combine / hc_norm / mix run in row ranges and each
  range is pushed as soon as it is mixed.

The default mori backend posts the copies with one-wave kernels on the compute
stream (mori CCO SDMA put with an engine-side completion signal), so no side
streams or cross-stream events are needed; the hip backend (hipMemcpyAsync on
per-peer copy streams) is used when mori cannot run in the process.

Switches (on by default, only with SGLANG_QWEN4_SEQ_PARALLEL):
SGLANG_QWEN4_SP_SDMA_RS / _AG / _AG_MOE, SGLANG_QWEN4_SP_SDMA_BACKEND (mori|hip),
SGLANG_QWEN4_SP_SDMA_RS_TRANSPORT (bf16|fp8), SGLANG_QWEN4_SP_SDMA_RS_CHUNKS and
SGLANG_QWEN4_SP_SDMA_AG_MOE_CHUNKS (auto by TP size). The MI308X launch script
exports them and preloads ROCm's libdrm for mori.
Drop the hip copy-stream backend: every SDMA push and wait goes through mori.
Without a usable mori (not importable, MORI_ENABLE_SDMA unset, or the libdrm
preload missing) the layers log one warning and keep the aiter reduce-scatter /
all-gather of plain sequence parallelism. SGLANG_QWEN4_SP_SDMA_BACKEND is gone.

mori is pinned like PyHIP in python/pyproject_other.toml (ROCm/mori 752efd3);
benchmark/qwen4_seq_parallel/mori/ adds the MI308X engine-spread patch and
install_mori.sh, which builds that commit with the patch and BUILD_CCO_SDMA=ON.
The README lists the tested versions (ROCm 7.14, torch 2.12, FlyDSL 0.3.2).
… qwen4-sp-sdma-mori

Resolve the launch-script conflict: keep the SDMA / mori exports and sgl-project#62's
GDN prefill backend and SSM dtype printouts.
They install a runtime dependency rather than run a benchmark; 3rdparty/amd
already holds the same clone + patch + build pattern for rocmProfileData.
Keep the per-engine counts in an AnvilLib member sized for the full 32-bit
engine mask (the old 8-entry static array could be indexed past its end on
parts with more engines), and only re-pick an engine for a peer link that
gets its first channels.
Track the upstream proposal: on MI308X a new peer link is only moved when its
engine collision involves a folded (fused-off) recommendation, and only onto
an xGMI engine the GPU does not use yet. Drop MORI_SDMA_SPREAD_MI308X from the
launch script and README.
The branch carries the MI308X SDMA engine spread (apinge/mori#1), so the
local patch is no longer needed. install_mori.sh now only builds the pinned
branch (MORI_REF also takes a commit or pull ref).
With the patch gone, the amd_mori pin in pyproject_other.toml builds the same
thing (BUILD_CCO_SDMA is on by default); the README shows pip --target for
installs outside the environment.
@apinge
apinge requested review from apinge and sammysun0711 and removed request for apinge November 7, 2026 12:59
@yicyang
yicyang marked this pull request as ready for review November 9, 2026 01:16
Comment thread python/sglang/srt/environ.py Resolved
_HIP_IPC_LAZY_PEER = 0x1
_MAX_CHUNKS = 64
_TRANSPORTS = ("bf16", "fp8")
_QUANT_GROUP = 32

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.

Do we apply quantized reduce scatter (e.g. FP8) here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

not yet in this PR, its a placeholder for further support.

Comment on lines +45 to +58
def _load_hip():
hip = ctypes.CDLL("libamdhip64.so")
hip.hipIpcGetMemHandle.argtypes = [ctypes.POINTER(_HipIpcHandle), ctypes.c_void_p]
hip.hipIpcOpenMemHandle.argtypes = [
ctypes.POINTER(ctypes.c_void_p),
_HipIpcHandle,
ctypes.c_uint,
]
hip.hipMemGetAddressRange.argtypes = [
ctypes.POINTER(ctypes.c_void_p),
ctypes.POINTER(ctypes.c_size_t),
ctypes.c_void_p,
]
return hip

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.

Since MORI also leverage the CUDA IPC here, shall we also test if it is compatible with multimodal data:
enable launch server with --mm-feature-transport cuda_ipc, then run multimodal smoke test evaluation/run_multimodal_test.sh, reference: https://github.com/apinge/sglang/pull/92/changes#diff-339fbc8803ec1b82fd6c196cb8aa03df343aae3810cadccf257c50ca74c3c031

@yicyang yicyang Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

No impact on cuda_ipc according to the test. This table shows the logprob of the same token id, sampled by greedy search.

TP2 cuda_ipc (first token's logprob) cpu(first token's logprob)
SDMA on: image + long text / text only -0.1462 / -0.0336 -0.1462 / -0.0336
SDMA off: image + long text / text only -0.5904 / -0.0482 -0.5904 / -0.0482

Comment thread python/sglang/srt/environ.py Resolved
_MAX_CHUNKS sized the hip backend's per-chunk flags; with mori the chunk
waits use the engine's signal counter, so nothing bounds chunks above.
All SP SDMA variables now appear in the MI308X launch script; the two chunk
counts stay commented out so unset keeps the measured per-TP defaults.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved critical defects can hang SDMA collectives, break cross-node initialization, produce incorrect FP16 reductions and FP8 projections, and fail the registered CPU guard.

6 open issues
What changed in this PR

Builds on sequence-parallel hyper-connections from #80 by overlapping Qwen4-Exp prefill communication with computation on AMD GPUs using mori-backed SDMA.

Changes:

  • Adds chunked reduce-scatter and all-gather operations with device-side completion waits.
  • Integrates projection chunks and hyper-connection row ranges into the model’s prefill path.
  • Adds runtime controls, mori dependencies, launch configuration, and benchmarks.
File Description
scripts/​launch_qwen38_flash_next_fp8_mi308x_pure_tp_4_or_8_or_2.sh Configures SDMA switches, chunk counts, and mori runtime requirements.
python/​sglang/​srt/​models/​qwen4_exp.py Integrates overlapped collectives and chunked computation into prefill.
python/​sglang/​srt/​layers/​sdma_reduce_scatter.py Implements SDMA reduce-scatter and all-gather with IPC buffers.
python/​sglang/​srt/​layers/​sdma_mori.py Adds shared mori queues, push/wait kernels, and availability checks.
python/​sglang/​srt/​layers/​hyperconnection.py Adds row-range mix and combine operations.
python/​sglang/​srt/​environ.py Defines SDMA feature, transport, and chunking controls.
python/​pyproject_other.toml Adds mori to both ROCm dependency groups.
benchmark/​qwen4_seq_parallel/​README.md Documents overlap behavior, configuration, and dependencies.
benchmark/​qwen4_seq_parallel/​bench_sdma_rs.py Adds reduce-scatter correctness checks and layer-like timing comparisons.

Review effort: Balanced

Comment thread python/sglang/srt/layers/sdma_mori.py Resolved
Comment thread python/sglang/srt/layers/sdma_mori.py Resolved
Comment thread python/sglang/srt/models/qwen4_exp.py Resolved
Comment thread python/sglang/srt/models/qwen4_exp.py Resolved
Comment thread python/sglang/srt/models/qwen4_exp.py Resolved
- Fall back to aiter when the attention TP group spans nodes (HIP IPC maps
  only within one node) or when mori set up no SDMA queue (puts would move
  no bytes and the waits would never return); checked once per process.
- Keep the SDMA reduce-scatter to bf16, the dtype its reduce kernel sums.
- Read max_prefill_tokens through runtime_context.get_schedule() instead of
  the legacy get_global_server_args().
- Drop each consumed projection chunk / all-gather input from the in-flight
  handles, which the model keeps on its carrier tensors.
…D CI

amd_mori, pinned in the hip extras, builds from source and its setup.py stops
without the ibverbs headers, which the base image does not ship.
…e / CI

Revert the Dockerfile and AMD CI changes; the README now lists the install
steps for mori (ibverbs headers, then the pinned amd_mori).
Only mori and libibverbs-dev are added on top of the ROCm 7.14 image; FlyDSL
and torch stay the image's. Drop --no-deps (mori declares no runtime deps)
and run the import check with the libdrm preload, without which importing
mori next to FlyDSL can crash.
@apinge
apinge merged commit d4edb47 into apinge:qwen38-flash-next-amd-current-fix-install Nov 10, 2026
1 check failed
sammysun0711 added a commit that referenced this pull request Nov 11, 2026
* [AMD] Qwen4-Exp: sequence-parallel hyper-connection residual for TP prefill (#80)

* [AMD] Qwen4-Exp: sequence-parallel hyper-connection residual for TP prefill (opt-in)

Between the TP-sharded blocks, Qwen4-Exp runs three per-token ops on its
4-lane hyper-connection residual: hc_combine, hc_norm and the low-rank mix.
With a replicated residual every TP rank repeats them on all tokens, ~165 ms
of a 12k-token prefill step per rank (31% at TP4, 22% at TP2).

With SGLANG_QWEN4_SEQ_PARALLEL=1, prefill keeps the residual sharded by token
rows after the last PLE layer (layers/hc_seq_parallel.py): each block's
partial output is reduce-scattered instead of all-reduced, combined and mixed
on this rank's rows, and the mixed input is all-gathered for the next block.
The MoE runs under mlp_reduce_scatter=True so it returns its partial sum.
RS + AG (aiter custom kernels) move the same bytes as the all-reduce, and
AG(RS(x)) is bit-identical to AR(x).

Decode, graph capture, speculative modes, DP attention, EP all-to-all and
batches below SGLANG_QWEN4_SEQ_PARALLEL_MIN_TOKENS (2048) are unchanged.

12k-token prefill step: TP4 534 -> 436 ms, TP2 760 -> 685 ms. Serving
(12000 in / 350 out): TP4 +3% (c1) to +16% (c32) req/s, TP2 +2.5% to +7.5%,
greedy outputs bit-identical, gsm8k and a long-context probe unchanged.

* Qwen4-Exp SP: review fixes (aiter reduce-scatter check, PP guard, README note)

- Narrow the aiter reduce-scatter path with isinstance on aiter's
  CustomAllreduce instead of a private GroupCoordinator helper.
- Skip the sequence-parallel path when this rank does not start at layer 0
  (the residual is sharded at an absolute layer index).
- README: note the discarded TP4 c32 baseline round.

* Qwen4-Exp SP: refresh README results from the re-measurement

* Qwen4-Exp SP: gather the mixer output, and shard eager target-verify batches

- At the end of a sequence-parallel forward, run the final mixer on the local
  rows and all-gather its [T, hidden] output. The [T, hc_count * hidden]
  residual (HC state) is gathered only when the forward captures hidden
  states (speculative drafting, return_hidden_states), which is 1/hc_count
  of the gather bytes otherwise.
- Gate on EXTEND / MIXED / TARGET_VERIFY instead of
  is_extend_without_speculative: eager target-verify batches above the
  threshold are sharded too (captured ones never are), and split prefill is
  no longer let through.

* Add error handling for CustomAllreduce import

Handle ImportError for CustomAllreduce import.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

* Qwen4-Exp SP: list the sequence-parallel switches in the MI308X launch script (commented out)

* Qwen4-Exp SP: enable the sequence-parallel residual by default

SGLANG_QWEN4_SEQ_PARALLEL now defaults to on (0 restores the all-reduce), and the
MI308X launch script exports both SP switches with overridable defaults.

* Qwen4-Exp SP: keep the all-reduce in tc_piecewise and any captured prefill

get_is_capture_mode() only covers decode capture and breakable graphs; also skip
the sequence-parallel plan inside tc_piecewise CUDA graphs and whenever the current
stream is capturing, since the row split depends on the batch's token count.

---------

Co-authored-by: yicyang <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
(cherry picked from commit 15055ff)

* [AMD] Qwen4-Exp SP: overlap the reduce-scatter and both all-gathers with compute over SDMA (mori) (#89)

* Qwen4-Exp SP: overlap the reduce-scatter and both all-gathers with compute over SDMA

On top of the sequence-parallel residual, each communication runs on the SDMA
copy engines under compute:
- reduce-scatter: o_proj / GDN out_proj run in row chunks, peers' blocks first,
  and each chunk is pushed to its owner as soon as it is computed; the owner
  waits per chunk right before combining it (the MoE output is pushed the same way);
- attention / GDN input all-gather: the input projection runs on the local rows
  while peers' rows land, then on each peer block as it arrives;
- MoE input all-gather: hc_combine / hc_norm / mix run in row ranges and each
  range is pushed as soon as it is mixed.

The default mori backend posts the copies with one-wave kernels on the compute
stream (mori CCO SDMA put with an engine-side completion signal), so no side
streams or cross-stream events are needed; the hip backend (hipMemcpyAsync on
per-peer copy streams) is used when mori cannot run in the process.

Switches (on by default, only with SGLANG_QWEN4_SEQ_PARALLEL):
SGLANG_QWEN4_SP_SDMA_RS / _AG / _AG_MOE, SGLANG_QWEN4_SP_SDMA_BACKEND (mori|hip),
SGLANG_QWEN4_SP_SDMA_RS_TRANSPORT (bf16|fp8), SGLANG_QWEN4_SP_SDMA_RS_CHUNKS and
SGLANG_QWEN4_SP_SDMA_AG_MOE_CHUNKS (auto by TP size). The MI308X launch script
exports them and preloads ROCm's libdrm for mori.

* Qwen4-Exp SP SDMA: mori only, pin the mori dependency

Drop the hip copy-stream backend: every SDMA push and wait goes through mori.
Without a usable mori (not importable, MORI_ENABLE_SDMA unset, or the libdrm
preload missing) the layers log one warning and keep the aiter reduce-scatter /
all-gather of plain sequence parallelism. SGLANG_QWEN4_SP_SDMA_BACKEND is gone.

mori is pinned like PyHIP in python/pyproject_other.toml (ROCm/mori 752efd3);
benchmark/qwen4_seq_parallel/mori/ adds the MI308X engine-spread patch and
install_mori.sh, which builds that commit with the patch and BUILD_CCO_SDMA=ON.
The README lists the tested versions (ROCm 7.14, torch 2.12, FlyDSL 0.3.2).

* Move the mori install script and MI308X patch to 3rdparty/amd/mori

They install a runtime dependency rather than run a benchmark; 3rdparty/amd
already holds the same clone + patch + build pattern for rocmProfileData.

* 3rdparty/amd/mori: engine-spread patch as proposed upstream

Keep the per-engine counts in an AnvilLib member sized for the full 32-bit
engine mask (the old 8-entry static array could be indexed past its end on
parts with more engines), and only re-pick an engine for a peer link that
gets its first channels.

* 3rdparty/amd/mori: engine-spread patch without an env var

Track the upstream proposal: on MI308X a new peer link is only moved when its
engine collision involves a folded (fused-off) recommendation, and only onto
an xGMI engine the GPU does not use yet. Drop MORI_SDMA_SPREAD_MI308X from the
launch script and README.

* Pin mori to apinge/mori qwen3.8-flash-sdma, drop the engine-spread patch

The branch carries the MI308X SDMA engine spread (apinge/mori#1), so the
local patch is no longer needed. install_mori.sh now only builds the pinned
branch (MORI_REF also takes a commit or pull ref).

* Drop 3rdparty/amd/mori/install_mori.sh

With the patch gone, the amd_mori pin in pyproject_other.toml builds the same
thing (BUILD_CCO_SDMA is on by default); the README shows pip --target for
installs outside the environment.

* SdmaReduceScatter: drop the chunk-count upper bound

_MAX_CHUNKS sized the hip backend's per-chunk flags; with mori the chunk
waits use the engine's signal counter, so nothing bounds chunks above.

* hyperconnection: revert formatting-only changes

* launch script: list the SP SDMA chunk knobs as optional settings

All SP SDMA variables now appear in the MI308X launch script; the two chunk
counts stay commented out so unset keeps the measured per-TP defaults.

* launch script: export the SP SDMA chunk counts with their per-TP defaults

* Qwen4-Exp SP SDMA: address the Copilot review

- Fall back to aiter when the attention TP group spans nodes (HIP IPC maps
  only within one node) or when mori set up no SDMA queue (puts would move
  no bytes and the waits would never return); checked once per process.
- Keep the SDMA reduce-scatter to bf16, the dtype its reduce kernel sums.
- Read max_prefill_tokens through runtime_context.get_schedule() instead of
  the legacy get_global_server_args().
- Drop each consumed projection chunk / all-gather input from the in-flight
  handles, which the model keeps on its carrier tensors.

* README: libibverbs-dev is a build-time requirement missing from the base image

* Install libibverbs-dev before the hip extras in the ROCm image and AMD CI

amd_mori, pinned in the hip extras, builds from source and its setup.py stops
without the ibverbs headers, which the base image does not ship.

* Document the libibverbs-dev install in the README instead of the image / CI

Revert the Dockerfile and AMD CI changes; the README now lists the install
steps for mori (ibverbs headers, then the pinned amd_mori).

* README: mark image vs installed dependencies, fix the mori import check

Only mori and libibverbs-dev are added on top of the ROCm 7.14 image; FlyDSL
and torch stay the image's. Drop --no-deps (mori declares no runtime deps)
and run the import check with the libdrm preload, without which importing
mori next to FlyDSL can crash.

---------

Co-authored-by: yicyang <[email protected]>
(cherry picked from commit d4edb47)

* Qwen4 CI: install mori for the SP SDMA prefill path; port fixups for v0.5.21

The two cherry-picked PRs (#80, #89) were resolved onto qwen4_v0.5.21 as follows:
- keep the branch's PP-aware hyper_connection_mixer, PP proxy tensors and
  AuxHiddenStateList; sequence parallelism is also off when pp_size > 1, since a
  non-last stage hands its residual on in proxy tensors;
- the launch-script changes go to evaluation/launch_qwen38_..._pure_tp_4_or_8_or_2.sh,
  which now enables SP + SDMA by default, so the Qwen3.8 TP2 CI cases run with them;
- get_attn_tp_group comes from parallel_state (dp_attention no longer re-exports it);
- isort / ruff-format on the touched files.

evaluation/Dockerfile.ci installs libibverbs-dev and amd_mori (apinge/mori
qwen3.8-flash-sdma) before the candidate install: the srt_hip extras pin mori by
URL, which the CI requirement check cannot install. The guide documents both.

---------

Co-authored-by: yicyang <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Xiake Sun <[email protected]>
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.

4 participants