Repository navigation
feat: add vllm shared prefix rollout sampler - #34
Merged
Flink-ddd merged 3 commits intoMay 30, 2026
Merged
Conversation
Signed-off-by: inaniloquentee <[email protected]>
Signed-off-by: inaniloquentee <[email protected]>
Collaborator
|
Thank you for contribution, This is an absolutely phenomenal PR, I'm approving this immediately. Outstanding work, @inaniloquentee Let's get this merged into main. if has real user report issue in the future and we will further update by case by case. but please pull latest code and push again and trigger completely CI workflow. |
Signed-off-by: inaniloquentee <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR completes issue #11:
It adds a vLLM-backed rollout sampler path that explicitly enables vLLM prefix caching by default, preserves shared prompt prefixes across GRPO multi-candidate generation, and returns both raw vLLM outputs and a stable normalized Kernel-Align rollout schema.
The PR also includes mocked unit tests, a real WSL2 vLLM smoke test, and a steady-state vLLM A/B benchmark comparing prefix caching disabled vs enabled.
Motivation
GRPO rollout commonly generates multiple candidate completions for the same prompt. Those candidates share the same prompt prefix. Without prefix reuse, the inference backend can repeatedly perform prompt prefill and rebuild equivalent KV cache state for each candidate.
vLLM supports Automatic Prefix Caching through:
Kernel-Align should not manage vLLM KV blocks directly. The executor's responsibility is to:
Implementation
New vLLM Sampler Module
Added:
Main types:
VLLMSamplerConfigVLLMSamplerConfignormalizes rollout sampler configuration from the executor's loosemodel_configdictionary.Important defaults:
Supported config fields:
modelnum_generationsenable_prefix_cachingsampling_paramsengine_kwargsbackendThe config validates:
num_generations >= 1"vllm"backend is currently acceptedLazy vLLM Construction
vLLM imports and engine construction are lazy.
This keeps CPU-only tests and kernel-only development paths from requiring vLLM at import time.
The vLLM engine is created only when generation is first requested:
Explicit disable remains supported:
Shared Prefix Candidate Expansion
For each input prompt, the sampler expands requests like this:
for
num_generations=3.This preserves identical prefixes within each GRPO candidate group and gives vLLM the request pattern needed for prefix-cache reuse.
Both text prompts and token prompt mappings are supported:
Token prompt support was added so real vLLM smoke tests can run with
skip_tokenizer_init=Trueand avoid external tokenizer downloads.Output Grouping
vLLM returns one output per expanded request. The sampler regroups flat output back into:
Returned shape:
{ "backend": "vllm", "prefix_cache_enabled": True, "num_prompts": 2, "num_generations": 3, "outputs": [[raw_candidate, ...], ...], "normalized_outputs": [[NormalizedRolloutCandidate, ...], ...], }The raw
outputsfield is kept for backward compatibility and debugging.Stable Normalized Output Schema
Added
NormalizedRolloutCandidateas a stable Kernel-Align view over vLLMRequestOutputobjects.Fields:
The object provides:
This lets downstream trainer/loss code consume a predictable schema without depending directly on vLLM's internal output object layout.
RolloutExecutor Changes
Updated:
Added:
The existing
execute_rollout(...)smoke path remains intact.RolloutExecutornow owns:sampler_configsamplergenerate_candidates(...)delegation toVLLMSharedPrefixSamplerTests
Added:
Mocked tests cover:
enable_prefix_caching=True;enable_prefix_caching=False;[prompt][candidate];RequestOutputobjects;RolloutExecutor.generate_candidates(...)uses the vLLM sampler config.Validation Results
Focused Unit Tests
Command:
Result:
Coverage:
enable_prefix_caching=True;enable_prefix_caching=False;[prompt][candidate];RolloutExecutor.generate_candidates(...)integration.Real vLLM Test Environment
Runtime used for local validation:
The real vLLM checks were run with a local validation harness outside the PR source tree. The relevant PR code path under test is
RolloutExecutor.generate_candidates(...), which delegates toVLLMSharedPrefixSampler.Real vLLM Smoke A/B Test
Workload:
Result:
Interpretation:
This smoke test proves real vLLM execution through
RolloutExecutor.generate_candidates(...)with both prefix-cache modes. The timings include engine startup/model load, so they should not be used as steady-state throughput claims.Real vLLM Steady-State Benchmark
Workload:
Result:
Interpretation:
This benchmark reuses each vLLM engine after warmup and excludes engine startup/model load from measured iterations. On this small local RTX 3050 workload, prefix caching improved average measured latency by about 14.3%.
This is integration-grade steady-state evidence, not a production-scale model benchmark.
Real vLLM Normalized Output Smoke Test
Verified normalized fields from real vLLM
RequestOutput:The local validation artifacts also recorded benchmark rows equivalent to:
Notes And Limitations
skip_tokenizer_init=Trueand token prompts are used to avoid external model/tokenizer downloads.These limits are intentionally kept out of the blocking scope for this PR. The implementation goal is to prove the executor integration, default prefix-cache configuration, shared-prefix request shape, output grouping, and normalized result schema. A production-scale throughput claim should be made in a follow-up benchmark with larger model artifacts and suitable benchmark hardware.
Completion Status
Issue #11 is complete for the current scope.
Completed:
Remaining non-blocking future work: