Skip to content

[Backport] Support CUDA IPC on ROCm for multimodal data in Qwen3.8 branch - #75

Merged
sammysun0711 merged 5 commits into
apinge:qwen38-flash-next-amd-current-fix-installfrom
sammysun0711:backport/rocm-cuda-ipc
Nov 3, 2026
Merged

sammysun0711 merged 5 commits into
apinge:qwen38-flash-next-amd-current-fix-installfrom
sammysun0711:backport/rocm-cuda-ipc

Conversation

@sammysun0711

@sammysun0711 sammysun0711 commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

This PR aim to support CUDA IPC on ROCm in Qwen3.8 branch for multimodal data transfer cross GPU.

Modifications

Backport following two upstream PR:

Accuracy Tests

Enable with following environment variable with Qwen3.8 server, text+image QA passed accuracy verification.

export SGLANG_USE_CUDA_IPC_TRANSPORT=1
export SGLANG_USE_IPC_POOL_HANDLE_CACHE=1

Speed Tests and Profiling

Not applicable.

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

Adapt 881b8ec to the existing ServerArgs handler and platform mocks; this branch predates serving_hook.

Signed-off-by: Xiake Sun <[email protected]>
PR sgl-project#33747 opens the multimodal IPC gate on HIP, but the pool lifecycle
introduced by sgl-project#33949 still calls the NVIDIA CUDA driver. Dispatch the
ROCm ready/wait/ack words through small Triton kernels with system-scope
acquire/release atomics. Keep the NVIDIA path unchanged.

Native HIP stream wait crashed on peer IPC mappings in the tested ROCm
build; the GPU kernel path preserves copy ordering and lease safety.
Correct the inherited gate comment to describe this additional backend
requirement and register IPC coverage for AMD.

Signed-off-by: Xiake Sun <[email protected]>
@sammysun0711
sammysun0711 requested review from apinge and a balanced review from Copilot October 28, 2026 13:35
Comment thread python/sglang/srt/server_args.py Resolved

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

2 open issues
What changed in this PR

Backports upstream changes to allow --mm-feature-transport=cuda_ipc on AMD ROCm/HIP by providing a ROCm-safe implementation of the CUDA-IPC pool’s stream-ordered ready/ack protocol, plus CI/tests to validate ROCm behavior.

Changes:

  • Allow cuda_ipc multimodal feature transport on either NVIDIA CUDA or AMD ROCm/HIP.
  • Add ROCm stream-control ops via Triton (system-scope atomics) and route stream_wait_value32/stream_write_value32 to the HIP implementation when on ROCm.
  • Expand unit tests and CI registration to cover stream ordering and multi-consumer reconstruction.
File Description
test/​registered/​unit/​server_args/​test_server_args.py Updates validation tests to accept ROCm for cuda_ipc and improves error-message coverage.
test/​registered/​unit/​multimodal/​test_cuda_ipc_transport.py Adds ROCm CI registration and new tests for stream ordering and multi-consumer reconstruction.
python/​sglang/​srt/​server_args.py Updates platform gating for cuda_ipc to include ROCm/HIP and adjusts the error message.
python/​sglang/​srt/​multimodal/​transport/​memory_pool.py Routes stream wait/write ops to ROCm-safe implementations when torch.version.hip is set.
python/​sglang/​srt/​multimodal/​transport/​hip_stream_ops.py Introduces Triton kernels implementing system-scope atomic wait/write for control words on ROCm.

Review effort: Lite

Comment on lines +8 to +23
def _wait_value32(address, value):
pointer = tl.cast(address, tl.pointer_type(tl.uint32))
while tl.atomic_add(pointer, 0, sem="acquire", scope="sys") < value:
pass


@triton.jit
def _write_value32(address, value):
pointer = tl.cast(address, tl.pointer_type(tl.uint32))
tl.atomic_xchg(pointer, value, sem="release", scope="sys")


def wait_value32(address: int, value: int) -> None:
_wait_value32[(1,)](address, value, num_warps=1)


@sammysun0711 sammysun0711 Oct 29, 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.

The patch is not valid

  • Uses tl.static_range(2**31 - 1), which asks Triton to expand roughly 2.1 billion iterations during compilation.
  • Never exits early when the flag becomes ready.
  • Returns after exhausting the loop without callers checking timeout status. The queued tensor copy and acknowledgement could then proceed before the data is ready.

I would like to keep this concern open for real customer case test.

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.

I try to bound CUDA IPC wait to align with server watchdog timeout to avoid infinity spin loop: b8fb891

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

The one-GPU CI registrations always skip the cross-GPU regression, leaving the new ROCm peer-IPC ready/ack path untested.

2 open issues
1 resolved since last review

Review effort: Balanced

- Reuse --watchdog-timeout for stream-ordered ROCm IPC readiness waits.
- Track GPU completion independently of scheduler batch activity.
- Log wait diagnostics and terminate consumers on timeout or query failure.
- Preserve supervision after event-record failures and reject graph capture.
- Add timeout and cached/uncached peer-IPC tests with two-GPU AMD CI.

Signed-off-by: Xiake Sun <[email protected]>
@apinge

apinge commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

The majority of this PR is a port of 2 upstream changes, with 2 newly introduced implementation files:

  • hip_stream_ops.py: Adds a ROCm implementation of stream wait/write using Triton system-scope acquire/release atomics, corresponding to the upstream use of cuStreamWaitValue32 and cuStreamWriteValue32 in upstream
  • ipc_wait_watchdog.py: Adds a watchdog to track completion of GPU wait events, terminating the consumer if a timeout or query failure occurs.

Notice that there exit hipStreamWaitValue32 and hipStreamWriteValue32. the message of 898ba7e , for this reason this PR uses triton kernel here.

Native HIP stream wait crashed on peer IPC mappings in the tested ROCm build

@apinge

apinge commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Tested with conc1 ,5 image (960x1280)8kin 500out

Original Record server config Mean TTFT
Before Add --mm-feature-transport cuda_ipc 1448.87 ms
After Do not add it; use CPU transport 1670.38 ms

In this record, enabling IPC reduced the Mean TTFT by 221.51 ms, approximately 13.26%.

@sammysun0711
sammysun0711 merged commit 3004941 into apinge:qwen38-flash-next-amd-current-fix-install Nov 3, 2026
1 check passed
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.

3 participants