Plan Module Training Deployment Issue
We use an online-served vLLM instead of an offline one and make API requests to generate and parse rollouts. Please check examples from VLLM doc.
Hello, I have a question. During Flow-GRPO training, shouldn't each rollout use the model with updated parameters? However, in the source code, it seems that a deployed vLLM service is used for every rollout. Wouldn't this result in using a fixed model for every rollout? How can we ensure that the RL is online?
Originally posted by @zhangxixi551 in #13
Hi, thanks for the great work on Flow-GRPO. I encountered an issue when trying to run the training strictly following the README.
When I start Flow-GRPO as described, the planner module reports an error saying it cannot find the API endpoint. After checking the source code, I wasn’t able to find any component that exposes a vLLM endpoint based on the model being updated during training.
This makes me wonder:
Am I expected to manually deploy an additional vLLM server during training to provide rollouts for the planner model?
If so, since that vLLM instance loads a fixed checkpoint at startup, how are the rollouts considered online in the context of online reinforcement learning? It seems the rollout model would not reflect the latest updated parameters.
We use an online-served vLLM instead of an offline one and make API requests to generate and parse rollouts. Please check examples from VLLM doc. Hello, I have a question. During Flow-GRPO training, shouldn't each rollout use the model with updated parameters? However, in the source code, it seems that a deployed vLLM service is used for every rollout. Wouldn't this result in using a fixed model for every rollout? How can we ensure that the RL is online?
Originally posted by @zhangxixi551 in #13
Hi, thanks for the great work on Flow-GRPO. I encountered an issue when trying to run the training strictly following the README.
When I start Flow-GRPO as described, the planner module reports an error saying it cannot find the API endpoint. After checking the source code, I wasn’t able to find any component that exposes a vLLM endpoint based on the model being updated during training.
This makes me wonder:
Am I expected to manually deploy an additional vLLM server during training to provide rollouts for the planner model?
If so, since that vLLM instance loads a fixed checkpoint at startup, how are the rollouts considered online in the context of online reinforcement learning? It seems the rollout model would not reflect the latest updated parameters.
Hello, I have exactly the same doubt! Could you tell me if you've solved it?
Hi @ymyamz and @zhangxixi551,
Thank you for raising these important questions about the online nature of Flow-GRPO training. Let me give a brief roadmap of how the system enables online RL despite using a vLLM service.
Key Points
1. Process Separation and Port Configuration
The gradient update and rollout collection happen in different processes to enable better inference scalability. Both processes access the same agentflow.port field in the config to deploy and communicate with the model, tracing the output of the target module of the system.
2. Correct Startup Order
To avoid the "API endpoint not found" error, you must follow this specific startup sequence:
# Step 1: Create a tmux session and start the agentflow service (Window 0)
tmux new-session -s agentflow
bash train/serve_with_logs.sh
# Step 2: Create a new window (Ctrl+B then C) and start training (Window 1)
bash train/train_with_logs.sh
The service must be running before training starts, otherwise the planner module cannot find the vLLM endpoint.
3. How Online RL is Guaranteed
The rollout model is indeed updated with the latest parameters. Here's the mechanism:
-
The
self.async_rollout_managerholds a worker group:self.actor_rollout_wgsource -
At each training step, the worker group is "woken up" and weight synchronization occurs source
-
This means that after each gradient update, the vLLM service is refreshed with the newly updated model weights before collecting the next batch of rollouts
4. Architecture Overview
Training Loop: -->
1. Gradient update on the trainer process
2. Updated weights → synchronized to rollout workers
3. vLLM engine reloaded with new weights
4. New rollouts collected using the updated model
5. <-- Repeat
This design separates concerns while maintaining the online property crucial for RL.
Speculation according to my experience
Additional Note: If you're running on rented servers, the setup is often deployed inside Docker containers or behind strict firewall rules. Please make sure the port you configure in agentflow.port is properly exposed in your Docker configuration and allowed through your firewall settings. This is a common source of connection issues!
For more implementation and system design details that vLLM serves as a intermedia between VeRL and traced trajectory, I recommend checking the AgentLightning repository, which contains the core logic for this weight synchronization mechanism.
Hope this clarifies the confusion =w=/!
Let me know if you have any follow-up questions.
@IsaacGHX I understand what you mean. Could you please help me check why my current configuration always shows that it cannot connect to the API?
env:
OPENAI_API_KEY: "YOUR_ONENAI_API" # Not that neccesary.
CUDA_VISIBLE_DEVICES: '2,3,4,5,6,7'
HYDRA_FULL_ERROR: 1
N_GPUS: 6
BASE_MODEL: '/mnt/sg_nas/models/hf_models/llama-3-8b-instruct-n' # This model will be served in vllm, used by `agentflow.port`, and serve as the base model of rollout in the training process.
ROLLOUT_TP_SIZE: 1
EXPERIMENT_NAME: 'AgentFlow_self'
PROJECT_NAME: 'AgentFlow_self'
BASE_DATA_DIR: 'data' # This is where to find training and eval data.
VERBOSITY: 'DEBUG'
N_WORKERS: 16
ENABLE_TOOLS: ["Base_Generator_Tool","Python_Coder_Tool"] # If OpenAI API is on, then it can add tools.
TOOL_ENGINE: ["self","self"] # Default means use tool.py's default params. You can set "dashscope" as qwen7B, "gpt-4o-mini" for gpt, or "self" as the training BASE_MODEL.
# TOOL_ENGINE: ["vllm-Qwen/Qwen2.5-7B-Instruct","vllm-Qwen/Qwen2.5-7B-Instruct","Default","Default"] # If you are not using the Dashscope API, you can use VLLM to serve qwen2.5-7b-instruct on your own server and redesign the llm_engine port.
MODEL_ENGINE: ["trainable","trainable","trainable","trainable"] # [planner_main, planner_fixed, verifier, executor]. "trainable" means use the BASE_MODEL with different temperatures for train/test. You can also specify specific models like "dashscope", "gpt-4o-mini", etc.
TOOL_STEPS: 3 # Do not increase beyond 5. It may overflow context.
TEST_TEMPERATURE: 0.0
TRAIN_TEMPERATURE: 0.7 # 0.7 - 0.5 is good. Please check whether every planner and the executor have the this parameter correctly transfered.
OUTPUT_TYPE: "direct" # Different output mode in rollout's last output, not that neccesary if we are searching and math reasoning because answer should be short.
AGENT_MAX_TIMEOUT: 500 # 300-500 is good. When steps extend beyond this limit, there may be errors.
python_args:
agentflow.port: 9999 # This will be sent to agent serving and training.
algorithm.adv_estimator: 'grpo'
data.train_files: '${BASE_DATA_DIR}/train/combined_train.parquet' # Mixed nq search and mathard, shuffled.
data.val_files: '${BASE_DATA_DIR}/val/aime24.parquet' # AIME24 for fast check, the first epoch maybe down due to async start and file lock.
actor_rollout_ref.rollout.tensor_model_parallel_size: '${ROLLOUT_TP_SIZE}'
trainer.n_gpus_per_node: '${N_GPUS}'
data.train_batch_size: 24
actor_rollout_ref.rollout.n: 8
actor_rollout_ref.actor.ppo_mini_batch_size: 12
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu: 4
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu: 4
actor_rollout_ref.rollout.multi_turn.format: 'hermes'
actor_rollout_ref.model.path: '${BASE_MODEL}'
data.max_prompt_length: 18432 # This is safe here because in qwen-plannr&executor and dashscope/4o-mini's tools will never prematurely end the output at this length.
data.max_response_length: 2048 # Make sure this will be transfered all the way down.
data.truncation: 'truncate' # If this is set to "error", then the process will be shut down when the input length exceeds the max_prompt_length + max_response_length.
trainer.val_before_train: True # If you restart from a CKPT, then you don't need to save time.
actor_rollout_ref.actor.optim.lr: 1e-6
actor_rollout_ref.model.use_remove_padding: True
actor_rollout_ref.actor.use_kl_loss: True
actor_rollout_ref.actor.kl_loss_coef: 0.001
actor_rollout_ref.actor.entropy_coeff: 0.0 # Maybe this can somehow prevent model repetition?
actor_rollout_ref.actor.clip_ratio_low: 0.2
actor_rollout_ref.actor.clip_ratio_high: 0.3
actor_rollout_ref.model.enable_gradient_checkpointing: True
actor_rollout_ref.actor.fsdp_config.param_offload: False
actor_rollout_ref.actor.fsdp_config.optimizer_offload: False
actor_rollout_ref.rollout.name: 'vllm'
actor_rollout_ref.rollout.gpu_memory_utilization: 0.6 # 0.55-0.65 is fine. If it's too small, the BASE_MODEL inference will be slow. If it's too large, the KV cache and other extra saved logic will cause OOM.
actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu: 4
actor_rollout_ref.ref.fsdp_config.param_offload: False
algorithm.use_kl_in_reward: False
trainer.critic_warmup: 0
trainer.logger: ['console','wandb']
trainer.project_name: '${PROJECT_NAME}'
trainer.experiment_name: '${EXPERIMENT_NAME}'
trainer.nnodes: 1
trainer.save_freq: 2 # This is to ensure the CKPT exists.
trainer.test_freq: 2
trainer.total_epochs: 5
Below is the modification I made to factory.py. I previously printed the request information from factory.py, and the port was http://127.0.0.1:35225/v1, which matches the “ SERVED AT ” printed. However, it still failed to connect. I’d like to know whether my port configuration is incorrect. Could you please help me troubleshoot this?
if "vllm" in model_string:
from .vllm import ChatVLLM
if "hf_models" in model_string:
model_string = model_string.replace("vllm-", "")
config = {
"model_string": model_string,
"base_url": kwargs.get("base_url", "http://localhost:8001/v1"),
"use_cache": use_cache,
"is_multimodal": is_multimodal,
"temperature": kwargs.get("temperature", 0.7),
"top_p": kwargs.get("top_p", 0.9),
"frequency_penalty": kwargs.get("frequency_penalty", 1.2),
"max_model_len": kwargs.get("max_model_len", 15200),
"max_seq_len_to_capture": kwargs.get("max_seq_len_to_capture", 15200),
}
return ChatVLLM(**config)
Some important logs is as follows: In serve_log/serving_output_0000
********MODEL /mnt/sg_nas/models/hf_models/llama-3-8b-instruct-n SERVED AT http://127.0.0.1:35225/v1***********
==> Initializing agentflow...
Enabled tools: ['Base_Generator_Tool', 'Python_Coder_Tool'] with ['self', 'self']
LLM engine name: vllm-/mnt/sg_nas/models/hf_models/llama-3-8b-instruct-n
Parallel loading: True (standalone mode: 4 workers (CPU=120))
==> Setting up tools...
vllm Error in generate method: Error code: 404 - {'object': 'error', 'message': 'The model `/mnt/sg_nas/models/hf_models/llama-3-8b-instruct-n` does not exist.', 'type': 'NotFoundError', 'param': None, 'code': 404}
Error type: NotFoundError
Error details: ("Error code: 404 - {'object': 'error', 'message': 'The model `/mnt/sg_nas/models/hf_models/llama-3-8b-instruct-n` does not exist.', 'type': 'NotFoundError', 'param': None, 'code': 404}",)
==> 🔍 Step 0: Query Analysis
{'error': 'NotFoundError', 'message': "Error code: 404 - {'object': 'error', 'message': 'The model `/mnt/sg_nas/models/hf_models/llama-3-8b-instruct-n` does not exist.', 'type': 'NotFoundError', 'param': None, 'code': 404}", 'details': ("Error code: 404 - {'object': 'error', 'message': 'The model `/mnt/sg_nas/models/hf_models/llama-3-8b-instruct-n` does not exist.', 'type': 'NotFoundError', 'param': None, 'code': 404}",)}
[Time]: 0.07s
Mapped: Base_Generator_Tool -> Generalist_Solution_Generator_Tool (dir: base_generator)
[31;1m🖇 AgentOps: [OPENAI WRAPPER] Error in chat_completion_stream_wrapper: Error code: 404 - {'object': 'error', 'message': 'The model `/mnt/sg_nas/models/hf_models/llama-3-8b-instruct-n` does not exist.', 'type': 'NotFoundError', 'param': None, 'code': 404}[0m
vllm Error in generate method: Error code: 404 - {'object': 'error', 'message': 'The model `/mnt/sg_nas/models/hf_models/llama-3-8b-instruct-n` does not exist.', 'type': 'NotFoundError', 'param': None, 'code': 404}
Error type: NotFoundError
Error details: ("Error code: 404 - {'object': 'error', 'message': 'The model `/mnt/sg_nas/models/hf_models/llama-3-8b-instruct-n` does not exist.', 'type': 'NotFoundError', 'param': None, 'code': 404}",)
see next_step +++++++
{'error': 'NotFoundError', 'message': "Error code: 404 - {'object': 'error', 'message': 'The model `/mnt/sg_nas/models/hf_models/llama-3-8b-instruct-n` does not exist.', 'type': 'NotFoundError', 'param': None, 'code': 404}", 'details': ("Error code: 404 - {'object': 'error', 'message': 'The model `/mnt/sg_nas/models/hf_models/llama-3-8b-instruct-n` does not exist.', 'type': 'NotFoundError', 'param': None, 'code': 404}",)}
arielg 2
Error extracting context, sub-goal, and tool name: 'dict' object has no attribute 'replace'
==> 🎯 Step 1: Action Prediction (None)
[Context]: None
[Sub Goal]: None
[Tool]: None
[Time]: 0.01s
==> 🚫 Error: Tool 'None' is not available or not found.
[31;1m🖇 AgentOps: [OPENAI WRAPPER] Error in chat_completion_stream_wrapper: Error code: 404 - {'object': 'error', 'message': 'The model `/mnt/sg_nas/models/hf_models/llama-3-8b-instruct-n` does not exist.', 'type': 'NotFoundError', 'param': None, 'code': 404}[0m
vllm Error in generate method: Error code: 404 - {'object': 'error', 'message': 'The model `/mnt/sg_nas/models/hf_models/llama-3-8b-instruct-n` does not exist.', 'type': 'NotFoundError', 'param': None, 'code': 404}
Error type: NotFoundError
Error details: ("Error code: 404 - {'object': 'error', 'message': '/mnt/sg_nas/models/hf_models/llama-3-8b-instruct-n` does not exist.', 'type': 'NotFoundError', 'param': None, 'code': 404}",)
Failure during agent execution: expected string or bytes-like object, got 'dict'. Defaulting to 'None'.
Mapped: Google_Search_Tool -> Ground_Google_Search_Tool (dir: google_search)
Mapped: Python_Coder_Tool -> Python_Code_Generator_Tool (dir: python_coder)
Mapped: Web_Search_Tool -> Web_RAG_Search_Tool (dir: web_search)
Mapped: Wikipedia_Search_Tool -> Wikipedia_RAG_Search_Tool (dir: wikipedia_search)
Loading tools and getting metadata... (parallel=True, max_workers=4)
Updated Python path: ['/mnt/sg_nas/muyangye.ymy/mount/AgentFlow/agentflow', '/mnt/sg_nas/muyangye.ymy/mount/AgentFlow/agentflow/agentflow', '/mnt/sg_nas/muyangye.ymy/mount/AgentFlow/train', '/mnt/sg_nas/muyangye.ymy/conda/envs/agentflow_2/lib/python311.zip', '/mnt/sg_nas/muyangye.ymy/conda/envs/agentflow_2/lib/python3.11', '/mnt/sg_nas/muyangye.ymy/conda/envs/agentflow_2/lib/python3.11/lib-dynload', '/mnt/sg_nas/muyangye.ymy/conda/envs/agentflow_2/lib/python3.11/site-packages', '/mnt/sg_nas/muyangye.ymy/mount/AgentFlow', '/mnt/sg_nas/muyangye.ymy/mount/AgentFlow']
This issue has troubled me for a long time, and I really need your help! In addition, I have also tried launching a local vLLM server as a fixed model, and that one can be connected successfully. I am confident that I followed the tutorial and used the correct script startup sequence.
The complete log file is as follows:
Hi @ymyamz
Nice to hear you successfully rolloing to the training process. And we are happy to find our community to train your self-customized model on specific domain and even customized reinforcement learning algorithm.
Thank you for your detailed logs and updates in this issue. Based on the last reply, it seems like there are a few potential issues and suggestions to address the deployment and training problems you're encountering with AgentFlow. I'll break them down step by step for clarity.
-
Directory Structure for Hugging Face Models: It looks like the model deployment might be failing because the directory path isn't pointing precisely to the required Hugging Face folder structure. For local deployment with VLLM, you typically need to specify the path down to the
{model_name}/actor/huggingfacelevel to ensure correct loading. If deployed properly, you should see initial logs confirming the model setup (though this might not match your exact error scenario based on my assumption). Double-check your config to ensure the path is accurate, e.g., something like/path/to/model/actor/huggingface. -
Checking Deployment Logs in
task_logs/{IP_Address}/serve_log: At minimum, the serve logs should show successful model deployment indicators. For example, you might expect entries like (I also found this exists in your logs):2025-11-28 08:18:45,666 [INFO] (Process-44794 agentflow.tracer.agentops) [Worker 6] Env var set: AGENTOPS_EXPORTER_ENDPOINT=http://localhost:54245/tracesNote that ports like 54245 here refer to the AgentOps tracer, not VLLM's serving port. I've referenced the system architecture diagram you attached below for context—it helps illustrate how components like tracers and VLLM interact. If your logs don't show model loading, it could indicate a deployment failure upstream.
-
Code and Environment Issues Observed [IMPORTANT]:
-
Port Killing Error: The error
[ERROR] Failed to kill process on port 9999: [Errno 2] No such file or directory: 'lsof'suggests that thelsofcommand isn't available, which is needed to properly kill processes occupying ports. This could lead to failed deployments or stuck models. To fix this, installlsofbased on your OS:- For Ubuntu/Debian:
sudo apt-get install lsof - For CentOS/RHEL:
sudo yum install lsofInstalling this should allow clean port management and ensure you're not reusing outdated model instances after logic changes.
- For Ubuntu/Debian:
-
VLLM Instrumentation Warning: The warning in
/mnt/sg_nas/muyangye.ymy/mount/AgentFlow/agentflow/instrumentation/__init__.py:51: UserWarning: vllm is not installed. It's therefore not instrumented.indicates that VLLM isn't installed in your current environment. When creating the server script, make sure you've activated the local UV virtual environment beforehand (e.g., your command should include something like(your_venv_name) python script.py). If this persists, consider installing VLLM globally in your Python environment as a fallback to ensure it runs, though this isn't recommended for isolation reasons—stick to virtual envs if possible. -
Training Configuration and Hardware Considerations: I'm not sure about your machine specs, but if it's something with massive VRAM like an H200 (100GB+), your current settings are fine. However, your config like:
{ 'batch_size': 24, 'enabled_tools': ['Base_Generator_Tool', 'Python_Coder_Tool'], 'exp_name': 'AgentFlow_llama_self', 'max_steps': 3, 'max_tokens': 2048, 'model_engine': ['trainable', 'trainable', 'trainable', 'trainable'], }could cause VRAM explosion if all modules (including tools and every component) are set to trainable. This might prevent stable training with larger batches. On servers like ours (A100 with 80GB VRAM and ~128-core CPU), VLLM's load might not handle 16 concurrent async on-policy accesses reliably with your config, leading to frequent interruptions or memory overflows. Adjust based on your hardware: reduce batch size, limit trainable modules, or scale down concurrency if needed. If your setup is much more powerful, disregard this.
-
Tool and Dataset Mismatch: Your config only enables
Base_Generator_ToolandPython_Coder_Tool, but you're using our provided mixed search/math datasets. This isn't ideal for building general capabilities—consider adding all our provided search tools to improve versatility. For hyperparameter tuning, refer to the VeRL documentation at https://verl.readthedocs.io/en/latest/examples/config.html for guidance on adjustments like batch sizes, steps, etc., tailored to your setup.
-
Welcome to show your experiment results on your setting to help community to explore new findings!
Wish your experiments walks smoothly =w=/
Here is the overall structure glance:
你可以尝试把模型放到AgentFlow-main文件夹下,像是这样AgentFlow-main/Qwen/Qwen2.5-7B-Instruct,然后参数使用相对路径BASE_MODEL: 'Qwen/Qwen2.5-7B-Instruct'。
你可以尝试把模型放到AgentFlow-main文件夹下,像是这样AgentFlow-main/Qwen/Qwen2.5-7B-Instruct,然后参数使用相对路径BASE_MODEL: 'Qwen/Qwen2.5-7B-Instruct'。
改成相对路径后,训练代码成功跑通。非常感谢两位作者耐心及时的回复!
We use an online-served vLLM instead of an offline one and make API requests to generate and parse rollouts. Please check examples from VLLM doc. Hello, I have a question. During Flow-GRPO training, shouldn't each rollout use the model with updated parameters? However, in the source code, it seems that a deployed vLLM service is used for every rollout. Wouldn't this result in using a fixed model for every rollout? How can we ensure that the RL is online?
Originally posted by @zhangxixi551 in #13 Hi, thanks for the great work on Flow-GRPO. I encountered an issue when trying to run the training strictly following the README. When I start Flow-GRPO as described, the planner module reports an error saying it cannot find the API endpoint. After checking the source code, I wasn’t able to find any component that exposes a vLLM endpoint based on the model being updated during training. This makes me wonder: Am I expected to manually deploy an additional vLLM server during training to provide rollouts for the planner model? If so, since that vLLM instance loads a fixed checkpoint at startup, how are the rollouts considered online in the context of online reinforcement learning? It seems the rollout model would not reflect the latest updated parameters.
Hello, I have exactly the same doubt! Could you tell me if you've solved it?
You can try changing the model path to a relative reference; that worked for me.