Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions docs/accelerators/xpu/xccl_checkpoint_engine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# XCCL checkpoint engine (disaggregated trainer / rollout on Intel GPUs)

verl's `nccl` checkpoint engine cannot run on XPU: it imports cupy and hard-codes `cuda`. This plugin registers a
separate engine under the backend name `xccl` that moves weights over a torch `ProcessGroupXCCL`:

```
actor_rollout_ref.rollout.checkpoint_engine.backend=xccl
```

It needs no Ray collective backend, no cupy and no change to vLLM. Actor rank 0 hosts a `TCPStore`, publishes its
port and a per-round id through the usual `MasterMetadata`, and every rank builds its own `ProcessGroupXCCL` over it;
the default torch.distributed world is left alone. Bucketing, the ZMQ metadata channel and `send_weights` /
`receive_weights` follow the NCCL engine.

Code: `verl_hardware_plugin/accelerators/xpu/engines/xccl_checkpoint_engine.py`, registered from
`verl_hardware_plugin/accelerators/xpu/registration.py`.

## Settings that mattered

Verified once, with the engine living only in this plugin (verl core = upstream main, no XCCL engine in it), using
one-step-off GRPO (`verl.experimental.one_step_off_policy.main_ppo`), 2 trainer + 2 vLLM rollout GPUs on B60,
Qwen2.5-0.5B-Instruct, 3 steps in 333 s: four weight syncs (initial plus one per step; 1.85, 0.86, 0.73 and 0.73 s)
into live vLLM servers, no errors, `multi_sender` at its default, 32 CPUs, 52 GiB host memory.

| Setting | Why |
|---|---|
| At least 32 CPUs on the devctl job | With 16 the Ray rollout placement group (1 GPU + 2 CPU) never schedules (the task runner holds 10 CPUs, the trainer group reserves 6); the run looks hung. |
| `update_weights_bucket_megabytes` >= largest single weight | verl refuses a weight that does not fit (about 544 MB in fp32 for `embed_tokens` of Qwen2.5-0.5B). 1024 was used. |
| `multi_sender` left at its default `False` | With `True` and a real FSDP weight generator the sync stalled after the first bucket: the relay path waits on a host-blocking broadcast while the actor ranks also need each other for the next all-gather. |
| Each Ray worker on its own GPU | Provided by the plugin's `ray_device_pin_patch` (applied from `PlatformXPU.__init__`): the verified run logged `Pinned xpu:0` / `xpu:1` for the trainers and `xpu:2` / `xpu:3` for the checkpoint-engine workers, with `RAY_EXPERIMENTAL_NOSET_ONEAPI_DEVICE_SELECTOR` unset. With the plugin bundled in the 2026-10-02 image (not inspected; its behaviour suggests it lacks this patch) over upstream-main verl core, a vLLM replica shared the trainer's card and the trainer died with `UR_RESULT_ERROR_OUT_OF_RESOURCES`; setting that variable was the workaround there. |

## Swapping the transport later

Only four methods touch the transport: `_start_store`, `_create_process_group`, `_destroy_process_group` and the
module-level `_broadcast`. If Ray ships an XCCL backend in `ray.util.collective` and verl's own `nccl` engine becomes
device-agnostic, the simplest swap is to delete this engine and set `backend=nccl`. A Ray- or vLLM-backed variant would
replace those four methods and leave the bucketing and rank layout alone.

## Not covered

Multi-node (cross-node XCCL has known problems on oneCCL 2022.x), more than 4 GPUs, models above 0.5B, repeated runs.
71 changes: 71 additions & 0 deletions tests/accelerators/xpu/test_xccl_checkpoint_engine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Copyright (c) 2026 BAAI. All rights reserved.
# Licensed under the Apache License, Version 2.0.

"""Rank layout of the XPU XCCL checkpoint engine.

Pure Python: no accelerator and no process group. The module only imports on a
torch build that ships ``ProcessGroupXCCL``, so everything is skipped elsewhere.
Moving real weights over XCCL needs XPU hardware and a vLLM/SGLang rollout; that
is covered by the end-to-end run described in docs/accelerators/xpu/xccl_checkpoint_engine.md.
"""

import pytest

engine = pytest.importorskip(
"verl_hardware_plugin.accelerators.xpu.engines.xccl_checkpoint_engine",
reason="needs a torch build with XPU and ProcessGroupXCCL",
)

MASTER = engine.MasterMetadata(zmq_ip="10.0.0.1", zmq_port=5555, store_port=6666, group_id="g", multi_sender=False)


def _meta(*node_ids, multi_sender=False):
master = engine.MasterMetadata(
zmq_ip=MASTER.zmq_ip,
zmq_port=MASTER.zmq_port,
store_port=MASTER.store_port,
group_id=MASTER.group_id,
multi_sender=multi_sender,
)
return [engine.WorkerMetadata(node_id=n, master=master if i == 0 else None) for i, n in enumerate(node_ids)]


def test_registered_under_xccl():
from verl.checkpoint_engine import CheckpointEngineRegistry

assert CheckpointEngineRegistry.get("xccl") is engine.XCCLCheckpointEngine


def test_multi_sender_is_off_by_default():
import inspect

default = inspect.signature(engine.XCCLCheckpointEngine.__init__).parameters["multi_sender"].default
assert default is False


def test_single_sender_only_actor_rank0_joins():
actor_kwargs, rollout_kwargs = engine.XCCLCheckpointEngine.build_topology(
actor_wg_world_size=2, rollout_world_size=2, metadata=_meta("a", "a")
)
assert actor_kwargs["rank"] == [0, -1]
assert rollout_kwargs["rank"] == [1, 2]
assert actor_kwargs["world_size"] == [3, 3]
assert rollout_kwargs["num_senders"] == [1, 1]


def test_multi_sender_admits_same_node_actors_only():
actor_kwargs, rollout_kwargs = engine.XCCLCheckpointEngine.build_topology(
actor_wg_world_size=3, rollout_world_size=2, metadata=_meta("a", "a", "b", multi_sender=True)
)
# actor 1 shares rank 0's node and relays; actor 2 is on another node and sits out
assert actor_kwargs["rank"] == [0, 1, -1]
assert rollout_kwargs["rank"] == [2, 3]
assert actor_kwargs["num_senders"] == [2, 2, 2]


def test_multi_sender_degrades_to_single_when_no_local_peers():
actor_kwargs, rollout_kwargs = engine.XCCLCheckpointEngine.build_topology(
actor_wg_world_size=2, rollout_world_size=1, metadata=_meta("a", "b", multi_sender=True)
)
assert actor_kwargs["rank"] == [0, -1]
assert rollout_kwargs["rank"] == [1]
Loading
Loading