[rollout, diffusion] fix: support prompt embedding cache for tokenized prompts#214
[rollout, diffusion] fix: support prompt embedding cache for tokenized prompts#214Sky-Trigger wants to merge 9 commits into
Conversation
Keep token IDs and masks hashable until encode_prompt, convert them inside the token-ID encoders, and expose the vLLM-Omni cache controls through diffusion rollout config. Co-authored-by: OpenAI Codex <noreply@openai.com> Signed-off-by: Trigger <Meng.Bo.Wang@outlook.com>
There was a problem hiding this comment.
Code Review
This pull request introduces a prompt embedding cache mechanism for diffusion workers by adding enable_prompt_embed_cache and prompt_embed_cache_size configurations across trainer and rollout configs. It also refactors several rollout adapters (such as Qwen and Wan22) to support list-based inputs for prompt IDs and masks, standardizing batch size calculation via a new helper function get_prompt_batch_size. There are no review comments provided, so I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
@knlnguyen1802 , prompt cache related, PTAL |
|
@Sky-Trigger Could you help to run a verification and post a curve |
|
@Sky-Trigger Thanks for verify it, could you run several step to compare performance gain on this branch ? |


Keep token IDs and attention masks hashable until
encode_prompt(), convert them to tensors inside token-ID encoders, and expose vLLM-Omni prompt embedding cache controls through the diffusion rollout configuration.What does this PR do?
This PR adapts verl-omni's tokenized diffusion prompt path to the prompt embedding cache introduced by vLLM-Omni PR #2962.
Previously, rollout adapters converted token ID lists and masks to
torch.Tensorbefore callingencode_prompt(). Since the vLLM-Omni cache cannot build keys from tensor arguments, these calls bypassed the cache.This change keeps prompt IDs and masks list-based across the cache boundary and converts them to tensors only inside the underlying token-ID encoder. It covers:
It also adds rollout configuration for enabling and sizing the cache without requiring environment variables.
Checklist Before Starting
[rollout, diffusion] fix: support prompt embedding cache for tokenized promptsTest
Static checks completed:
ruff checkruff format --checkcompileallgit diff --checkManual validation:
examples/diffusionnft_trainer/run_qwen_image_ocr_lora.shcompleted successfully with the updated DiffusionNFT adapter.Configuration unit tests were added to
tests/workers/config/test_diffusion_config_on_cpu.py.Full pytest and all adapter-specific GPU/NPU experiments were not run in the current environment. The remaining independent rollout paths are FlowGRPO, online DPO, and Wan2.2 DanceGRPO.
API and Usage Example
The cache is disabled by default and uses the upstream default capacity of 32.
It can be enabled through Hydra configuration:
python3 -m verl_omni.trainer.main_diffusion \ actor_rollout_ref.rollout.enable_prompt_embed_cache=True \ actor_rollout_ref.rollout.prompt_embed_cache_size=64 \ ...Equivalent YAML:
No example shell scripts are modified.
Design & Code Changes
Prompt cache boundary
Before:
After:
Adapter changes
encode_prompt().prompt_maskto a list before constructing the diffusion request.Configuration changes
Added to
DiffusionRolloutConfig:These values are passed directly to
AsyncOmni. Cache size must be a positive integer.Checklist Before Submitting
pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=alwaysAI Assistance
AI assistance was used to inspect the adapter call paths, implement the changes, and prepare this PR description. All changed lines and validation results were reviewed by the human submitter.