Skip to content

Conversation

@hongpeng-guo
Copy link
Collaborator

@hongpeng-guo hongpeng-guo commented May 7, 2025

Checklist Before Starting

  • Search for similar PR(s).

What does this PR do?

Today, extending verl in proprietary usage large requires forking it, and padding code changes in the private fork.
For example, the current verl API doesn't support adding new Dispatch and Execute mode in runtime. The only way to achieve it is to make a new private fork.

This PR replace the static Enum type of Dispatch and Execute into a new "DynamicEnum" type, that the users can use new APIs register_dispatch_mode and update_dispatch_mode to adding and define new distributed mode at runtime using native verl API, instead of making a fork.

Specific Changes

  • Defined DynamicEnum class in utils.py_functional.py;
  • Re-defined Dispatch and Execute classes, all existing Enum API and usage are still usbale;
  • Added register_dispatch_mode and update_dispatch_mode for users to register new dispatch modes at runtime;
  • nit: pre-commit automatically fixed part of code format in another PR fix: ray worker exit with SYSTEM_ERROR caused by SIGALRM from math re… #1331

Usage Example

Provide usage example(s) for easier usage.

def test_register_new_dispatch_mode():
    # Test registration
    def dummy_dispatch(worker_group, *args, **kwargs):
        return args, kwargs

    def dummy_collect(worker_group, output):
        return output

    register_dispatch_mode("TEST_MODE", dummy_dispatch, dummy_collect)

    # Verify enum extension
    _check_dispatch_mode(Dispatch.TEST_MODE)

    # Verify registry update
    assert get_predefined_dispatch_fn(Dispatch.TEST_MODE) == {"dispatch_fn": dummy_dispatch, "collect_fn": dummy_collect}

Test

Added tests/verl/test_decorator.py

Checklist Before Submitting

  • Read the Contribute Guide.
  • Apply pre-commit checks.
  • Add [BREAKING] to the PR title if it breaks any API.
  • Update the documentation about your changes in the docs.
  • Add CI test(s) if neccessary.

@hongpeng-guo hongpeng-guo changed the title WIP [single_controller][decorator] Define a DynamicEnum class to make Dispatch and Execute extensible. [single_controller][decorator] Define a DynamicEnum class to make Dispatch and Execute extensible. May 7, 2025
@hongpeng-guo hongpeng-guo changed the title [single_controller][decorator] Define a DynamicEnum class to make Dispatch and Execute extensible. WIP[single_controller][decorator] Define a DynamicEnum class to make Dispatch and Execute extensible. May 7, 2025
@hongpeng-guo hongpeng-guo marked this pull request as draft May 7, 2025 06:04
Signed-off-by: Hongpeng Guo <[email protected]>
Signed-off-by: Hongpeng Guo <[email protected]>
@hongpeng-guo hongpeng-guo self-assigned this May 7, 2025
Signed-off-by: Hongpeng Guo <[email protected]>
@hongpeng-guo hongpeng-guo changed the title WIP[single_controller][decorator] Define a DynamicEnum class to make Dispatch and Execute extensible. [single_controller][decorator] Define a DynamicEnum class to make Dispatch and Execute extensible. May 7, 2025
@hongpeng-guo hongpeng-guo marked this pull request as ready for review May 7, 2025 18:01
Signed-off-by: Hongpeng Guo <[email protected]>
tongyx361
tongyx361 previously approved these changes May 7, 2025
@tongyx361 tongyx361 merged commit 8cac3f8 into volcengine:main May 8, 2025
28 checks passed
@eric-haibin-lin eric-haibin-lin mentioned this pull request May 8, 2025
33 tasks
@hongpeng-guo hongpeng-guo deleted the hpguo/extend_decorator branch October 2, 2025 04:21
chenjiaoAngel added a commit to chenjiaoAngel/verl that referenced this pull request Nov 14, 2025
…Dispatch` and `Execute` extensible. (volcengine#1424)

### Checklist Before Starting

- [x] Search for similar PR(s).

### What does this PR do?

Today, extending `verl` in proprietary usage large requires forking it,
and padding code changes in the private fork.
For example, the current `verl` API doesn't support adding new
`Dispatch` and `Execute` mode in runtime. The only way to achieve it is
to make a new private fork.

This PR replace the static `Enum` type of `Dispatch` and `Execute` into
a new `"DynamicEnum"` type, that the users can use new APIs
`register_dispatch_mode` and `update_dispatch_mode` to adding and define
new distributed mode at runtime using native `verl` API, instead of
making a fork.


### Specific Changes

* Defined `DynamicEnum` class in `utils.py_functional.py`;
* Re-defined `Dispatch` and `Execute` classes, all existing Enum API and
usage are still usbale;
* Added `register_dispatch_mode` and `update_dispatch_mode` for users to
register new dispatch modes at runtime;
* nit: `pre-commit` automatically fixed part of code format in another
PR volcengine#1331

### Usage Example

> Provide usage example(s) for easier usage.

```python
def test_register_new_dispatch_mode():
    # Test registration
    def dummy_dispatch(worker_group, *args, **kwargs):
        return args, kwargs

    def dummy_collect(worker_group, output):
        return output

    register_dispatch_mode("TEST_MODE", dummy_dispatch, dummy_collect)

    # Verify enum extension
    _check_dispatch_mode(Dispatch.TEST_MODE)

    # Verify registry update
    assert get_predefined_dispatch_fn(Dispatch.TEST_MODE) == {"dispatch_fn": dummy_dispatch, "collect_fn": dummy_collect}
