verl icon indicating copy to clipboard operation
verl copied to clipboard

Need to update get_vllm_max_lora_rank

Open YuchuanW opened this issue 10 months ago • 4 comments

System Info

Environment: verl: 0.8.0.dev0 vllm: 0.11.0 python: 3.12.0 torch: 2.8.0 All packages and the environment installed follow official installation guide at https://verl.readthedocs.io/en/latest/start/install.html

Running a dapo on Qwen3-8B with a locally trained LoRA checkpoint, with vLLM as the rollout engine, the following error occurred: ImportError: cannot import name 'MaxLoRARanks' from 'vllm.config.lora'

And this is caused by an incompatibility between the current verl codebase and newer versions of vLLM. And if I tried to downgrade vllm, other errors will occur In /home/user/verl/verl/workers/rollout/vllm_rollout/utils.py


def get_vllm_max_lora_rank(lora_rank: int): """ For vLLM, automatically adjusts the max_lora_rank to the nearest allowed value. The allowed values are retrieved from vLLM's MaxLoRARanks type definition. """ assert lora_rank > 0, f"lora_rank must be greater than 0, get {lora_rank}" from vllm.config.lora import MaxLoRARanks vllm_max_lora_ranks = sorted(get_args(MaxLoRARanks)) if lora_rank > vllm_max_lora_ranks[-1]: raise ValueError(f"lora_rank must be less than or equal to {vllm_max_lora_ranks[-1]}, but got {lora_rank}") for rank in vllm_max_lora_ranks: if lora_rank <= rank: return rank


While in /home/user/miniconda3/envs/verl/lib/python3.12/site-packages/vllm/config/lora.py No MaxLoRARanks but


def post_init(self): possible_max_ranks = (8, 16, 32, 64, 128, 256, 320, 512) if self.max_lora_rank not in possible_max_ranks: raise ValueError(...)


I solved this by modifying get_vllm_max_lora_rank to:


def get_vllm_max_lora_rank(lora_rank: int): assert lora_rank > 0, f"lora_rank must be greater than 0, got {lora_rank}" vllm_max_lora_ranks = (8, 16, 32, 64, 128, 256, 320, 512) if lora_rank > vllm_max_lora_ranks[-1]: raise ValueError( f"lora_rank must be <= {vllm_max_lora_ranks[-1]}, got {lora_rank}" ) for rank in vllm_max_lora_ranks: if lora_rank <= rank: return rank


Information

  • [ ] The official example scripts
  • [x] My own modified scripts

Tasks

  • [ ] An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • [x] My own task or dataset (give details below)

Reproduction

python -m verl.trainer.main_ppo
data.train_files="${TRAIN_PARQUET}"
data.val_files="${VAL_PARQUET}"
data.prompt_key=prompt
data.truncation=left
data.max_prompt_length=${max_prompt_length}
data.max_response_length=${max_response_length}
data.train_batch_size=${train_prompt_bsz}
actor_rollout_ref.rollout.n=${n_resp_per_prompt}
algorithm.adv_estimator=${adv_estimator}
algorithm.use_kl_in_reward=${use_kl_in_reward}
algorithm.kl_ctrl.kl_coef=${kl_coef}
actor_rollout_ref.actor.use_kl_loss=${use_kl_loss}
actor_rollout_ref.actor.kl_loss_coef=${kl_loss_coef}
actor_rollout_ref.actor.clip_ratio_low=${clip_ratio_low}
actor_rollout_ref.actor.clip_ratio_high=${clip_ratio_high}
actor_rollout_ref.actor.clip_ratio_c=10.0
actor_rollout_ref.model.use_remove_padding=True
actor_rollout_ref.actor.use_dynamic_bsz=${use_dynamic_bsz}
actor_rollout_ref.ref.log_prob_use_dynamic_bsz=${use_dynamic_bsz}
actor_rollout_ref.rollout.log_prob_use_dynamic_bsz=${use_dynamic_bsz}
actor_rollout_ref.actor.ppo_max_token_len_per_gpu=${actor_ppo_max_token_len}
actor_rollout_ref.ref.log_prob_max_token_len_per_gpu=${infer_ppo_max_token_len}
actor_rollout_ref.rollout.log_prob_max_token_len_per_gpu=${infer_ppo_max_token_len}
actor_rollout_ref.rollout.name=vllm
actor_rollout_ref.model.path="${BASE_MODEL}"
actor_rollout_ref.model.lora_adapter_path="${LORA_CKPT}"
actor_rollout_ref.model.lora_rank=16
actor_rollout_ref.model.enable_gradient_checkpointing=True
actor_rollout_ref.actor.optim.lr=1e-6
actor_rollout_ref.actor.optim.lr_warmup_steps=10
actor_rollout_ref.actor.optim.weight_decay=0.1
actor_rollout_ref.actor.ppo_mini_batch_size=${train_prompt_mini_bsz}
actor_rollout_ref.actor.fsdp_config.param_offload=${offload}
actor_rollout_ref.actor.fsdp_config.optimizer_offload=${offload}
actor_rollout_ref.actor.entropy_coeff=0.0
actor_rollout_ref.actor.grad_clip=1.0
actor_rollout_ref.actor.loss_agg_mode=${loss_agg_mode}
actor_rollout_ref.actor.ulysses_sequence_parallel_size=${sp_size}
actor_rollout_ref.rollout.gpu_memory_utilization=0.9
actor_rollout_ref.rollout.tensor_model_parallel_size=${gen_tp}
actor_rollout_ref.rollout.enable_chunked_prefill=True
actor_rollout_ref.rollout.max_num_batched_tokens=$((max_prompt_length + max_response_length))
actor_rollout_ref.rollout.temperature=${temperature}
actor_rollout_ref.rollout.top_p=${top_p}
actor_rollout_ref.rollout.top_k=${top_k}
actor_rollout_ref.rollout.val_kwargs.temperature=${val_temperature}
actor_rollout_ref.rollout.val_kwargs.top_p=${val_top_p}
actor_rollout_ref.rollout.val_kwargs.top_k=${top_k}
actor_rollout_ref.rollout.val_kwargs.n=1
actor_rollout_ref.ref.fsdp_config.param_offload=${offload}
actor_rollout_ref.ref.ulysses_sequence_parallel_size=${sp_size}
actor_rollout_ref.actor.fsdp_config.fsdp_size=${fsdp_size}
reward_model.reward_manager=dapo
+reward_model.reward_kwargs.overlong_buffer_cfg.enable=${enable_overlong_buffer}
+reward_model.reward_kwargs.overlong_buffer_cfg.len=${overlong_buffer_len}
+reward_model.reward_kwargs.overlong_buffer_cfg.penalty_factor=${overlong_penalty_factor}
+reward_model.reward_kwargs.overlong_buffer_cfg.log=False
+reward_model.reward_kwargs.max_resp_len=${max_response_length}
trainer.logger='["console","wandb"]'
trainer.project_name="${project_name}"
trainer.experiment_name="${exp_name}"
trainer.n_gpus_per_node=2
trainer.nnodes=1
trainer.val_before_train=True
trainer.test_freq=1
trainer.save_freq=1
trainer.total_epochs=1
trainer.total_training_steps=50
trainer.default_local_dir="${OUT_DIR}"
trainer.resume_mode=auto
trainer.log_val_generations=10

Expected behavior

Please update the code.

YuchuanW avatar Jan 29 '26 15:01 YuchuanW

I encountered the same error

ccl4wsh avatar Jan 30 '26 08:01 ccl4wsh

我遇到了同样的错误,按照楼主教程成功修复

u1544096979 avatar Jan 31 '26 14:01 u1544096979

i encountered the same error, tried to fix by installing vllm 0.11.2

szhou0202 avatar Feb 01 '26 20:02 szhou0202

中文:这个问题看起来已经在 main 分支中修复了。#5113 报告的根因是 vLLM 0.11.0 的 vllm.config.lora 中没有 MaxLoRARanks,而旧的 verl 代码直接导入它。PR #5115 已在 get_vllm_max_lora_rank 中加入 fallback:当导入 MaxLoRARanks 失败时,verl 会使用允许的 LoRA rank 列表 1, 8, 16, 32, 64, 128, 256, 320, 512。当前 main 分支代码已经包含这个逻辑。

English: This appears to have been fixed on the main branch. The root cause reported in #5113 was that vLLM 0.11.0 no longer exposed MaxLoRARanks from vllm.config.lora, while the older verl code imported it directly. PR #5115 added a fallback in get_vllm_max_lora_rank: if importing MaxLoRARanks fails, verl now uses the allowed LoRA rank list 1, 8, 16, 32, 64, 128, 256, 320, 512. The current main branch already contains this logic.

This response was generated by a scheduled Codex GPT5.5 issue processing task.

Kirrito-k423 avatar Aug 01 '26 01:08 Kirrito-k423