[Bug]Qwen3VL 30B training resumption exception, using Megatron backend and hf ckpt.
System Info
----------Python Info---------- Version : 3.11.14 Compiler : GCC 11.2.0 Build : ('main', 'Oct 21 2025 18:31:21') Arch : ('64bit', 'ELF') ------------Pip Info----------- Version : 25.2 Directory : /data/miniconda3/envs/lh_verl_new/lib/python3.11/site-packages/pip vllm : 0.11.0 sglang : not found. ray : 2.50.1 torch : 2.8.0 ----------verl Info----------- Version : 0.7.0.dev Directory : /home/verl/verl/verl Commit Hash : 146075bbd4a7462174f7953c639407940956867b ----------Platform Info---------- Platform : Linux-5.15.0-25-generic-x86_64-with-glibc2.35 system : Linux node : glusterfs-07 release : 5.15.0-25-generic version : #25-Ubuntu SMP Wed Mar 30 15:54:22 UTC 2022 ----------Environment---------- CUDA Runtime : 12.8 CUDA Compiler : Cuda compilation tools, release 12.6, V12.6.85 ----------System Info---------- CPU Memory : 2015.52 GB GPU Count : 8 GPU 1 Type : NVIDIA H100 80GB HBM3 GPU 1 Memory : 79.65 GB GPU 2 Type : NVIDIA H100 80GB HBM3 GPU 2 Memory : 79.65 GB GPU 3 Type : NVIDIA H100 80GB HBM3 GPU 3 Memory : 79.65 GB GPU 4 Type : NVIDIA H100 80GB HBM3 GPU 4 Memory : 79.65 GB GPU 5 Type : NVIDIA H100 80GB HBM3 GPU 5 Memory : 79.65 GB GPU 6 Type : NVIDIA H100 80GB HBM3 GPU 6 Memory : 79.65 GB GPU 7 Type : NVIDIA H100 80GB HBM3 GPU 7 Memory : 79.65 GB GPU 8 Type : NVIDIA H100 80GB HBM3 GPU 8 Memory : 79.65 G
Information
- [ ] The official example scripts
- [x] My own modified scripts
Tasks
- [x] An officially supported task in the
examplesfolder (such as GLUE/SQuAD, ...) - [ ] My own task or dataset (give details below)
Reproduction
ray stop --force
set -x ENGINE=${1:-vllm} export CUDA_DEVICE_MAX_CONNECTIONS=1 # For megatron communication/computation overlapping
export VLLM_ALLREDUCE_USE_SYMM_MEM=0 # for vllm0.11.0 with TP
GEN_TP=${GEN_TP:-4} CP=${CP:-1} TP=${TP:-4} PP=${PP:-1} EP=${EP:-8} ETP=${ETP:-1}
HF_MODEL_PATH=/home/verl/ckpt/Qwen3-VL-30B-A3B-Instruct
train_path=/home/verl/data/geo3k/train.parquet test_path=/home/verl/data/geo3k/test.parquet
python3 -m verl.trainer.main_ppo --config-path=config
--config-name='ppo_megatron_trainer.yaml'
algorithm.adv_estimator=grpo
data.train_files="$train_path"
data.val_files="$test_path"
data.train_batch_size=64
data.max_prompt_length=1024
data.max_response_length=2048
data.filter_overlong_prompts=True
data.truncation='error'
actor_rollout_ref.model.path=$HF_MODEL_PATH
actor_rollout_ref.actor.optim.lr=1e-6
actor_rollout_ref.actor.ppo_mini_batch_size=32
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=1
actor_rollout_ref.actor.megatron.pipeline_model_parallel_size=$PP
actor_rollout_ref.actor.megatron.tensor_model_parallel_size=$TP
actor_rollout_ref.actor.megatron.context_parallel_size=$CP
actor_rollout_ref.actor.megatron.expert_model_parallel_size=$EP
actor_rollout_ref.actor.megatron.expert_tensor_parallel_size=$ETP
actor_rollout_ref.actor.use_kl_loss=True
actor_rollout_ref.actor.kl_loss_coef=0.01
actor_rollout_ref.actor.kl_loss_type=low_var_kl
actor_rollout_ref.actor.entropy_coeff=0
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=1
actor_rollout_ref.rollout.tensor_model_parallel_size=$GEN_TP
actor_rollout_ref.actor.use_dynamic_bsz=True
actor_rollout_ref.actor.ppo_max_token_len_per_gpu=4096
actor_rollout_ref.ref.log_prob_use_dynamic_bsz=True
actor_rollout_ref.ref.log_prob_max_token_len_per_gpu=4096
actor_rollout_ref.rollout.log_prob_use_dynamic_bsz=True
actor_rollout_ref.rollout.log_prob_max_token_len_per_gpu=4096
actor_rollout_ref.rollout.name=$ENGINE
+actor_rollout_ref.rollout.engine_kwargs.vllm.disable_mm_preprocessor_cache=True
actor_rollout_ref.rollout.gpu_memory_utilization=0.7
actor_rollout_ref.rollout.n=5
actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=1
actor_rollout_ref.actor.megatron.use_mbridge=True
actor_rollout_ref.actor.megatron.param_offload=True
actor_rollout_ref.actor.megatron.optimizer_offload=True
actor_rollout_ref.actor.megatron.grad_offload=True
actor_rollout_ref.ref.megatron.param_offload=True
+actor_rollout_ref.actor.optim.override_optimizer_config.optimizer_offload_fraction=1
+actor_rollout_ref.actor.optim.override_optimizer_config.overlap_cpu_optimizer_d2h_h2d=True
+actor_rollout_ref.actor.optim.override_optimizer_config.use_precision_aware_optimizer=True
+actor_rollout_ref.actor.optim.override_optimizer_config.optimizer_cpu_offload=True
+actor_rollout_ref.actor.megatron.override_transformer_config.moe_router_dtype=fp32
+actor_rollout_ref.actor.megatron.override_transformer_config.moe_enable_deepep=True
+actor_rollout_ref.actor.megatron.override_transformer_config.moe_token_dispatcher_type=flex
+actor_rollout_ref.actor.megatron.override_transformer_config.recompute_method=uniform
+actor_rollout_ref.actor.megatron.override_transformer_config.recompute_granularity=full
+actor_rollout_ref.actor.megatron.override_transformer_config.recompute_num_layers=1
+actor_rollout_ref.actor.megatron.override_transformer_config.gradient_accumulation_fusion=False
+actor_rollout_ref.actor.megatron.override_transformer_config.moe_permute_fusion=True
+actor_rollout_ref.actor.megatron.override_transformer_config.moe_aux_loss_coeff=0.01
+actor_rollout_ref.actor.megatron.override_transformer_config.moe_z_loss_coeff=0.001
algorithm.use_kl_in_reward=False
trainer.critic_warmup=0
trainer.logger='["console"]'
trainer.project_name='verl_grpo_example_geo3k'
trainer.experiment_name='qwen3_vl_30b_megatron'
trainer.n_gpus_per_node=8
trainer.nnodes=1
trainer.save_freq=1
trainer.test_freq=5
trainer.val_before_train=False
trainer.default_local_dir='/data1/checkpoints20251222/${trainer.project_name}/${trainer.experiment_name}'
trainer.total_epochs=15
The above is my running script. When reading the saved checkpoint, Verlet reports an error, and the optimizer's step information is None.
The error message is as follows:
askRunner pid=158744) Unhandled error (suppress with 'RAY_IGNORE_UNHANDLED_ERRORS=1'): ray::WorkerDict.actor_rollout_load_checkpoint() (pid=174760, ip=90.91.103.37, actor_id=422db48070706e3b229f21d301000000, repr=<verl.single_controller.ray.base.WorkerDict object at 0x7f23728937d0>) (TaskRunner pid=158744) File "/data/miniconda3/envs/lh_verl_new/lib/python3.11/concurrent/futures/_base.py", line 456, in result (TaskRunner pid=158744) return self.__get_result() (TaskRunner pid=158744) ^^^^^^^^^^^^^^^^^^^ (TaskRunner pid=158744) File "/data/miniconda3/envs/lh_verl_new/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result (TaskRunner pid=158744) raise self._exception (TaskRunner pid=158744) ^^^^^^^^^^^^^^^^^^^^^ (TaskRunner pid=158744) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (TaskRunner pid=158744) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (TaskRunner pid=158744) File "/home/verl/verl/verl/single_controller/ray/base.py", line 825, in func (TaskRunner pid=158744) return getattr(self.worker_dict[key], name)(*args, **kwargs) (TaskRunner pid=158744) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (TaskRunner pid=158744) File "/home/verl/verl/verl/single_controller/base/decorator.py", line 451, in inner (TaskRunner pid=158744) return func(*args, **kwargs) (TaskRunner pid=158744) ^^^^^^^^^^^^^^^^^^^^^ (TaskRunner pid=158744) File "/home/verl/verl/verl/utils/transferqueue_utils.py", line 185, in dummy_inner (TaskRunner pid=158744) return func(*args, **kwargs) (TaskRunner pid=158744) ^^^^^^^^^^^^^^^^^^^^^ (TaskRunner pid=158744) File "/home/verl/verl/verl/workers/megatron_workers.py", line 858, in load_checkpoint (TaskRunner pid=158744) self.checkpoint_mananager.load_checkpoint( (TaskRunner pid=158744) File "/home/verl/verl/verl/utils/checkpoint/megatron_checkpoint_manager.py", line 316, in load_checkpoint (TaskRunner pid=158744) sharded_state_dict = self.generate_state_dict( (TaskRunner pid=158744) ^^^^^^^^^^^^^^^^^^^^^^^^^ (TaskRunner pid=158744) File "/home/verl/verl/verl/utils/checkpoint/megatron_checkpoint_manager.py", line 267, in generate_state_dict (TaskRunner pid=158744) optimizer_sharded_states = self.optimizer.sharded_state_dict(state_dict, is_loading=is_loading) (TaskRunner pid=158744) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (TaskRunner pid=158744) File "/data/miniconda3/envs/lh_verl_new/lib/python3.11/site-packages/megatron/core/optimizer/optimizer.py", line 1161, in sharded_state_dict (TaskRunner pid=158744) optim_state_dict = optimizer.sharded_state_dict( (TaskRunner pid=158744) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (TaskRunner pid=158744) File "/data/miniconda3/envs/lh_verl_new/lib/python3.11/site-packages/megatron/core/optimizer/distrib_optimizer.py", line 1172, in sharded_state_dict (TaskRunner pid=158744) self.load_state_dict(self.state_dict()) (TaskRunner pid=158744) File "/data/miniconda3/envs/lh_verl_new/lib/python3.11/site-packages/megatron/core/optimizer/distrib_optimizer.py", line 811, in load_state_dict (TaskRunner pid=158744) step = torch.tensor(steps[0], dtype=torch.float32, device="cpu") (TaskRunner pid=158744) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (TaskRunner pid=158744) TypeError: must be real number, not NoneType
Expected behavior
I found that the weight saving file contains step information, which means there was an issue when loading the weights.
`
def load_checkpoint(self, local_path: str, hdfs_path: str = None, del_local_after_load=False):
if local_path is not None:
assert os.path.exists(local_path), f"Checkpoint path {local_path} does not exist."
# For load optimizer dist_ckpt
import transformer_engine
torch.serialization.add_safe_globals([torch.optim.AdamW])
torch.serialization.add_safe_globals([transformer_engine.pytorch.optimizers.fused_adam.FusedAdam])
dist_checkpoint_path = get_dist_checkpoint_path(local_path)
# Get State Dict for loading
sharded_state_dict = self.generate_state_dict(
self.should_load_model and self.use_dist_checkpointing,
self.should_load_optimizer,
self.should_load_extra,
is_loading=True,
)
log_with_rank(f"Generated state dict for loading: {sharded_state_dict.keys()}", rank=self.rank, logger=logger)
# Load Dist Checkpointing
state_dict = load_dist_checkpointing(
sharded_state_dict=sharded_state_dict,
ckpt_dir=dist_checkpoint_path,
)
`
An exception occurred in the self.generate_state_dict method, but at this point, the checkpoint had not yet been read. The actual reading occurs in load_dist_checkpointing. Initially, it was just initialized with step=None, and later it should have read the real checkpoint to overwrite the initial values. However, the self.generate_state_dict method also uses step, which causes the error.
一样的问题,这个有解决办法不?
The issue occurs when we use optimizer_cpu_offload. This looks more like a bug from the Megatron side.
Have you resolved this issue?
/verl/megatron_link/core/optimizer/distrib_optimizer.py
临时修改,将 step = torch.tensor(steps[0], dtype=torch.float32, device="cpu")
替换为 if steps[0] is None: logger.warning(" Optimizer step is None, setting to 0.") step = torch.tensor(0, dtype=torch.float32, device="cpu") else: step = torch.tensor(steps[0], dtype=torch.float32, device="cpu")
https://verl.readthedocs.io/en/latest/examples/config.html#trainer
trainer.resume_mode: The mode of resuming training. Support disable, auto and resume_path. If set to auto as default, the program will automatically resume from the latest checkpoint in the default_local_dir. If set to resume_path, the program will resume from the path specified in resume_from_path. trainer.resume_from_path: The path to resume training from. Only effective when resume_mode is set to resume_path.
Have you resolved this issue? @ruanhao123 下面的修改操作能解决问题吗?
临时修改,将 step = torch.tensor(steps[0], dtype=torch.float32, device="cpu")
替换为 if steps[0] is None: logger.warning(" Optimizer step is None, setting to 0.") step = torch.tensor(0, dtype=torch.float32, device="cpu") else: step = torch.tensor(steps[0], dtype=torch.float32, device="cpu")