```

### Test

Added `tests/verl/test_decorator.py`

### Checklist Before Submitting

- [x] Read the [Contribute
Guide](https://github.com/volcengine/verl?tab=readme-ov-file#contribution-guide).
- [x] Apply [pre-commit
checks](https://github.com/volcengine/verl?tab=readme-ov-file#code-linting-and-formatting).
- [ ] Add `[BREAKING]` to the PR title if it breaks any API.
- [ ] Update the documentation about your changes in the
[docs](https://github.com/volcengine/verl/tree/main/docs).
- [x] Add CI test(s) if neccessary.

---------

Signed-off-by: Hongpeng Guo <[email protected]>
TimurTaepov pushed a commit to giorgossideris/verl that referenced this pull request Dec 20, 2025
…Dispatch` and `Execute` extensible. (volcengine#1424)

### Checklist Before Starting

- [x] Search for similar PR(s).

### What does this PR do?

Today, extending `verl` in proprietary usage large requires forking it,
and padding code changes in the private fork.
For example, the current `verl` API doesn't support adding new
`Dispatch` and `Execute` mode in runtime. The only way to achieve it is
to make a new private fork.

This PR replace the static `Enum` type of `Dispatch` and `Execute` into
a new `"DynamicEnum"` type, that the users can use new APIs
`register_dispatch_mode` and `update_dispatch_mode` to adding and define
new distributed mode at runtime using native `verl` API, instead of
making a fork.


### Specific Changes

* Defined `DynamicEnum` class in `utils.py_functional.py`;
* Re-defined `Dispatch` and `Execute` classes, all existing Enum API and
usage are still usbale;
* Added `register_dispatch_mode` and `update_dispatch_mode` for users to
register new dispatch modes at runtime;
* nit: `pre-commit` automatically fixed part of code format in another
PR volcengine#1331

### Usage Example

> Provide usage example(s) for easier usage.

```python
def test_register_new_dispatch_mode():
    # Test registration
    def dummy_dispatch(worker_group, *args, **kwargs):
        return args, kwargs

    def dummy_collect(worker_group, output):
        return output

    register_dispatch_mode("TEST_MODE", dummy_dispatch, dummy_collect)

    # Verify enum extension
    _check_dispatch_mode(Dispatch.TEST_MODE)

    # Verify registry update
    assert get_predefined_dispatch_fn(Dispatch.TEST_MODE) == {"dispatch_fn": dummy_dispatch, "collect_fn": dummy_collect}
```

### Test

Added `tests/verl/test_decorator.py`

### Checklist Before Submitting

- [x] Read the [Contribute
Guide](https://github.com/volcengine/verl?tab=readme-ov-file#contribution-guide).
- [x] Apply [pre-commit
checks](https://github.com/volcengine/verl?tab=readme-ov-file#code-linting-and-formatting).
- [ ] Add `[BREAKING]` to the PR title if it breaks any API.
- [ ] Update the documentation about your changes in the
[docs](https://github.com/volcengine/verl/tree/main/docs).
- [x] Add CI test(s) if neccessary.

---------

Signed-off-by: Hongpeng Guo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants