-
Notifications
You must be signed in to change notification settings - Fork 168
[feat]: verl patches for vllm 13 compatibility #4713
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
Merged
yeshsurya
merged 17 commits into
main
from
yeshwanth/torch_and_dep_upgrade_in_environment
Jan 9, 2026
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b97de06
[feat]: Update torch for vllm upgrade and verl patches for compatibility
yeshsurya dc9276a
[feat]: upgrade ray required from 2 node test
yeshsurya b807ec6
[update]: flash attention build giving layers post torch upgrade
yeshsurya 83a6888
[update]: set max procs to 4 for build pool memory limitation
yeshsurya b48de70
[test]: upgrade pip since seeing build failure only in build ci
yeshsurya a2532d8
[update]: force flash attention build since it fails in ci/cd build
yeshsurya f86119f
[update]: reduce thread for ci/cd pool's memory constraint
yeshsurya 22f79ed
[update]: trying flash attn build with one thread
yeshsurya 846dbd6
[test]: limit nvcc threads to 1
yeshsurya 859632f
[test]: jobs 4 nvcc thread to 1
yeshsurya 0128344
[test]: 2 main threads 1 nvcc thread
yeshsurya 8b9f7fa
[test]: one thread build with increased timeout
yeshsurya d4747f9
[test]: Increased timeout to 4 hrs
yeshsurya 4cc20a5
[test]: double the timeout
yeshsurya 1e2b001
[test]: Adjust other timeouts for giving more time to build
yeshsurya 10fd7b7
[update]: removed flash attention
yeshsurya f6e4264
[update]: reverting the build.py changes
yeshsurya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
assets/training/finetune_acft_hf_nlp/environments/acpt-rft/context/utils
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| from msgspec import field | ||
| from packaging import version as vs | ||
| from vllm.lora.lora_model import LoRAModel | ||
| from vllm.lora.request import LoRARequest | ||
| from vllm.lora.utils import get_adapter_absolute_path | ||
| from vllm.lora.worker_manager import LRUCacheWorkerLoRAManager | ||
|
|
||
| from verl.third_party.vllm import get_version | ||
|
|
||
|
|
||
| class TensorLoRARequest(LoRARequest): | ||
| peft_config: dict = field(default=None) | ||
| lora_tensors: dict = field(default=None) | ||
|
|
||
|
|
||
| class VLLMHijack: | ||
| @staticmethod | ||
| def hijack(): | ||
| def hijack__load_adapter(self, lora_request: TensorLoRARequest) -> LoRAModel: | ||
| """ | ||
| based on vllm.lora.worker_manager.WorkerLoRAManager._load_adapter, support load adapter with lora tensors | ||
|
|
||
| Reason: | ||
| VLLM does not support adding LoRA from tensors directly. It only supports adding LoRA via file paths. | ||
| To synchronize the LoRA tensors of the actor model, we need to find a workaround to enable VLLM to | ||
| load memory-based LoRA tensors. | ||
| """ | ||
| try: | ||
| supported_lora_modules = self._adapter_manager.supported_lora_modules | ||
| packed_modules_mapping = self._adapter_manager.packed_modules_mapping | ||
| expected_lora_modules: list[str] = [] | ||
| for module in supported_lora_modules: | ||
| if module in packed_modules_mapping: | ||
| expected_lora_modules.extend(packed_modules_mapping[module]) | ||
| else: | ||
| expected_lora_modules.append(module) | ||
|
|
||
| expected_lora_modules = list(set(expected_lora_modules)) | ||
|
|
||
| lora_tensors = None | ||
| from vllm.lora.peft_helper import PEFTHelper | ||
|
|
||
| if isinstance(lora_request, TensorLoRARequest): | ||
| peft_config = lora_request.peft_config | ||
| lora_tensors = lora_request.lora_tensors | ||
| peft_helper = PEFTHelper.from_dict(peft_config) | ||
| else: | ||
| lora_path = get_adapter_absolute_path(lora_request.lora_path) | ||
|
|
||
| peft_helper = PEFTHelper.from_local_dir(lora_path, self.max_position_embeddings) | ||
|
|
||
| # Validates the LoRA configuration against requirements before | ||
| # loading weights, throwing an exception if validation fails. | ||
| peft_helper.validate_legal(self.lora_config) | ||
|
|
||
| # For some models like Qwen2VL, we need to use hf_to_vllm_mapper | ||
| # to ensure correct loading of lora weights. | ||
| model = self._adapter_manager.model | ||
| hf_to_vllm_mapper = None | ||
| if hasattr(model, "hf_to_vllm_mapper") and model.hf_to_vllm_mapper is not None: | ||
| hf_to_vllm_mapper = model.hf_to_vllm_mapper | ||
| # vLLM 0.13.0 compatibility: lora_extra_vocab_size was removed | ||
| lora_extra_vocab_size = getattr(self.lora_config, 'lora_extra_vocab_size', 0) | ||
|
|
||
| # vLLM 0.13.0 compatibility: embedding_padding_modules may not exist | ||
| embedding_padding_modules = getattr(self, 'embedding_padding_modules', {}) | ||
| if isinstance(lora_request, TensorLoRARequest): | ||
| print(f"Lora module class is {self._lora_model_cls}") | ||
| lora = self._lora_model_cls.from_lora_tensors( | ||
| lora_model_id=lora_request.lora_int_id, | ||
| tensors=lora_tensors, | ||
| peft_helper=peft_helper, | ||
| device="cpu", | ||
| dtype=self.lora_config.lora_dtype, | ||
| model_vocab_size=self.vocab_size + lora_extra_vocab_size, | ||
| weights_mapper=hf_to_vllm_mapper, | ||
| ) | ||
| else: | ||
| lora = self._lora_model_cls.from_local_checkpoint( | ||
| lora_path, | ||
| expected_lora_modules, | ||
| peft_helper=peft_helper, | ||
| lora_model_id=lora_request.lora_int_id, | ||
| device="cpu", | ||
| dtype=self.lora_config.lora_dtype, | ||
| target_embedding_padding=self.vocab_size + lora_extra_vocab_size, | ||
| embedding_modules=self.embedding_modules, | ||
| embedding_padding_modules=embedding_padding_modules, | ||
| weights_mapper=hf_to_vllm_mapper, | ||
| ) | ||
| except Exception as e: | ||
| raise e | ||
|
|
||
| return lora | ||
|
|
||
| def do_hijack(target_cls, target_method_name, hooking_method): | ||
| setattr(target_cls, target_method_name, hooking_method) | ||
|
|
||
| do_hijack(LRUCacheWorkerLoRAManager, "_load_adapter", hijack__load_adapter) | ||
|
|
||
|
|
||
| def is_version_ge(pkg: str = "vllm", minver: str = "0.7.3"): | ||
| """check if the package version is greater than or equal to the minimum version""" | ||
| return vs.parse(get_version(pkg)) >= vs.parse(minver) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.