verl icon indicating copy to clipboard operation
verl copied to clipboard

Has fully async policy support vllm FP8 rollout?

Open qbei-i opened this issue 9 months ago • 6 comments

Description: I am experiencing a significant regression in output quality when enabling FP8 rollout while using the Fully Async Policy in my training pipeline (using verl 0.7.0 + vLLM 0.12.0).

Behavior:

FP8 Enabled: The model produces "garbage" or nonsensical outputs. Specifically, the first token generated is consistently incorrect or unrelated to the prompt, suggesting a corruption in the initial forward pass or weight loading.

FP8 Disabled (FP16/BF16): The model functions perfectly, and the outputs are coherent and as expected.

qbei-i avatar Mar 02 '26 13:03 qbei-i

I'm going to reproduce the bug. May you share the training script or some configs?

Begunner avatar Mar 03 '26 08:03 Begunner

I'm going to reproduce the bug. May you share the training script or some configs?

@Begunner Hi, I've updated the implementation to use runner instead of inference_model here. This refactor allows us to intercept the weight sync from actor to rollouter and determine if FP8 quantization should be performed on the fly.

Here is the updated code snippet:

elif model_runner is not None:
      inference_model = model_runner.model
      named_tensor = _to_flattened_tensor_meta(bucket.metas, 0)
      weights = _extract_weights(named_tensor, buffer_b)
      if is_fp8_model(model_runner.vllm_config):
          print(f"FP8 model detected (async): {model_runner.vllm_config.quant_config}")
          # Convert bf16 weights to fp8 format before loading
          loaded_params = load_quanted_weights(weights, model_runner)
          print(f"FP8 weights loaded (async), loaded_params: {len(loaded_params)}")
      else:
          inference_model.load_weights(weights)

qbei-i avatar Mar 03 '26 09:03 qbei-i

@qbei-i Yes! In verl 0.7.0, fully async uses its own checkpoint engine, which is imcomplete. Fully async has been refactored in #5029 and uses the default checkpoint engine. It supports FP8 checkpoint loading now.

Begunner avatar Mar 03 '26 11:03 Begunner

@Begunner Good Jobs! And I will change my codebase from 0.7.0 to main :)

qbei-i avatar Mar 03 '26 12:03 qbei-i

@Begunner Hi, I'm using main with commit hash is 90ef51fb471cec0. Rollout looks good, but the actor's CPU Memory is so large! Some suggestion?

Image

here is some run training script with Qwen 32b.

NNODES_ROLLOUT=${NNODES_ROLLOUT:-4}
NNODES_TRAIN=${NNODES_TRAIN:-4}
NGPUS_PER_NODE=${NGPUS_PER_NODE:-8}

train_prompt_bsz=0
gen_prompt_bsz=1
n_resp_per_prompt=8
train_prompt_mini_bsz=128
total_rollout_steps=$(((512*400)))
test_freq=20
staleness_threshold=0.2
trigger_parameter_sync_step=4
require_batches=1
partial_rollout=True

rollout_mode="async"
rollout_name="vllm" # sglang or vllm
if [ "$rollout_mode" = "async" ]; then
    export VLLM_USE_V1=1
    return_raw_chat="True"
fi

max_prompt_length=$((1024 * 4))
max_response_length=$((1024 * 8))

offload=True

