Add vLLM offline backend with micro-batching support#736
Conversation
fc01371 to
bbe2874
Compare
efa1d9e to
942fa2e
Compare
942fa2e to
5d2304d
Compare
|
Hi @maryamtahhan, the DCO check has failed. Please click on DCO in the Checks section for instructions on how to resolve this. |
664810c to
251eb67
Compare
|
@sjmonson @jaredoconnell this PR has been rebased and is green again |
|
|
||
|
|
||
| def create_sampling_params( | ||
| vllm_module: Any, |
There was a problem hiding this comment.
Don't pass modules as arguments. Just move from guidellm.extras import vllm out of the TYPE_CHECKING block. guidellm.extras builds lazy stubs so it won't actually import vLLM until you call something on the module.
| if TYPE_CHECKING: | ||
| from guidellm.extras import vllm | ||
| else: | ||
| from guidellm.extras import vllm |
There was a problem hiding this comment.
Its funny this is not a linting error.
| if TYPE_CHECKING: | |
| from guidellm.extras import vllm | |
| else: | |
| from guidellm.extras import vllm | |
| from guidellm.extras import vllm |
| request_info.timings.request_end = time.time() | ||
|
|
||
| if batched_req.result is not None: | ||
| output = batched_req.result |
There was a problem hiding this comment.
So poking around the vLLM docs a bit it looks like vLLM will tell us a lot about the request from what it returns. Maybe take a look at batched_req.result.metrics which is a RequestStateStats and wire all of the latencies to the correct metrics. You can get pretty much all of the latency metrics we normally track. Start/end time I would probably keep how you currently have them though since that is what the "user" sees as start/end.
| @Backend.register("vllm_offline") | ||
| class VLLMOfflineBackend(Backend): |
There was a problem hiding this comment.
I didn't check too closely but it seems like even with common.py the normal and offline backends share a lot of code. Would it make more sense if the base class was the other vLLM backend? E.g.
| @Backend.register("vllm_offline") | |
| class VLLMOfflineBackend(Backend): | |
| @Backend.register("vllm_offline") | |
| class VLLMOfflineBackend(VLLMPythonBackend): |
Either way I think you should keep common.py as it makes the classes easier to read.
dbutenhof
left a comment
There was a problem hiding this comment.
I think the code is mostly OK (except it should be updated to match the current backend init conventions). The documentation needs to be updated to 0.7 CLI conventions.
Introduces VLLMOfflineBackend inheriting from VLLMPythonBackend, using vLLM's synchronous LLM engine for micro-batched inference. Wires RequestStateStats metrics into response timings. Includes registration test, docs, and backends.md update. Signed-off-by: Maryam Tahhan <[email protected]> Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: Maryam Tahhan <[email protected]>
f27b076 to
ff7f125
Compare
Use llm.get_tokenizer() instead of llm.llm_engine.tokenizer.tokenizer which doesn't exist in the V1 engine. Signed-off-by: Maryam Tahhan <[email protected]> Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: Maryam Tahhan <[email protected]>
- Apply ruff format to offline.py - Fix _wire_vllm_metrics: only use token counts, not monotonic timestamps that produce garbage when mixed with wall-clock times - Apply mdformat to markdown docs Signed-off-by: Maryam Tahhan <[email protected]> Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: Maryam Tahhan <[email protected]>
Add vLLM Offline Backend with Shared Base Class
This PR implements offline/batch inference support for vLLM using a clean, extensible architecture that eliminates code duplication between vLLM backends.
Summary
Adds
VLLMOfflineBackendfor batch processing and refactors existing vLLM code into a sharedVLLMBackendBaseclass. This reduces code duplication by ~360 lines while adding new offline inference capabilities optimized for benchmarking scenarios.New Components
VLLMBackendBase (base.py)
Shared base class for all vLLM backends containing ~400 lines of common functionality:
_get_tokenizer()method for subclass implementationVLLMOfflineBackend (offline.py)
New backend for offline batch processing using vLLM's
LLMclass:batch_size(default: 32)LLM.generate()Refactored VLLMPythonBackend (vllm.py)
VLLMBackendBaseinstead ofBackenddirectly_get_tokenizer()forAsyncLLMEngineKey Benefits
Documentation
docs/guides/vllm-offline-backend.mddocs/guides/backends.mdwith offline backend sectionUsage Example
Test Plan
Unit Tests (✅ Passing)
VLLMOfflineBackendlifecycle (startup, shutdown, validate)VLLMBackendBaserequest resolution and formattingIntegration Tests (✅ Verified)
Backend.create()Manual Testing
Details
VLLMBackendBaseshared base class insrc/guidellm/backends/vllm_python/base.pyVLLMOfflineBackendandVLLMOfflineBackendArgsinsrc/guidellm/backends/vllm_python/offline.pyVLLMPythonBackendto extendVLLMBackendBase(eliminate duplication)_ResolvedRequest,_has_jinja2_markers) from base for backward compatibilityRuntimeErrorfrom torchcodec/PIL)tests/unit/backends/vllm_python/test_vllm.pydocs/guides/vllm-offline-backend.mddocs/guides/backends.mdwith offline backend documentationvllm_offlinebackend type in Backend registrytest_backend.pywith offline backend registration testUse of AI
git log
commit ff7f125
Author: Maryam Tahhan [email protected]
Date: Fri Jul 17 14:30:31 2026 +0100
commit fd96103
Author: Maryam Tahhan [email protected]
Date: Fri Jul 17 15:33:26 2026 +0100
commit 253b08f
Author: Maryam Tahhan [email protected]
Date: Fri Jul 17 15:41:25 2026 +0100
Co-Authored-By: Claude Opus 4.6 [email protected]
Signed-off-by: Maryam Tahhan [email protected]
Signed-off-by: Maryam Tahhan [email protected]