[vllm] fix: verl + vllm-ascend(version 0.9.1) running failed issue#2782
[vllm] fix: verl + vllm-ascend(version 0.9.1) running failed issue#2782vermouth1992 merged 2 commits intoverl-project:mainfrom
Conversation
Signed-off-by: leo-pony <nengjunma@outlook.com>
There was a problem hiding this comment.
Code Review
This pull request refactors the vLLM patching logic to resolve a type hint incompatibility issue when using verl with vllm-ascend. By moving the patch_vllm_moe_model_weight_loader function to a new vllm_patch.py module and deferring its import until it's needed, the change ensures that hardware-specific patches from vllm-ascend are applied before any vLLM models are imported by verl, which fixes the runtime error. The overall approach is sound. I've identified a critical issue in the new vllm_patch.py module that could lead to runtime errors and have provided a detailed comment with a suggested fix.
|
LGTM! |
Signed-off-by: leo-pony <nengjunma@outlook.com>
|
@vermouth1992 |
…erl-project#2782) ### What does this PR do? > Handle the use case of verl + vllm + vllm-ascend(v0.9.1), detail information see verl-project#2564 vllm-ascend v0.9.1 is the next upcoming commercial release branch, with the previous commercial release branch is vllm-ascend v0.7.3. ### Checklist Before Starting - [ ] Search for similar PRs. Paste at least one query link here: ... - [x] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI) - `{modules}` include `fsdp`, `megatron`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data` - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]` - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test` - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title. - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching` ### Test > Test on ascend npu: GRPO, FSDP backend, Qwen2.5-0.5B mode. ### API and Usage Example > No changes ### Design & Code Changes #### vllm+vllm-ascend(v0.9.1) normal use case: In vllm 0.7.3 uses pytorch2.5.1, and the type hint for infer_schema of mode is List[int]. vllm 0.9.1 uses pytorch 2.7, and to keep consistence with pytorch2.7, and vllm changed hint type to list[int] to infer_schema of mode. Type hint List[int] and list[int] is not compatible. <img width="754" height="434" alt="image" src="https://github.com/user-attachments/assets/40a40e4f-6092-4d89-baff-95c88437a13b" /> vllm-ascend version 0.9.1 needs to be used in conjunction with vllm 0.9.1. But vllm-ascend 0.9.1 max supportted pytorch version is 2.5.1. As pytorch 2.5.1 using List[int] as type hint, vllm-ascend needs add patch to infer_schema of mode to successfully running in pytorch 2.5.1 environment. The patch workflow as following graph display. As vllm hardware limits, vllm-ascend currently patch type hint list[int] during vllm LLM instance creating process. This is okay for most vllm-ascend applications. #### vllm+vllm-ascend(v0.9.1) currently workflow in verl: For verl+vllm-ascend+pytorch2.5.1 there has a problem, as following: verl currently import vllm modes before create vllm LLM instance operation. So error take place: pass list[int] to infer_schema which needs List[int], and then running failed. <img width="954" height="660" alt="image" src="https://github.com/user-attachments/assets/844631b5-1d60-4412-9feb-4324d80d415d" /> #### workflow in this PR in verl to handle hint type mismatch issue: Actully patch_vllm_moe_model_weight_loader is after the operation of LLM create. "import vllm modes" action just been prematurely executed during _build_rollout processing, just file becasue vllm_utils.py in which there has another functions that needs by _build_rollout, by the way those functions been imported, vllm mode been imported. Lets vllm-hardware plugins makes it's patchs take effect, then this problem fixed: move patch_vllm_moe_model_weight_loader funciton to independent file, and import patch_vllm_moe_model_weight_loader just before wight loader patching operation.  ### Checklist Before Submitting > [!IMPORTANT] > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review. - [ ] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). - [ ] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always` - [ ] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs). - [ ] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ... - [ ] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). (If not accessible, please try [the Feishu group (飞书群)](https://applink.larkoffice.com/client/chat/chatter/add_by_link?link_token=772jd4f1-cd91-441e-a820-498c6614126a).) --------- Signed-off-by: leo-pony <nengjunma@outlook.com>
…erl-project#2782) ### What does this PR do? > Handle the use case of verl + vllm + vllm-ascend(v0.9.1), detail information see verl-project#2564 vllm-ascend v0.9.1 is the next upcoming commercial release branch, with the previous commercial release branch is vllm-ascend v0.7.3. ### Checklist Before Starting - [ ] Search for similar PRs. Paste at least one query link here: ... - [x] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI) - `{modules}` include `fsdp`, `megatron`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data` - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]` - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test` - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title. - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching` ### Test > Test on ascend npu: GRPO, FSDP backend, Qwen2.5-0.5B mode. ### API and Usage Example > No changes ### Design & Code Changes #### vllm+vllm-ascend(v0.9.1) normal use case: In vllm 0.7.3 uses pytorch2.5.1, and the type hint for infer_schema of mode is List[int]. vllm 0.9.1 uses pytorch 2.7, and to keep consistence with pytorch2.7, and vllm changed hint type to list[int] to infer_schema of mode. Type hint List[int] and list[int] is not compatible. <img width="754" height="434" alt="image" src="https://github.com/user-attachments/assets/40a40e4f-6092-4d89-baff-95c88437a13b" /> vllm-ascend version 0.9.1 needs to be used in conjunction with vllm 0.9.1. But vllm-ascend 0.9.1 max supportted pytorch version is 2.5.1. As pytorch 2.5.1 using List[int] as type hint, vllm-ascend needs add patch to infer_schema of mode to successfully running in pytorch 2.5.1 environment. The patch workflow as following graph display. As vllm hardware limits, vllm-ascend currently patch type hint list[int] during vllm LLM instance creating process. This is okay for most vllm-ascend applications. #### vllm+vllm-ascend(v0.9.1) currently workflow in verl: For verl+vllm-ascend+pytorch2.5.1 there has a problem, as following: verl currently import vllm modes before create vllm LLM instance operation. So error take place: pass list[int] to infer_schema which needs List[int], and then running failed. <img width="954" height="660" alt="image" src="https://github.com/user-attachments/assets/844631b5-1d60-4412-9feb-4324d80d415d" /> #### workflow in this PR in verl to handle hint type mismatch issue: Actully patch_vllm_moe_model_weight_loader is after the operation of LLM create. "import vllm modes" action just been prematurely executed during _build_rollout processing, just file becasue vllm_utils.py in which there has another functions that needs by _build_rollout, by the way those functions been imported, vllm mode been imported. Lets vllm-hardware plugins makes it's patchs take effect, then this problem fixed: move patch_vllm_moe_model_weight_loader funciton to independent file, and import patch_vllm_moe_model_weight_loader just before wight loader patching operation.  ### Checklist Before Submitting > [!IMPORTANT] > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review. - [ ] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). - [ ] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always` - [ ] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs). - [ ] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ... - [ ] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). (If not accessible, please try [the Feishu group (飞书群)](https://applink.larkoffice.com/client/chat/chatter/add_by_link?link_token=772jd4f1-cd91-441e-a820-498c6614126a).) --------- Signed-off-by: leo-pony <nengjunma@outlook.com>
…3345) ### What does this PR do? After [pr#3285](19020f6), [issue 2564](#2564) began to reappear. Following the modification of [pr#2782](#2782), [issue 2564](#2564) was solved. ### Checklist Before Starting - [x] Search for similar PRs. Paste at least one query link here: [pr#2782](#2782) - [x] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI) - `{modules}` include `fsdp`, `megatron`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data` - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]` - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test` - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title. - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching` ### Test > For changes that can not be tested by CI (e.g., algorithm implementation, new model support), validate by experiment(s) and show results like training curve plots, evaluation results, etc. ### API and Usage Example > Demonstrate how the API changes if any, and provide usage example(s) if possible. ```python # Add code snippet or script demonstrating how to use this ``` ### Design & Code Changes > Demonstrate the high-level design if this PR is complex, and list the specific changes. ### Checklist Before Submitting > [!IMPORTANT] > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review. - [x] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). - [x] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always` - [ ] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs). - [ ] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ... - [ ] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). (If not accessible, please try [the Feishu group (飞书群)](https://applink.larkoffice.com/client/chat/chatter/add_by_link?link_token=772jd4f1-cd91-441e-a820-498c6614126a).)
…erl-project#2782) ### What does this PR do? > Handle the use case of verl + vllm + vllm-ascend(v0.9.1), detail information see verl-project#2564 vllm-ascend v0.9.1 is the next upcoming commercial release branch, with the previous commercial release branch is vllm-ascend v0.7.3. ### Checklist Before Starting - [ ] Search for similar PRs. Paste at least one query link here: ... - [x] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI) - `{modules}` include `fsdp`, `megatron`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data` - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]` - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test` - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title. - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching` ### Test > Test on ascend npu: GRPO, FSDP backend, Qwen2.5-0.5B mode. ### API and Usage Example > No changes ### Design & Code Changes #### vllm+vllm-ascend(v0.9.1) normal use case: In vllm 0.7.3 uses pytorch2.5.1, and the type hint for infer_schema of mode is List[int]. vllm 0.9.1 uses pytorch 2.7, and to keep consistence with pytorch2.7, and vllm changed hint type to list[int] to infer_schema of mode. Type hint List[int] and list[int] is not compatible. <img width="754" height="434" alt="image" src="https://github.com/user-attachments/assets/40a40e4f-6092-4d89-baff-95c88437a13b" /> vllm-ascend version 0.9.1 needs to be used in conjunction with vllm 0.9.1. But vllm-ascend 0.9.1 max supportted pytorch version is 2.5.1. As pytorch 2.5.1 using List[int] as type hint, vllm-ascend needs add patch to infer_schema of mode to successfully running in pytorch 2.5.1 environment. The patch workflow as following graph display. As vllm hardware limits, vllm-ascend currently patch type hint list[int] during vllm LLM instance creating process. This is okay for most vllm-ascend applications. #### vllm+vllm-ascend(v0.9.1) currently workflow in verl: For verl+vllm-ascend+pytorch2.5.1 there has a problem, as following: verl currently import vllm modes before create vllm LLM instance operation. So error take place: pass list[int] to infer_schema which needs List[int], and then running failed. <img width="954" height="660" alt="image" src="https://github.com/user-attachments/assets/844631b5-1d60-4412-9feb-4324d80d415d" /> #### workflow in this PR in verl to handle hint type mismatch issue: Actully patch_vllm_moe_model_weight_loader is after the operation of LLM create. "import vllm modes" action just been prematurely executed during _build_rollout processing, just file becasue vllm_utils.py in which there has another functions that needs by _build_rollout, by the way those functions been imported, vllm mode been imported. Lets vllm-hardware plugins makes it's patchs take effect, then this problem fixed: move patch_vllm_moe_model_weight_loader funciton to independent file, and import patch_vllm_moe_model_weight_loader just before wight loader patching operation.  ### Checklist Before Submitting > [!IMPORTANT] > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review. - [ ] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). - [ ] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always` - [ ] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs). - [ ] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ... - [ ] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). (If not accessible, please try [the Feishu group (飞书群)](https://applink.larkoffice.com/client/chat/chatter/add_by_link?link_token=772jd4f1-cd91-441e-a820-498c6614126a).) --------- Signed-off-by: leo-pony <nengjunma@outlook.com>
…erl-project#3345) ### What does this PR do? After [pr#3285](verl-project@19020f6), [issue 2564](verl-project#2564) began to reappear. Following the modification of [pr#2782](verl-project#2782), [issue 2564](verl-project#2564) was solved. ### Checklist Before Starting - [x] Search for similar PRs. Paste at least one query link here: [pr#2782](verl-project#2782) - [x] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI) - `{modules}` include `fsdp`, `megatron`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data` - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]` - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test` - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title. - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching` ### Test > For changes that can not be tested by CI (e.g., algorithm implementation, new model support), validate by experiment(s) and show results like training curve plots, evaluation results, etc. ### API and Usage Example > Demonstrate how the API changes if any, and provide usage example(s) if possible. ```python # Add code snippet or script demonstrating how to use this ``` ### Design & Code Changes > Demonstrate the high-level design if this PR is complex, and list the specific changes. ### Checklist Before Submitting > [!IMPORTANT] > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review. - [x] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). - [x] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always` - [ ] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs). - [ ] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ... - [ ] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). (If not accessible, please try [the Feishu group (飞书群)](https://applink.larkoffice.com/client/chat/chatter/add_by_link?link_token=772jd4f1-cd91-441e-a820-498c6614126a).)
…erl-project#3345) ### What does this PR do? After [pr#3285](verl-project@19020f6), [issue 2564](verl-project#2564) began to reappear. Following the modification of [pr#2782](verl-project#2782), [issue 2564](verl-project#2564) was solved. ### Checklist Before Starting - [x] Search for similar PRs. Paste at least one query link here: [pr#2782](verl-project#2782) - [x] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI) - `{modules}` include `fsdp`, `megatron`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data` - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]` - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test` - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title. - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching` ### Test > For changes that can not be tested by CI (e.g., algorithm implementation, new model support), validate by experiment(s) and show results like training curve plots, evaluation results, etc. ### API and Usage Example > Demonstrate how the API changes if any, and provide usage example(s) if possible. ```python # Add code snippet or script demonstrating how to use this ``` ### Design & Code Changes > Demonstrate the high-level design if this PR is complex, and list the specific changes. ### Checklist Before Submitting > [!IMPORTANT] > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review. - [x] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). - [x] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always` - [ ] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs). - [ ] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ... - [ ] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). (If not accessible, please try [the Feishu group (飞书群)](https://applink.larkoffice.com/client/chat/chatter/add_by_link?link_token=772jd4f1-cd91-441e-a820-498c6614126a).)
…3345) ### What does this PR do? After [pr#3285](verl-project/verl@4a2d266), [issue 2564](verl-project/verl#2564) began to reappear. Following the modification of [pr#2782](verl-project/verl#2782), [issue 2564](verl-project/verl#2564) was solved. ### Checklist Before Starting - [x] Search for similar PRs. Paste at least one query link here: [pr#2782](verl-project/verl#2782) - [x] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI) - `{modules}` include `fsdp`, `megatron`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data` - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]` - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test` - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title. - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching` ### Test > For changes that can not be tested by CI (e.g., algorithm implementation, new model support), validate by experiment(s) and show results like training curve plots, evaluation results, etc. ### API and Usage Example > Demonstrate how the API changes if any, and provide usage example(s) if possible. ```python # Add code snippet or script demonstrating how to use this ``` ### Design & Code Changes > Demonstrate the high-level design if this PR is complex, and list the specific changes. ### Checklist Before Submitting > [!IMPORTANT] > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review. - [x] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). - [x] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always` - [ ] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs). - [ ] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ... - [ ] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). (If not accessible, please try [the Feishu group (飞书群)](https://applink.larkoffice.com/client/chat/chatter/add_by_link?link_token=772jd4f1-cd91-441e-a820-498c6614126a).)
…erl-project#3345) ### What does this PR do? After [pr#3285](verl-project@19020f6), [issue 2564](verl-project#2564) began to reappear. Following the modification of [pr#2782](verl-project#2782), [issue 2564](verl-project#2564) was solved. ### Checklist Before Starting - [x] Search for similar PRs. Paste at least one query link here: [pr#2782](verl-project#2782) - [x] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI) - `{modules}` include `fsdp`, `megatron`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data` - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]` - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test` - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title. - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching` ### Test > For changes that can not be tested by CI (e.g., algorithm implementation, new model support), validate by experiment(s) and show results like training curve plots, evaluation results, etc. ### API and Usage Example > Demonstrate how the API changes if any, and provide usage example(s) if possible. ```python # Add code snippet or script demonstrating how to use this ``` ### Design & Code Changes > Demonstrate the high-level design if this PR is complex, and list the specific changes. ### Checklist Before Submitting > [!IMPORTANT] > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review. - [x] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). - [x] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always` - [ ] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs). - [ ] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ... - [ ] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). (If not accessible, please try [the Feishu group (飞书群)](https://applink.larkoffice.com/client/chat/chatter/add_by_link?link_token=772jd4f1-cd91-441e-a820-498c6614126a).)
…erl-project#3345) ### What does this PR do? After [pr#3285](verl-project@19020f6), [issue 2564](verl-project#2564) began to reappear. Following the modification of [pr#2782](verl-project#2782), [issue 2564](verl-project#2564) was solved. ### Checklist Before Starting - [x] Search for similar PRs. Paste at least one query link here: [pr#2782](verl-project#2782) - [x] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI) - `{modules}` include `fsdp`, `megatron`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data` - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]` - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test` - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title. - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching` ### Test > For changes that can not be tested by CI (e.g., algorithm implementation, new model support), validate by experiment(s) and show results like training curve plots, evaluation results, etc. ### API and Usage Example > Demonstrate how the API changes if any, and provide usage example(s) if possible. ```python # Add code snippet or script demonstrating how to use this ``` ### Design & Code Changes > Demonstrate the high-level design if this PR is complex, and list the specific changes. ### Checklist Before Submitting > [!IMPORTANT] > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review. - [x] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). - [x] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always` - [ ] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs). - [ ] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ... - [ ] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). (If not accessible, please try [the Feishu group (飞书群)](https://applink.larkoffice.com/client/chat/chatter/add_by_link?link_token=772jd4f1-cd91-441e-a820-498c6614126a).)
…erl-project#2782) ### What does this PR do? > Handle the use case of verl + vllm + vllm-ascend(v0.9.1), detail information see verl-project#2564 vllm-ascend v0.9.1 is the next upcoming commercial release branch, with the previous commercial release branch is vllm-ascend v0.7.3. ### Checklist Before Starting - [ ] Search for similar PRs. Paste at least one query link here: ... - [x] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI) - `{modules}` include `fsdp`, `megatron`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data` - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]` - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test` - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title. - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching` ### Test > Test on ascend npu: GRPO, FSDP backend, Qwen2.5-0.5B mode. ### API and Usage Example > No changes ### Design & Code Changes #### vllm+vllm-ascend(v0.9.1) normal use case: In vllm 0.7.3 uses pytorch2.5.1, and the type hint for infer_schema of mode is List[int]. vllm 0.9.1 uses pytorch 2.7, and to keep consistence with pytorch2.7, and vllm changed hint type to list[int] to infer_schema of mode. Type hint List[int] and list[int] is not compatible. <img width="754" height="434" alt="image" src="https://github.com/user-attachments/assets/40a40e4f-6092-4d89-baff-95c88437a13b" /> vllm-ascend version 0.9.1 needs to be used in conjunction with vllm 0.9.1. But vllm-ascend 0.9.1 max supportted pytorch version is 2.5.1. As pytorch 2.5.1 using List[int] as type hint, vllm-ascend needs add patch to infer_schema of mode to successfully running in pytorch 2.5.1 environment. The patch workflow as following graph display. As vllm hardware limits, vllm-ascend currently patch type hint list[int] during vllm LLM instance creating process. This is okay for most vllm-ascend applications. #### vllm+vllm-ascend(v0.9.1) currently workflow in verl: For verl+vllm-ascend+pytorch2.5.1 there has a problem, as following: verl currently import vllm modes before create vllm LLM instance operation. So error take place: pass list[int] to infer_schema which needs List[int], and then running failed. <img width="954" height="660" alt="image" src="https://github.com/user-attachments/assets/844631b5-1d60-4412-9feb-4324d80d415d" /> #### workflow in this PR in verl to handle hint type mismatch issue: Actully patch_vllm_moe_model_weight_loader is after the operation of LLM create. "import vllm modes" action just been prematurely executed during _build_rollout processing, just file becasue vllm_utils.py in which there has another functions that needs by _build_rollout, by the way those functions been imported, vllm mode been imported. Lets vllm-hardware plugins makes it's patchs take effect, then this problem fixed: move patch_vllm_moe_model_weight_loader funciton to independent file, and import patch_vllm_moe_model_weight_loader just before wight loader patching operation.  ### Checklist Before Submitting > [!IMPORTANT] > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review. - [ ] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). - [ ] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always` - [ ] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs). - [ ] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ... - [ ] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). (If not accessible, please try [the Feishu group (飞书群)](https://applink.larkoffice.com/client/chat/chatter/add_by_link?link_token=772jd4f1-cd91-441e-a820-498c6614126a).) --------- Signed-off-by: leo-pony <nengjunma@outlook.com>
…erl-project#3345) ### What does this PR do? After [pr#3285](verl-project@06f449c), [issue 2564](verl-project#2564) began to reappear. Following the modification of [pr#2782](verl-project#2782), [issue 2564](verl-project#2564) was solved. ### Checklist Before Starting - [x] Search for similar PRs. Paste at least one query link here: [pr#2782](verl-project#2782) - [x] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI) - `{modules}` include `fsdp`, `megatron`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data` - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]` - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test` - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title. - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching` ### Test > For changes that can not be tested by CI (e.g., algorithm implementation, new model support), validate by experiment(s) and show results like training curve plots, evaluation results, etc. ### API and Usage Example > Demonstrate how the API changes if any, and provide usage example(s) if possible. ```python # Add code snippet or script demonstrating how to use this ``` ### Design & Code Changes > Demonstrate the high-level design if this PR is complex, and list the specific changes. ### Checklist Before Submitting > [!IMPORTANT] > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review. - [x] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). - [x] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always` - [ ] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs). - [ ] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ... - [ ] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). (If not accessible, please try [the Feishu group (飞书群)](https://applink.larkoffice.com/client/chat/chatter/add_by_link?link_token=772jd4f1-cd91-441e-a820-498c6614126a).)
…3345) ### What does this PR do? After [pr#3285](verl-project/verl@19020f6), [issue 2564](verl-project/verl#2564) began to reappear. Following the modification of [pr#2782](verl-project/verl#2782), [issue 2564](verl-project/verl#2564) was solved. ### Checklist Before Starting - [x] Search for similar PRs. Paste at least one query link here: [pr#2782](verl-project/verl#2782) - [x] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI) - `{modules}` include `fsdp`, `megatron`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data` - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]` - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test` - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title. - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching` ### Test > For changes that can not be tested by CI (e.g., algorithm implementation, new model support), validate by experiment(s) and show results like training curve plots, evaluation results, etc. ### API and Usage Example > Demonstrate how the API changes if any, and provide usage example(s) if possible. ```python # Add code snippet or script demonstrating how to use this ``` ### Design & Code Changes > Demonstrate the high-level design if this PR is complex, and list the specific changes. ### Checklist Before Submitting > [!IMPORTANT] > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review. - [x] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). - [x] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always` - [ ] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs). - [ ] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ... - [ ] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). (If not accessible, please try [the Feishu group (飞书群)](https://applink.larkoffice.com/client/chat/chatter/add_by_link?link_token=772jd4f1-cd91-441e-a820-498c6614126a).)
…erl-project#2782) ### What does this PR do? > Handle the use case of verl + vllm + vllm-ascend(v0.9.1), detail information see verl-project#2564 vllm-ascend v0.9.1 is the next upcoming commercial release branch, with the previous commercial release branch is vllm-ascend v0.7.3. ### Checklist Before Starting - [ ] Search for similar PRs. Paste at least one query link here: ... - [x] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI) - `{modules}` include `fsdp`, `megatron`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data` - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]` - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test` - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title. - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching` ### Test > Test on ascend npu: GRPO, FSDP backend, Qwen2.5-0.5B mode. ### API and Usage Example > No changes ### Design & Code Changes #### vllm+vllm-ascend(v0.9.1) normal use case: In vllm 0.7.3 uses pytorch2.5.1, and the type hint for infer_schema of mode is List[int]. vllm 0.9.1 uses pytorch 2.7, and to keep consistence with pytorch2.7, and vllm changed hint type to list[int] to infer_schema of mode. Type hint List[int] and list[int] is not compatible. <img width="754" height="434" alt="image" src="https://github.com/user-attachments/assets/40a40e4f-6092-4d89-baff-95c88437a13b" /> vllm-ascend version 0.9.1 needs to be used in conjunction with vllm 0.9.1. But vllm-ascend 0.9.1 max supportted pytorch version is 2.5.1. As pytorch 2.5.1 using List[int] as type hint, vllm-ascend needs add patch to infer_schema of mode to successfully running in pytorch 2.5.1 environment. The patch workflow as following graph display. As vllm hardware limits, vllm-ascend currently patch type hint list[int] during vllm LLM instance creating process. This is okay for most vllm-ascend applications. #### vllm+vllm-ascend(v0.9.1) currently workflow in verl: For verl+vllm-ascend+pytorch2.5.1 there has a problem, as following: verl currently import vllm modes before create vllm LLM instance operation. So error take place: pass list[int] to infer_schema which needs List[int], and then running failed. <img width="954" height="660" alt="image" src="https://github.com/user-attachments/assets/844631b5-1d60-4412-9feb-4324d80d415d" /> #### workflow in this PR in verl to handle hint type mismatch issue: Actully patch_vllm_moe_model_weight_loader is after the operation of LLM create. "import vllm modes" action just been prematurely executed during _build_rollout processing, just file becasue vllm_utils.py in which there has another functions that needs by _build_rollout, by the way those functions been imported, vllm mode been imported. Lets vllm-hardware plugins makes it's patchs take effect, then this problem fixed: move patch_vllm_moe_model_weight_loader funciton to independent file, and import patch_vllm_moe_model_weight_loader just before wight loader patching operation.  ### Checklist Before Submitting > [!IMPORTANT] > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review. - [ ] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). - [ ] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always` - [ ] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs). - [ ] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ... - [ ] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). (If not accessible, please try [the Feishu group (飞书群)](https://applink.larkoffice.com/client/chat/chatter/add_by_link?link_token=772jd4f1-cd91-441e-a820-498c6614126a).) --------- Signed-off-by: leo-pony <nengjunma@outlook.com>
…erl-project#3345) ### What does this PR do? After [pr#3285](verl-project@502af49), [issue 2564](verl-project#2564) began to reappear. Following the modification of [pr#2782](verl-project#2782), [issue 2564](verl-project#2564) was solved. ### Checklist Before Starting - [x] Search for similar PRs. Paste at least one query link here: [pr#2782](verl-project#2782) - [x] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI) - `{modules}` include `fsdp`, `megatron`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data` - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]` - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test` - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title. - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching` ### Test > For changes that can not be tested by CI (e.g., algorithm implementation, new model support), validate by experiment(s) and show results like training curve plots, evaluation results, etc. ### API and Usage Example > Demonstrate how the API changes if any, and provide usage example(s) if possible. ```python # Add code snippet or script demonstrating how to use this ``` ### Design & Code Changes > Demonstrate the high-level design if this PR is complex, and list the specific changes. ### Checklist Before Submitting > [!IMPORTANT] > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review. - [x] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). - [x] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always` - [ ] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs). - [ ] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ... - [ ] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). (If not accessible, please try [the Feishu group (飞书群)](https://applink.larkoffice.com/client/chat/chatter/add_by_link?link_token=772jd4f1-cd91-441e-a820-498c6614126a).)
…erl-project#2782) ### What does this PR do? > Handle the use case of verl + vllm + vllm-ascend(v0.9.1), detail information see verl-project#2564 vllm-ascend v0.9.1 is the next upcoming commercial release branch, with the previous commercial release branch is vllm-ascend v0.7.3. ### Checklist Before Starting - [ ] Search for similar PRs. Paste at least one query link here: ... - [x] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI) - `{modules}` include `fsdp`, `megatron`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data` - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]` - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test` - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title. - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching` ### Test > Test on ascend npu: GRPO, FSDP backend, Qwen2.5-0.5B mode. ### API and Usage Example > No changes ### Design & Code Changes #### vllm+vllm-ascend(v0.9.1) normal use case: In vllm 0.7.3 uses pytorch2.5.1, and the type hint for infer_schema of mode is List[int]. vllm 0.9.1 uses pytorch 2.7, and to keep consistence with pytorch2.7, and vllm changed hint type to list[int] to infer_schema of mode. Type hint List[int] and list[int] is not compatible. <img width="754" height="434" alt="image" src="https://github.com/user-attachments/assets/40a40e4f-6092-4d89-baff-95c88437a13b" /> vllm-ascend version 0.9.1 needs to be used in conjunction with vllm 0.9.1. But vllm-ascend 0.9.1 max supportted pytorch version is 2.5.1. As pytorch 2.5.1 using List[int] as type hint, vllm-ascend needs add patch to infer_schema of mode to successfully running in pytorch 2.5.1 environment. The patch workflow as following graph display. As vllm hardware limits, vllm-ascend currently patch type hint list[int] during vllm LLM instance creating process. This is okay for most vllm-ascend applications. #### vllm+vllm-ascend(v0.9.1) currently workflow in verl: For verl+vllm-ascend+pytorch2.5.1 there has a problem, as following: verl currently import vllm modes before create vllm LLM instance operation. So error take place: pass list[int] to infer_schema which needs List[int], and then running failed. <img width="954" height="660" alt="image" src="https://github.com/user-attachments/assets/844631b5-1d60-4412-9feb-4324d80d415d" /> #### workflow in this PR in verl to handle hint type mismatch issue: Actully patch_vllm_moe_model_weight_loader is after the operation of LLM create. "import vllm modes" action just been prematurely executed during _build_rollout processing, just file becasue vllm_utils.py in which there has another functions that needs by _build_rollout, by the way those functions been imported, vllm mode been imported. Lets vllm-hardware plugins makes it's patchs take effect, then this problem fixed: move patch_vllm_moe_model_weight_loader funciton to independent file, and import patch_vllm_moe_model_weight_loader just before wight loader patching operation.  ### Checklist Before Submitting > [!IMPORTANT] > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review. - [ ] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). - [ ] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always` - [ ] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs). - [ ] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ... - [ ] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). (If not accessible, please try [the Feishu group (飞书群)](https://applink.larkoffice.com/client/chat/chatter/add_by_link?link_token=772jd4f1-cd91-441e-a820-498c6614126a).) --------- Signed-off-by: leo-pony <nengjunma@outlook.com>
…erl-project#3345) ### What does this PR do? After [pr#3285](verl-project@01313d2), [issue 2564](verl-project#2564) began to reappear. Following the modification of [pr#2782](verl-project#2782), [issue 2564](verl-project#2564) was solved. ### Checklist Before Starting - [x] Search for similar PRs. Paste at least one query link here: [pr#2782](verl-project#2782) - [x] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI) - `{modules}` include `fsdp`, `megatron`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data` - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]` - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test` - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title. - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching` ### Test > For changes that can not be tested by CI (e.g., algorithm implementation, new model support), validate by experiment(s) and show results like training curve plots, evaluation results, etc. ### API and Usage Example > Demonstrate how the API changes if any, and provide usage example(s) if possible. ```python # Add code snippet or script demonstrating how to use this ``` ### Design & Code Changes > Demonstrate the high-level design if this PR is complex, and list the specific changes. ### Checklist Before Submitting > [!IMPORTANT] > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review. - [x] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). - [x] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always` - [ ] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs). - [ ] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ... - [ ] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). (If not accessible, please try [the Feishu group (飞书群)](https://applink.larkoffice.com/client/chat/chatter/add_by_link?link_token=772jd4f1-cd91-441e-a820-498c6614126a).)
What does this PR do?
Checklist Before Starting
[{modules}] {type}: {description}(This will be checked by the CI){modules}includefsdp,megatron,sglang,vllm,rollout,trainer,ci,training_utils,recipe,hardware,deployment,ray,worker,single_controller,misc,perf,model,algo,env,tool,ckpt,doc,data,like[megatron, fsdp, doc]{type}is infeat,fix,refactor,chore,test[BREAKING]to the beginning of the title.[BREAKING][fsdp, megatron] feat: dynamic batchingTest
API and Usage Example
Design & Code Changes
vllm+vllm-ascend(v0.9.1) normal use case:
In vllm 0.7.3 uses pytorch2.5.1, and the type hint for infer_schema of mode is List[int]. vllm 0.9.1 uses pytorch 2.7, and to keep consistence with pytorch2.7, and vllm changed hint type to list[int] to infer_schema of mode. Type hint List[int] and list[int] is not compatible.

vllm-ascend version 0.9.1 needs to be used in conjunction with vllm 0.9.1. But vllm-ascend 0.9.1 max supportted pytorch version is 2.5.1. As pytorch 2.5.1 using List[int] as type hint, vllm-ascend needs add patch to infer_schema of mode to successfully running in pytorch 2.5.1 environment. The patch workflow as following graph display.
As vllm hardware limits, vllm-ascend currently patch type hint list[int] during vllm LLM instance creating process. This is okay for most vllm-ascend applications.
vllm+vllm-ascend(v0.9.1) currently workflow in verl:
For verl+vllm-ascend+pytorch2.5.1 there has a problem, as following:

verl currently import vllm modes before create vllm LLM instance operation. So error take place: pass list[int] to infer_schema which needs List[int], and then running failed.
workflow in this PR in verl to handle hint type mismatch issue:
Actully patch_vllm_moe_model_weight_loader is after the operation of LLM create. "import vllm modes" action just been prematurely executed during _build_rollout processing, just file becasue vllm_utils.py in which there has another functions that needs by _build_rollout, by the way those functions been imported, vllm mode been imported. Lets vllm-hardware plugins makes it's patchs take effect, then this problem fixed: move patch_vllm_moe_model_weight_loader funciton to independent file, and import patch_vllm_moe_model_weight_loader just before wight loader patching operation.

Checklist Before Submitting
Important
Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review.
pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=alwaysci-requestchannel in theverlSlack workspace. (If not accessible, please try the Feishu group (飞书群).)