Skip to content

[rollout, sglang] feat: support sglang ROCm backend via aiter defaults and ray init env - #1

Open
xiaohong42 wants to merge 1 commit into
mainfrom
feat/sglang-rocm-aiter-default
Open

[rollout, sglang] feat: support sglang ROCm backend via aiter defaults and ray init env#1
xiaohong42 wants to merge 1 commit into
mainfrom
feat/sglang-rocm-aiter-default

Conversation

@xiaohong42

@xiaohong42 xiaohong42 commented Jun 9, 2026

Copy link
Copy Markdown
Owner

What does this PR do?

Enable the SGLang rollout backend to run out-of-the-box on AMD ROCm GPUs.

On ROCm (torch.version.hip is not None), this PR:

  1. Defaults the SGLang attention backend to aiter when the user has not explicitly set one (previously it fell through to flashinfer/fa3).
  2. Defaults SGLANG_USE_AITER=1 via os.environ.setdefault, so the non-attention kernels (RMSNorm / RoPE / MoE / quant) also take the AITER path. This is decoupled from the attention backend selection and is set for ROCm regardless of which attention backend is chosen.
  3. Injects RAY_ACCEL_ENV_VAR_OVERRIDE_ON_ZERO=0 into PPO_RAY_RUNTIME_ENV so Ray 2.x does not force-clear accelerator visibility for the num_gpus=0 SGLang server actor (otherwise the actor sees no GPU).

All three are scoped to ROCm and remain user-overridable: an explicit engine_kwargs.sglang.attention_backend or an exported SGLANG_USE_AITER still win, and CUDA / NPU behavior is unchanged.

Checklist Before Starting

Test

Validated on AMD ROCm (MI3xx). Both rollout integration paths train end-to-end:

  • Colocate (main_ppo, GRPO + SGLang): ran launch_smoke_qwen3_8b.sh.
  • Fully async (fully_async_policy, SGLang): ran dapo_7b_math_fsdp2_4_4.sh.

Both smoke runs complete the training steps successfully. The SGLang server log shows the expected ROCm detected: attention_backend=aiter, SGLANG_USE_AITER=1.

CI does not cover this change because it requires ROCm hardware (AITER kernels + HIP visibility); the existing CPU/CUDA CI cannot exercise the ROCm path.

API and Usage Example

No API changes. The new behavior is automatic on ROCm and overridable:

# Default on ROCm: attention_backend=aiter, SGLANG_USE_AITER=1 (auto)

# Override the attention backend (SGLANG_USE_AITER still defaults to 1):
... +actor_rollout_ref.rollout.engine_kwargs.sglang.attention_backend=triton

# Fall back to vLLM RMSNorm/RoPE kernels by disabling AITER explicitly:
export SGLANG_USE_AITER=0

Design & Code Changes

  • verl/workers/rollout/sglang_rollout/async_sglang_server.py
    • ROCm -> default attention_backend="aiter" when unset.
    • Set SGLANG_USE_AITER=1 via setdefault, decoupled from the attention backend, plus an info log of the resolved values.
  • verl/trainer/constants_ppo.py
    • On ROCm, add RAY_ACCEL_ENV_VAR_OVERRIDE_ON_ZERO=0 to PPO_RAY_RUNTIME_ENV (conditional dict, mirroring the existing _gb200_nccl_env pattern).

Checklist Before Submitting

  • Read the Contribute Guide.
  • Apply pre-commit checks (pre-commit run --files <changed files> --show-diff-on-failure --color=always): all hooks pass.
  • Add / Update the documentation. — No docs change; behavior is auto + overridable and described above.
  • Add unit or end-to-end test(s) ... If not feasible, explain why: requires ROCm hardware; validated manually (see Test).
  • Once your PR is ready for CI, send a message in the ci-request channel. — To be done when opening the upstream PR.
  • Not related to the recipe submodule.

…s and ray init env

On ROCm (torch.version.hip is not None), default the SGLang attention
backend to "aiter" when the user has not set one. The non-attention
kernels (RMSNorm/RoPE/MoE/quant) are routed through AITER via
SGLANG_USE_AITER, which is now injected through the platform abstraction
(PlatformROCm.rollout_env_vars()) instead of os.environ.setdefault: the
SGLang server actor's runtime_env consumes get_platform().rollout_env_vars()
and ray_noset_envvars(), mirroring the vLLM/trtllm rollout servers. Both
remain overridable: an explicit engine_kwargs.sglang.attention_backend or
an exported SGLANG_USE_AITER still win.

Also inject RAY_ACCEL_ENV_VAR_OVERRIDE_ON_ZERO=0 into PPO_RAY_RUNTIME_ENV
on ROCm so Ray 2.x does not force-clear accelerator visibility for the
num_gpus=0 SGLang server actor (otherwise the actor sees no GPU). Scoped
to ROCm to keep Ray's default behavior on other platforms.

AI assistance (Cursor) was used; the change was reviewed line-by-line.

Co-authored-by: Cursor <cursor@cursor.com>
Signed-off-by: xiaohong42 <940683523@qq.com>
@xiaohong42
xiaohong42 force-pushed the feat/sglang-rocm-aiter-default branch from 0cbf93f to d21601c Compare June 12, 2026 08:14
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