[rollout, data] feat: integrate TransferQueue for multi-modal image data transfer - #5780
[rollout, data] feat: integrate TransferQueue for multi-modal image data transfer#5780RobotGF wants to merge 6 commits into
Conversation
…ata transfer Add TQ-based zero-copy image data transfer between AgentLoop workers and vLLM server, using tq:// URL scheme to avoid serialising large PIL Images over Ray RPC. Changes: - New verl/utils/tq_multimodal.py: store/resolve images via TQ with zero-copy path (PIL→numpy→tensor→msgpack memoryview→ZMQ) - vllm_async_server.py: resolve tq:// URLs in generate(), inject TQ env vars into vLLM server Ray actor runtime_env - single_turn_agent_loop.py & tool_agent_loop.py: store images to TQ before generate() when TQ is enabled; no-op fallback otherwise Non-breaking: all changes are guarded by TQ availability checks. When TQ is not enabled, the existing PIL-Image-over-Ray-RPC path is used. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request introduces TransferQueue (TQ) support for multi-modal data to optimize communication by avoiding the serialization of large image blobs over Ray RPC. Key changes include the addition of a utility module for TQ operations, integration of media storage in agent loops, and URL resolution in the vLLM server. Feedback identifies a logic error in environment variable parsing, the use of inconsistent request IDs for tracing, and a risky dependency on a private external API for URL parsing.
…rformance - Fix hash collision: replace hash()-based index with uuid4 as explicit KV key - Batch images: flatten all images into one contiguous tensor per store call, reducing N TQ round-trips to 1 (store) and grouping fetches on resolve - Use async_kv_put with explicit key instead of async_put, ensuring deterministic retrieval by batch_key - Move inline imports to module top-level across all 4 files - Remove dead try/except ImportError in maybe_store_media_to_tq - Optimize _maybe_resolve_tq_media to check only first element Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ingleTurnAgentLoop Generate request_id once and pass it to both maybe_store_media_to_tq and server_manager.generate, ensuring consistent tracing across distributed components. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Store path: - Replace per-image np.copy() + torch.cat with pre-allocated contiguous buffer and direct copy_ into it (N+1 allocations → 1 allocation) Resolve path: - Output numpy.ndarray in channels-first (C,H,W) format directly, which vLLM multi_modal_data accepts natively - Skip PIL Image.fromarray round-trip, eliminating 1 memcpy per image on resolve and another inside vLLM's HF processor (PIL→tensor) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
pickle.loads on env vars crossing process boundaries allows arbitrary code execution. Switch serialize_tq_info/deserialize_tq_info to JSON. The vllm-side _deserialize_env_var already handles both formats (JSON preferred, pickle fallback with warning), so this is backward-compatible. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Cover URL helpers (make/parse/is_tq_url), TQ client singleton, JSON serialization helpers, and full store→resolve round-trip with mock TQ client including: - RGB, RGBA, grayscale image round-trips - Mixed image batch in single TQ entry - Channels-first (C,H,W) output format verification - Batch key uniqueness (uuid4) - maybe_store_media_to_tq enable/disable/fallback paths - TensorDict internal layout validation All tests run on CPU without real TransferQueue dependency. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Hold until #5401 merged, do you any have performance comparison before and after this PR? |
|
| ``(image_data, video_data)`` — either ``tq://`` URL lists or the | ||
| original PIL Image lists. | ||
| """ | ||
| tq_enabled = os.environ.get("TRANSFER_QUEUE_ENABLE", False) |
There was a problem hiding this comment.
For ease-of-use concern, do we have a better way to trigger transfer queue rather env var?
There was a problem hiding this comment.
btw, main_ppo uses os.environ.get("TRANSFER_QUEUE_ENABLE", "0") == "1", which is safer if the env var is set to "0"
There was a problem hiding this comment.
For ease-of-use concern, do we have a better way to trigger transfer queue rather env var?
Yes,maybe the config system of transfer_queue field is better way
|
|
| partition_id: TQ partition that holds the image data. | ||
|
|
||
| Returns: | ||
| A list of ``tq://<partition_id>/<batch_key>/<index>`` URL strings, |
There was a problem hiding this comment.
batch_key may lead to some misunderstanding for the upcoming agentic session level management. Can we refer to the key format design in https://github.com/verl-project/verl/pull/5401/changes#diff-4c72a1d4b0dd65c951d50ff4f1db44c5b9572658e7fcaaf380c1de576f9b8f6aR375 to propose a more clear name?
There was a problem hiding this comment.
Now it sounds like we are retrieving the mm data for the whole batch
Thank you for your great work! I’ll study your implementation. |
|
#5401 has been merged~ You can join our chat group for further discussion: https://raw.githubusercontent.com/TransferQueue/community_doc/refs/heads/main/other_assets/WeChatGroup.png |

What does this PR do?
Add TQ-based zero-copy image data transfer between AgentLoop workers and vLLM server, using tq:// URL scheme to avoid serialising large PIL Images over Ray RPC.
Checklist Before Starting
[{modules}] {type}: {description}(This will be checked by the CI){modules}includefsdp,megatron,veomni,sglang,vllm,rollout,trainer,ci,training_utils,recipe,hardware,deployment,ray,worker,single_controller,misc,perf,model,algo,env,tool,ckpt,doc,data,cfg,reward,fully_async,one_step_off,like[megatron, fsdp, doc]{type}is infeat,fix,refactor,chore,test[BREAKING]to the beginning of the title.[BREAKING][fsdp, megatron] feat: dynamic batchingTest
API and Usage Example
# Add code snippet or script demonstrating how to use thisDesign & Code Changes
Checklist Before Submitting
Important
Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review.
pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=alwaysci-requestchannel in theverlSlack workspace. (If not accessible, please try the Feishu group (飞书群).)recipesubmodule, please also update the reference to the submodule commit viagit submodule update --remoteorcd recipe && git pull origin main.