Skip to content

[Feat] [AMD] multimodal: Enable feature IPC transport on ROCm - #33747

Closed
vincentzed wants to merge 2 commits into
sgl-project:mainfrom
vincentzed:mm-feature-transport-rocm
Closed

vincentzed wants to merge 2 commits into
sgl-project:mainfrom
vincentzed:mm-feature-transport-rocm

Conversation

@vincentzed

@vincentzed vincentzed commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

--mm-feature-transport=cuda_ipc was rejected on ROCm even though the implementation only uses PyTorch's CUDA-compatible APIs (torch.cuda, _share_cuda_), which dispatch to HIP IPC in a ROCm build. That forced every image feature tensor through the CPU shared-memory transport. On MI325X, a paired frontend profile attributed 0.73 s to wrap_shm_features / _wrap_shm_or_inline for 128 concurrent image requests; HIP IPC wrapping is 0.02 s (−97.3%).

Modifications

  • Accept cuda_ipc on CUDA or ROCm/HIP in _handle_multimodal_feature_transport. The single-node and multimodal-splitting guards are unchanged, and the public flag name stays cuda_ipc.
  • Unit tests: ROCm acceptance (env-isolated with patch.dict — acceptance writes the legacy IPC env var and must not leak into later tests) and an explicit rejection test for non-CUDA-like platforms.

Accuracy Tests

MI325X, Torch 2.9.1 + ROCm 7.2, BF16 (HSA_ENABLE_IPC_MODE_LEGACY=1):

  • test/registered/unit/server_args/test_server_args.py passes; cross-process test_cuda_ipc_transport.py passes.
  • Standalone HIP IPC probe — allocate → pooled share → reconstruct in a spawned process — returns the exact tensor (torch.testing.assert_close) with exactly one cached pool handle.

Speed Tests and Profiling

Single-image serving workload (512×512, 268 input / 32 output tokens, 512 prompts, 1 warmup + 3 measured runs, one MI325X):

Concurrency CPU SHM HIP IPC Gain
16 1,374 tok/s 1,649 tok/s +20.0%
32 1,686 tok/s 2,154 tok/s +27.8%

Checklist


CI States

Latest PR Test (Base): ❌ Run #39094939664
Latest PR Test (Extra): ❌ Run #39094939726
Latest PR Test (AMD ROCm 10): ❌ Run #39094939657

--mm-feature-transport=cuda_ipc only uses PyTorch CUDA-compatible APIs
(torch.cuda, _share_cuda_), which dispatch to HIP IPC on a ROCm build,
so accept it there instead of forcing image feature tensors through the
CPU shared-memory transport. On MI325X the CPU SHM path cost 0.73 s of
frontend wrapping for 128 concurrent image requests vs 0.02 s over HIP
IPC; C32 image serving improved 27.8%.

Single-node and multimodal-splitting guards unchanged; the public flag
name stays cuda_ipc. The acceptance unit test restores os.environ
(acceptance writes the legacy IPC env var) so it cannot leak into later
tests.
@vincentzed vincentzed mentioned this pull request Aug 5, 2026
The transport resolution moved from ServerArgs._handle_multimodal_feature_transport
to arg_groups/serving_hook.handle_multimodal_feature_transport. Accept cuda_ipc on
CUDA or HIP there. Tests use override_platform instead of patching server_args.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KVPUFiK2bhzjErEnCMv26w
@vincentzed
vincentzed marked this pull request as ready for review September 7, 2026 18:09
@vincentzed

Copy link
Copy Markdown
Contributor Author

Closing this. Since it was written, #33949 moved the cuda_ipc pool onto the CUDA driver calls cuStreamWaitValue32 and cuStreamWriteValue32, so opening the gate on ROCm would turn on a path that cannot work there. Doing this properly needs HIP versions of those calls and a fresh measurement on AMD hardware.

@vincentzed vincentzed closed this Oct 18, 2026
@vincentzed vincentzed reopened this Oct 18, 2026
@vincentzed vincentzed changed the title [Multimodal] Enable feature IPC transport on ROCm [Feat] [AMD] multimodal: Enable feature IPC transport on ROCm Oct 18, 2026
@vincentzed

Copy link
Copy Markdown
Contributor Author

Reopening, I closed this too early. The change is still wanted, but it needs testing on AMD before it can merge. Since this was written, #33949 moved the cuda_ipc pool onto cuStreamWaitValue32 and cuStreamWriteValue32, so ROCm needs the HIP equivalents (hipStreamWaitValue32 and hipStreamWriteValue32) checked on real hardware. The MI325X numbers in the description are from before that change.

apinge pushed a commit to apinge/sglang that referenced this pull request Oct 22, 2026
…_v0.5.21` (#54)

* Merge main; port the cuda_ipc ROCm gate to serving_hook

The transport resolution moved from ServerArgs._handle_multimodal_feature_transport
to arg_groups/serving_hook.handle_multimodal_feature_transport. Accept cuda_ipc on
CUDA or HIP there. Tests use override_platform instead of patching server_args.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KVPUFiK2bhzjErEnCMv26w
(cherry picked from commit 7453337)

* [AMD] Complete stream-ordered multimodal IPC support on ROCm

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.

* support qwen3.5 fp8 ptpc model

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

* Add Qwen3.5 + dflash support with cuda graph and target verify

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

* Add evaluation guide and scripts

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

* eval: update eval guide & scripts

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

* Addess review comments

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

* eval: update guide to enforce reinstall process

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

* fix(qwen3.8 ple): release loader parameter references before FP8 postprocessing

The self-referencing PLE shard loader forms a closure cycle that retains
params_dict after weight loading. When FP8 postprocessing
(fp8e4m3->fp8e4m3nuz) replaces the parameters, the dictionary keeps
their original GPU storage alive until cyclic GC runs, causing
Qwen3.8 BF16-PLE TP2 launches OOM.

Clear params_dict before returning so obsolete weight storage can be
released during postprocessing. Preserve PLE GPU residency, weight
precision, and existing quantization behavior.

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

* eval: add Qwen3.5 dflash model and eval guide

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

---------

Signed-off-by: Xiake Sun <[email protected]>
Co-authored-by: vincentzed <[email protected]>
Co-authored-by: Claude Fable 5.1 <[email protected]>
sammysun0711 added a commit to apinge/sglang that referenced this pull request Nov 3, 2026
…anch (#75)

* [AMD] Allow multimodal CUDA IPC on ROCm in the Qwen3.8 branch

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

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

* [AMD] Complete stream-ordered multimodal IPC support on ROCm

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]>

* fix(multimodal): bound ROCm IPC waits with server watchdog timeout

- 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]>

* eval: enable cuda_ipc for qwen3.8 by default

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

---------

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

Copy link
Copy Markdown
Contributor

Thanks @vincentzed. Closing this because you have 7 PRs open and none updated in 7 days, over our soft cap of 5 for idle PRs.

Reopen the two or three you most want reviewed - a short active set moves faster than a long idle one.

Some directories moved recently, so an older branch may need retargeting:
sgl-kernel/ -> python/sglang/kernels/aot/, python/sglang/jit_kernel/
-> python/sglang/kernels/jit/, docs/ -> docs/docs/ (.mdx),
bench_serving.py -> benchmark/serving.py, test/srt/ -> test/registered/.

@github-actions github-actions Bot closed this Nov 20, 2026
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.

1 participant