Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BREAKING][core] move single_controller into verl directory #45

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .github/workflows/yapf_format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ jobs:
pip install toml==0.10.2
- name: Running yapf
run: |
yapf -r -vv -d --style=./.style.yapf verl tests single_controller examples
yapf -r -vv -d --style=./.style.yapf verl tests examples
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ pip3 install yapf
```
Then, make sure you are at top level of verl repo and run
```bash
yapf -ir -vv --style ./.style.yapf verl single_controller examples
yapf -ir -vv --style ./.style.yapf verl examples
```


Expand Down
14 changes: 7 additions & 7 deletions docs/advance/dpo_extension.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ Implementation details:

.. code:: python

from single_controller.base import Worker
from single_controller.ray import RayWorkerGroup, RayClassWithInitArgs, RayResourcePool
from verl.single_controller.base import Worker
from verl.single_controller.ray import RayWorkerGroup, RayClassWithInitArgs, RayResourcePool
import ray

@ray.remote
Expand All @@ -75,7 +75,7 @@ API: compute reference log probability

.. code:: python

from single_controller.base import Worker
from verl.single_controller.base import Worker
import ray

@ray.remote
Expand All @@ -93,7 +93,7 @@ API: Update actor model parameters

.. code:: python

from single_controller.base import Worker
from verl.single_controller.base import Worker
import ray

@ray.remote
Expand Down Expand Up @@ -184,7 +184,7 @@ registered into the worker_group**

.. code:: python

from single_controller.base.decorator import register
from verl.single_controller.base.decorator import register

def dispatch_data(worker_group, data):
return data.chunk(worker_group.world_size)
Expand Down Expand Up @@ -214,11 +214,11 @@ computation, and data collection.

Furthermore, the model parallelism size of each model is usually fixed,
including dp, tp, pp. So for these common distributed scenarios, we have
pre-implemented specific dispatch and collect methods,in `decorator.py <https://github.com/volcengine/verl/blob/main/single_controller/base/decorator.py>`_, which can be directly used to wrap the computations.
pre-implemented specific dispatch and collect methods,in `decorator.py <https://github.com/volcengine/verl/blob/main/verl/single_controller/base/decorator.py>`_, which can be directly used to wrap the computations.

.. code:: python

from single_controller.base.decorator import register, Dispatch
from verl.single_controller.base.decorator import register, Dispatch

@register(dispatch_mode=Dispatch.DP_COMPUTE_PROTO)
def generate_sequences(self, data: DataProto) -> DataProto:
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/ppo_code_architecture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ Define worker classes
if config.actor_rollout_ref.actor.strategy == 'fsdp': # for FSDP backend
assert config.actor_rollout_ref.actor.strategy == config.critic.strategy
from verl.trainer.ppo.workers.fsdp_workers import ActorRolloutRefWorker, CriticWorker
from single_controller.ray import RayWorkerGroup
from verl.single_controller.ray import RayWorkerGroup
ray_worker_group_cls = RayWorkerGroup

elif config.actor_rollout_ref.actor.strategy == 'megatron': # for Megatron backend
assert config.actor_rollout_ref.actor.strategy == config.critic.strategy
from verl.trainer.ppo.workers.megatron_workers import ActorRolloutRefWorker, CriticWorker
from single_controller.ray.megatron import NVMegatronRayWorkerGroup
from verl.single_controller.ray.megatron import NVMegatronRayWorkerGroup
ray_worker_group_cls = NVMegatronRayWorkerGroup # Ray worker class for Megatron-LM

else:
Expand Down
2 changes: 1 addition & 1 deletion docs/workers/megatron_workers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ We implement various of APIs for each ``Worker`` class decorated by the
``@register(dispatch_mode=)`` . These APIs can be called by the ray
driver process. The data can be correctly collect and dispatch following
the ``dispatch_mode`` on each function. The supported dispatch_model
(i.e., transfer protocols) can be found in `decorator.py <https://github.com/volcengine/verl/blob/main/single_controller/base/decorator.py>`_.
(i.e., transfer protocols) can be found in `decorator.py <https://github.com/volcengine/verl/blob/main/verl/single_controller/base/decorator.py>`_.

