Add VLLMOpenAIModelClass parent class with cancellation support and health probes#998
Merged
christineyu123 merged 3 commits intomasterfrom Mar 24, 2026
Merged
Conversation
Minimum allowed line rate is |
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
VLLMOpenAIModelClass(clarifai/runners/models/vllm_openai_class.py) — a parent class that vLLM model implementations can subclass instead of writing a standalonemodel.pyfrom scratch. Subclasses only need to implementload_model()to setself.server,self.client,self.model, andself.cancellation_handler.VLLMCancellationHandler— manages per-request cancellation viaregister_item_abort_callback. When the Clarifai runtime signals an abort, it sets athreading.Eventand closes the underlyinghttpxresponse, causing vLLM to detectis_disconnected(), abort the engine, and free KV cache.openai_stream_transportinVLLMOpenAIModelClasshandles both/chat/completionsand/responsesendpoints with full cancellation support (including the race condition where abort arrives before the stream starts).handle_liveness_probe/handle_readiness_probehit vLLM's/healthendpoint directly when a server is running; fall back to the base class behaviour when no server is set.tests/runners/test_vllm_openai_class.pywith 17 unit tests coveringVLLMCancellationHandlerstate transitions, health probe delegation, and streaming cancellation behaviour — no real vLLM process required.Test plan
uv run pytest tests/runners/test_vllm_openai_class.py -v)VLLMOpenAIModelClassin a model upload (e.g.trinity-mini-thinking-vllm) and verify abort cancels the running generation🤖 Generated with Claude Code