python3 -m  verl.experimental.fully_async_policy.fully_async_main --config-path=config \
    --config-name='fully_async_ppo_megatron_trainer.yaml'\
    algorithm.adv_estimator=grpo \
    data.train_files="$train_files" \
    data.val_files="$test_files" \
    data.shuffle=False \
    data.train_batch_size=${train_prompt_bsz} \
    data.gen_batch_size=${gen_prompt_bsz} \
    data.return_raw_chat=${return_raw_chat} \
    data.val_batch_size=1024 \
    data.max_prompt_length=${max_prompt_length} \
    data.max_response_length=${max_response_length} \
    data.filter_overlong_prompts=True \
    data.truncation='error' \
    actor_rollout_ref.model.path=$model_path \
    actor_rollout_ref.actor.optim.lr=1e-6 \
    actor_rollout_ref.actor.optim.lr_decay_steps=${total_rollout_steps} \
    actor_rollout_ref.hybrid_engine=False \
    actor_rollout_ref.actor.ppo_mini_batch_size=${train_prompt_mini_bsz} \
    actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=1 \
    actor_rollout_ref.actor.use_dynamic_bsz=True \
    actor_rollout_ref.actor.megatron.tensor_model_parallel_size=8 \
    actor_rollout_ref.actor.use_kl_loss=False \
    actor_rollout_ref.actor.kl_loss_coef=0.00001 \
    actor_rollout_ref.actor.kl_loss_type=low_var_kl \
    actor_rollout_ref.actor.megatron.param_offload=${offload} \
    actor_rollout_ref.actor.megatron.grad_offload=False \
    actor_rollout_ref.actor.megatron.optimizer_offload=${offload} \
    actor_rollout_ref.actor.megatron.override_transformer_config.recompute_granularity=full \
    actor_rollout_ref.actor.megatron.override_transformer_config.recompute_method=uniform \
    actor_rollout_ref.actor.megatron.override_transformer_config.recompute_num_layers=1 \
    actor_rollout_ref.actor.entropy_coeff=0 \
    actor_rollout_ref.actor.ppo_max_token_len_per_gpu=$((max_prompt_length + max_response_length)) \
    actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=1 \
    actor_rollout_ref.rollout.calculate_log_probs=True \
    actor_rollout_ref.rollout.tensor_model_parallel_size=8 \
    actor_rollout_ref.rollout.name=${rollout_name} \
    actor_rollout_ref.rollout.mode=${rollout_mode} \
    +actor_rollout_ref.rollout.quantization=fp8 \
    actor_rollout_ref.rollout.enforce_eager=False \
    actor_rollout_ref.rollout.free_cache_engine=False \
    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.model.override_config.model_config.max_position_embeddings=$((max_prompt_length + max_response_length)) \
    actor_rollout_ref.model.use_fused_kernels=False \
    actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \
    actor_rollout_ref.nccl_timeout=14400 \
    actor_rollout_ref.rollout.n=${n_resp_per_prompt} \
    actor_rollout_ref.rollout.max_model_len=$((max_prompt_length + max_response_length)) \
    actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=1 \
    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 \
    reward.reward_manager.name=async_remote_rate_limited \
    reward.num_workers=64 \
    +reward.max_concurrent=64 \
    +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 \
    actor_rollout_ref.rollout.agent.num_workers=64 \
    algorithm.use_kl_in_reward=False \
    algorithm.rollout_correction.rollout_is=${rollout_is} \
    algorithm.rollout_correction.rollout_is_threshold=${rollout_is_threshold} \
    algorithm.rollout_correction.rollout_rs=${rollout_rs} \
    algorithm.rollout_correction.rollout_rs_threshold=${rollout_rs_threshold} \
    algorithm.rollout_correction.bypass_mode=False \
    trainer.critic_warmup=0 \
    trainer.logger='["console","swanlab"]' \
    trainer.project_name=$project_name \
    trainer.experiment_name=$experiment_name \
    trainer.n_gpus_per_node=8 \
    trainer.nnodes="${NNODES_TRAIN}" \
    trainer.n_gpus_per_node="${NGPUS_PER_NODE}" \
    rollout.nnodes="${NNODES_ROLLOUT}" \
    rollout.n_gpus_per_node="${NGPUS_PER_NODE}" \
    rollout.total_rollout_steps="${total_rollout_steps}" \
    +rollout.max_concurrent=32 \
    trainer.save_freq=5 \
    trainer.default_local_dir="my_path/${experiment_name}"\
    trainer.test_freq=${test_freq} \
    trainer.total_epochs=50 \
    trainer.rollout_data_dir="my_path/${experiment_name}"\
    trainer.val_before_train=False \
    async_training.staleness_threshold="${staleness_threshold}" \
    async_training.trigger_parameter_sync_step="${trigger_parameter_sync_step}" \
    async_training.require_batches="${require_batches}" \
    async_training.partial_rollout="${partial_rollout}"

qbei-i avatar Mar 04 '26 00:03 qbei-i

I got it. set actor_rollout_ref.actor.megatron.dist_ckpt_optim_fully_reshardable=False is okey

qbei-i avatar Mar 04 '26 15:03 qbei-i