ActorRolloutRefWorker
^^^^^^^^^^^^^^^^^^^^^
Expand Down
16 changes: 8 additions & 8 deletions examples/ray/tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@
},
"outputs": [],
"source": [
"from single_controller.ray.base import RayResourcePool, RayClassWithInitArgs, RayWorkerGroup, merge_resource_pool\n",
"from single_controller.base import Worker"
"from verl.single_controller.ray.base import RayResourcePool, RayClassWithInitArgs, RayWorkerGroup, merge_resource_pool\n",
"from verl.single_controller.base import Worker"
]
},
{
Expand Down Expand Up @@ -437,7 +437,7 @@
},
"outputs": [],
"source": [
"from single_controller.ray.decorator import register, Dispatch, Execute"
"from verl.single_controller.ray.decorator import register, Dispatch, Execute"
]
},
{
Expand Down Expand Up @@ -518,7 +518,7 @@
},
"outputs": [],
"source": [
"from single_controller.ray.decorator import register, Dispatch, collect_all_to_all, Execute"
"from verl.single_controller.ray.decorator import register, Dispatch, collect_all_to_all, Execute"
]
},
{
Expand Down Expand Up @@ -723,10 +723,10 @@
},
"outputs": [],
"source": [
"from single_controller.ray.decorator import register, Dispatch, Execute\n",
"from single_controller.ray.megatron import NVMegatronRayWorkerGroup\n",
"from single_controller.base.megatron.worker import MegatronWorker\n",
"from single_controller.ray.base import RayResourcePool, RayClassWithInitArgs, RayWorkerGroup\n",
"from verl.single_controller.ray.decorator import register, Dispatch, Execute\n",
"from verl.single_controller.ray.megatron import NVMegatronRayWorkerGroup\n",
"from verl.single_controller.base.megatron.worker import MegatronWorker\n",
"from verl.single_controller.ray.base import RayResourcePool, RayClassWithInitArgs, RayWorkerGroup\n",
"from omegaconf import OmegaConf\n",
"from megatron.core import parallel_state as mpu"
]
Expand Down
4 changes: 2 additions & 2 deletions examples/split_placement/main_ppo_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ def main_task(config):
if config.actor_rollout_ref.actor.strategy == 'fsdp':
assert config.actor_rollout_ref.actor.strategy == config.critic.strategy
from verl.trainer.ppo.workers.fsdp_workers import ActorRolloutRefWorker, CriticWorker
from single_controller.ray import RayWorkerGroup
from verl.single_controller.ray import RayWorkerGroup
ray_worker_group_cls = RayWorkerGroup

elif config.actor_rollout_ref.actor.strategy == 'megatron':
assert config.actor_rollout_ref.actor.strategy == config.critic.strategy
from verl.trainer.ppo.workers.megatron_workers import ActorRolloutRefWorker, CriticWorker
from single_controller.ray.megatron import NVMegatronRayWorkerGroup
from verl.single_controller.ray.megatron import NVMegatronRayWorkerGroup
ray_worker_group_cls = NVMegatronRayWorkerGroup

else:
Expand Down
2 changes: 1 addition & 1 deletion examples/split_placement/split_monkey_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"""
import os
from pprint import pprint
from single_controller.ray import RayResourcePool, RayWorkerGroup, RayClassWithInitArgs
from verl.single_controller.ray import RayResourcePool, RayWorkerGroup, RayClassWithInitArgs
from verl import DataProto
from verl.trainer.ppo.ray_trainer import compute_advantage, apply_kl_penalty, reduce_metrics, compute_data_metrics, Role, create_colocated_worker_cls
from codetiming import Timer
Expand Down
6 changes: 3 additions & 3 deletions tests/ray/check_worker_alive/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

import ray

from single_controller.ray.base import RayResourcePool, RayClassWithInitArgs, RayWorkerGroup
from single_controller.base.worker import Worker
from single_controller.base.decorator import register, Dispatch
from verl.single_controller.ray.base import RayResourcePool, RayClassWithInitArgs, RayWorkerGroup
from verl.single_controller.base.worker import Worker
from verl.single_controller.base.decorator import register, Dispatch


@ray.remote
Expand Down
4 changes: 2 additions & 2 deletions tests/ray/detached_worker/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import torch

from verl import DataProto
from single_controller.ray import RayClassWithInitArgs
from single_controller.ray.megatron import NVMegatronRayWorkerGroup
from verl.single_controller.ray import RayClassWithInitArgs
from verl.single_controller.ray.megatron import NVMegatronRayWorkerGroup

from tensordict import TensorDict

Expand Down
8 changes: 4 additions & 4 deletions tests/ray/detached_worker/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
from torch import nn

import ray
from single_controller.ray import RayClassWithInitArgs, RayResourcePool
from single_controller.ray.megatron import NVMegatronRayWorkerGroup
from single_controller.base.megatron.worker import MegatronWorker
from single_controller.ray.decorator import register, Dispatch
from verl.single_controller.ray import RayClassWithInitArgs, RayResourcePool
from verl.single_controller.ray.megatron import NVMegatronRayWorkerGroup
from verl.single_controller.base.megatron.worker import MegatronWorker
from verl.single_controller.ray.decorator import register, Dispatch
from verl import DataProto
from verl.models.llama.megatron import ParallelLlamaForCausalLMRmPadPP

Expand Down
6 changes: 3 additions & 3 deletions tests/ray/test_colocated_workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

import ray

from single_controller.base import Worker
from single_controller.base.decorator import register, Dispatch
from single_controller.ray.base import RayResourcePool, RayClassWithInitArgs, RayWorkerGroup, create_colocated_worker_cls
from verl.single_controller.base import Worker
from verl.single_controller.base.decorator import register, Dispatch
from verl.single_controller.ray.base import RayResourcePool, RayClassWithInitArgs, RayWorkerGroup, create_colocated_worker_cls

from verl import DataProto

Expand Down
6 changes: 3 additions & 3 deletions tests/ray/test_data_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
In this test, we instantiate a data parallel worker with 8 GPUs
"""

from single_controller.base import Worker
from single_controller.ray import RayWorkerGroup, RayClassWithInitArgs, RayResourcePool
from verl.single_controller.base import Worker
from verl.single_controller.ray import RayWorkerGroup, RayClassWithInitArgs, RayResourcePool

from single_controller.base.decorator import Dispatch, register
from verl.single_controller.base.decorator import Dispatch, register

import ray
import torch
Expand Down
6 changes: 3 additions & 3 deletions tests/ray/test_driverfunc_to_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
from verl import DataProto
from tensordict import TensorDict

from single_controller.base.worker import Worker
from single_controller.ray.base import RayResourcePool, RayClassWithInitArgs
from single_controller.ray import RayWorkerGroup
from verl.single_controller.base.worker import Worker
from verl.single_controller.ray.base import RayResourcePool, RayClassWithInitArgs
from verl.single_controller.ray import RayWorkerGroup

os.environ['RAY_DEDUP_LOGS'] = '0'
os.environ['NCCL_DEBUG'] = 'WARN'
Expand Down
4 changes: 2 additions & 2 deletions tests/ray/test_high_level_scheduling_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

import ray

from single_controller.ray.base import RayResourcePool, RayClassWithInitArgs, RayWorkerGroup, merge_resource_pool
from single_controller.base.worker import Worker
from verl.single_controller.ray.base import RayResourcePool, RayClassWithInitArgs, RayWorkerGroup, merge_resource_pool
from verl.single_controller.base.worker import Worker


@ray.remote
Expand Down
8 changes: 4 additions & 4 deletions tests/ray/test_ray_local_envs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""
e2e test single_controller.ray
e2e test verl.single_controller.ray
"""
import os
import ray

from single_controller.ray.base import RayResourcePool, RayClassWithInitArgs, RayWorkerGroup
from single_controller.base.worker import Worker
from single_controller.ray.decorator import register, Dispatch, collect_all_to_all, Execute
from verl.single_controller.ray.base import RayResourcePool, RayClassWithInitArgs, RayWorkerGroup
from verl.single_controller.base.worker import Worker
from verl.single_controller.ray.decorator import register, Dispatch, collect_all_to_all, Execute


@ray.remote
Expand Down
6 changes: 3 additions & 3 deletions tests/ray/test_remote_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from single_controller.remote import remote, RemoteBackend, SharedResourcePool
from single_controller.base.decorator import register, Dispatch
from single_controller.base.worker import Worker
from verl.single_controller.remote import remote, RemoteBackend, SharedResourcePool
from verl.single_controller.base.decorator import register, Dispatch
from verl.single_controller.base.worker import Worker


@remote(process_on_nodes=[3], use_gpu=True, name_prefix="actor", sharing=SharedResourcePool)
Expand Down
8 changes: 4 additions & 4 deletions tests/ray/test_worker_group_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""
e2e test single_controller.ray
e2e test verl.single_controller.ray
"""

import torch
import ray

from single_controller.ray.base import RayResourcePool, RayClassWithInitArgs, RayWorkerGroup
from single_controller.base.worker import Worker
from single_controller.ray.decorator import register, Dispatch, collect_all_to_all, Execute
from verl.single_controller.ray.base import RayResourcePool, RayClassWithInitArgs, RayWorkerGroup
from verl.single_controller.base.worker import Worker
from verl.single_controller.ray.decorator import register, Dispatch, collect_all_to_all, Execute


def two_to_all_dispatch_fn(worker_group, *args, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions tests/ray/test_worker_group_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import torch.distributed
import ray

from single_controller.ray.base import RayResourcePool, RayClassWithInitArgs, RayWorkerGroup
from single_controller.base.worker import Worker
from verl.single_controller.ray.base import RayResourcePool, RayClassWithInitArgs, RayWorkerGroup
from verl.single_controller.base.worker import Worker


@ray.remote
Expand Down
File renamed without changes.
Loading
Loading