Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ Frontend ] Multiprocessing for OpenAI Server with zeromq #6883

Merged
merged 84 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
bed649a
:alembic: add backend proto file
joerunde Jul 25, 2024
7de9d49
:recycle: move proto to grpc/pb
joerunde Jul 25, 2024
9394a62
:sparkles: add proto compilation
joerunde Jul 25, 2024
dd8bf96
updated
robertgshaw2-neuralmagic Jul 25, 2024
5c7fbff
kinda working
robertgshaw2-neuralmagic Jul 25, 2024
952e8ef
:construction: more wip
joerunde Jul 25, 2024
e8eac95
fixed
robertgshaw2-neuralmagic Jul 25, 2024
938a843
:bug: fixup race condition
joerunde Jul 25, 2024
2b8d7cd
:bug: remove timeout
joerunde Jul 25, 2024
ea02d39
format
robertgshaw2-neuralmagic Jul 26, 2024
4a2dc46
streaming
robertgshaw2-neuralmagic Jul 26, 2024
30f2bc9
removed breaks
robertgshaw2-neuralmagic Jul 26, 2024
c718b68
pushing current state
robertgshaw2-neuralmagic Jul 26, 2024
b3d25c6
:alembic: try unix sockets
joerunde Jul 26, 2024
2765b17
:zap: no background loop
joerunde Jul 26, 2024
b219778
spurious change
robertgshaw2-neuralmagic Jul 26, 2024
932ea23
remove spurious change
robertgshaw2-neuralmagic Jul 26, 2024
f029114
spurious changes
robertgshaw2-neuralmagic Jul 26, 2024
6854758
spurioous change
robertgshaw2-neuralmagic Jul 26, 2024
3b5ff66
:bug: whoops
joerunde Jul 26, 2024
79247c3
:memo: log stuff
joerunde Jul 26, 2024
a39ebc0
stash
robertgshaw2-neuralmagic Jul 26, 2024
ef257f1
pushing up
robertgshaw2-neuralmagic Jul 26, 2024
a6c9bc5
stash
robertgshaw2-neuralmagic Jul 28, 2024
d7490bc
actually working
robertgshaw2-neuralmagic Jul 28, 2024
f68fd60
cleanup
robertgshaw2-neuralmagic Jul 28, 2024
38b5b9c
more cleanup
robertgshaw2-neuralmagic Jul 28, 2024
bc54311
cleanup
robertgshaw2-neuralmagic Jul 28, 2024
3cccebb
stash
robertgshaw2-neuralmagic Jul 28, 2024
4b78e29
more cleanup
robertgshaw2-neuralmagic Jul 28, 2024
345bfdd
setup
robertgshaw2-neuralmagic Jul 28, 2024
cfbb001
cleanup
robertgshaw2-neuralmagic Jul 28, 2024
d811b42
format
robertgshaw2-neuralmagic Jul 28, 2024
852534e
cleaning up
robertgshaw2-neuralmagic Jul 28, 2024
e42be96
zlib
robertgshaw2-neuralmagic Jul 28, 2024
5202a59
Revert "zlib"
robertgshaw2-neuralmagic Jul 28, 2024
71b1bf9
turn on chunked prefill
robertgshaw2-neuralmagic Jul 28, 2024
a499079
move RPC code into oai server
robertgshaw2-neuralmagic Jul 29, 2024
88a1d08
format
robertgshaw2-neuralmagic Jul 29, 2024
13ce2f1
format
robertgshaw2-neuralmagic Jul 29, 2024
bb8ac06
trying to flow it through
robertgshaw2-neuralmagic Jul 29, 2024
6ebdb3d
cleaning
robertgshaw2-neuralmagic Jul 29, 2024
24c8100
cleaning
robertgshaw2-neuralmagic Jul 29, 2024
e707049
cleaning
robertgshaw2-neuralmagic Jul 29, 2024
baaf6bc
add stubs
robertgshaw2-neuralmagic Jul 29, 2024
9d19d92
format
robertgshaw2-neuralmagic Jul 29, 2024
f1be4b8
working with single launch...
robertgshaw2-neuralmagic Jul 29, 2024
8e417ad
working end to end - with some hacks
robertgshaw2-neuralmagic Jul 29, 2024
4c16c5e
:goal_net: handle shutdown and request errors
joerunde Jul 29, 2024
6ddd4a7
:art: fmt and clean up shutdown handler
joerunde Jul 29, 2024
6d7da74
:bug: fixup type hint for queue
joerunde Jul 29, 2024
97ea04d
:sparkles: update chat endpoint
joerunde Jul 29, 2024
6d753a4
:bug: fixup zmq constant types
joerunde Jul 29, 2024
38e308e
:sparkles: hook up de/tokenize
joerunde Jul 29, 2024
ec19a7b
:recycle: add VLLMBackend protocol
joerunde Jul 29, 2024
453939b
Frontend mp flag (#384)
joerunde Jul 30, 2024
1f33286
Features / Cleanup for MP Frontend (#387)
robertgshaw2-neuralmagic Jul 31, 2024
5362952
Use random port for backend (#390)
joerunde Jul 31, 2024
7214fb8
Await socket operations + some other minor cleanup (#391)
njhill Jul 31, 2024
98a7dab
:sparkles: health check round 2 (#392)
joerunde Jul 31, 2024
f5f0b45
Add tokenizer (#394)
robertgshaw2-neuralmagic Jul 31, 2024
0b351c0
Socket context (#393)
joerunde Jul 31, 2024
79fcc44
Logit bias (#395)
robertgshaw2-neuralmagic Jul 31, 2024
9da8c4a
Merge remote-tracking branch 'upstream/main' into isolate-oai-server-…
joerunde Jul 31, 2024
4c65f74
:bug: messed up the revert in the merge commit :(
joerunde Jul 31, 2024
9bc97f1
fix (#396)
robertgshaw2-neuralmagic Jul 31, 2024
68d8612
Merge remote-tracking branch 'upstream/main' into isolate-oai-server-…
joerunde Jul 31, 2024
4337fe7
format
robertgshaw2-neuralmagic Aug 1, 2024
779d9bd
stash
robertgshaw2-neuralmagic Aug 1, 2024
a6044a3
Fix failed tests (#398)
robertgshaw2-neuralmagic Aug 1, 2024
100189f
Merge branch 'main' into isolate-oai-server-process
robertgshaw2-neuralmagic Aug 1, 2024
0fc8545
fixed merge conflicts
robertgshaw2-neuralmagic Aug 1, 2024
6383091
updated
robertgshaw2-neuralmagic Aug 1, 2024
a09f57f
cleaning
robertgshaw2-neuralmagic Aug 1, 2024
1bdbfcb
:white_check_mark: add test for multiprocessing flag (#399)
joerunde Aug 1, 2024
f3c0f1c
:sparkles: pipe tracing flag (#400)
joerunde Aug 1, 2024
9c415ad
integration tests for old backend
robertgshaw2-neuralmagic Aug 1, 2024
62036ad
rename
robertgshaw2-neuralmagic Aug 1, 2024
a177d87
cleaning
robertgshaw2-neuralmagic Aug 1, 2024
9ca3b93
ordering
robertgshaw2-neuralmagic Aug 1, 2024
f8b5fb1
fix embedding model feedback
robertgshaw2-neuralmagic Aug 1, 2024
fca5a71
Update vllm/entrypoints/openai/rpc/server.py
robertgshaw2-neuralmagic Aug 1, 2024
5f07f86
format
robertgshaw2-neuralmagic Aug 1, 2024
bd0fd76
Merge branch 'main' into isolate-oai-server-process
robertgshaw2-neuralmagic Aug 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
format
  • Loading branch information
robertgshaw2-neuralmagic committed Aug 1, 2024
commit 5f07f866b6d2bcca90c5be636b63c8cebedbb3ee
13 changes: 7 additions & 6 deletions vllm/entrypoints/openai/api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@

_running_tasks: Set[asyncio.Task] = set()


def model_is_embedding(model_name: str) -> bool:
return ModelConfig(model=model_name,
tokenizer=model_name,
tokenizer_mode="auto",
trust_remote_code=False,
seed=0, dtype="float16").embedding_mode
seed=0,
dtype="float16").embedding_mode


@asynccontextmanager
Expand Down Expand Up @@ -94,27 +96,26 @@ async def build_async_engine_client(args) -> AsyncIterator[AsyncEngineClient]:
# Backend itself still global for the silly lil' health handler
global async_engine_client


# If manually triggered or embedding model, use AsyncLLMEngine in process.
# TODO: support embedding model via RPC.
if (model_is_embedding(args.model) or
args.disable_frontend_multiprocessing):
if (model_is_embedding(args.model)
or args.disable_frontend_multiprocessing):
async_engine_client = AsyncLLMEngine.from_engine_args(
engine_args, usage_context=UsageContext.OPENAI_API_SERVER)
yield async_engine_client
return

# Otherwise, use the multiprocessing AsyncLLMEngine.
else:
# Start the RPC Server in separate process (holds the AsyncLLMEngine).
# Start RPCServer in separate process (holds the AsyncLLMEngine).
port = get_open_port(envs.VLLM_RPC_PORT)
rpc_server_process = Process(target=run_rpc_server,
args=(engine_args,
UsageContext.OPENAI_API_SERVER,
port))
rpc_server_process.start()

# Build the RPC Client, which conforms to the AsyncEngineClient protocol.
# Build RPCClient, which conforms to AsyncEngineClient Protocol.
async_engine_client = AsyncEngineRPCClient(port)
await async_engine_client.setup()

Expand Down
6 changes: 4 additions & 2 deletions vllm/entrypoints/openai/serving_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ async def create_chat_completion(
) = self._maybe_get_adapters(request)

model_config = self.model_config
tokenizer = await self.async_engine_client.get_tokenizer(lora_request)
tokenizer = await self.async_engine_client.get_tokenizer(
lora_request)

conversation: List[ConversationMessage] = []
mm_futures: List[Awaitable[MultiModalDataDict]] = []
Expand Down Expand Up @@ -161,7 +162,8 @@ async def create_chat_completion(
if mm_data is not None:
engine_inputs["multi_modal_data"] = mm_data

is_tracing_enabled = await self.async_engine_client.is_tracing_enabled()
is_tracing_enabled = (
await self.async_engine_client.is_tracing_enabled())
trace_headers = None
if is_tracing_enabled and raw_request:
trace_headers = extract_trace_headers(raw_request.headers)
Expand Down
10 changes: 6 additions & 4 deletions vllm/entrypoints/openai/serving_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ async def create_completion(self, request: CompletionRequest,
prompt_adapter_request,
) = self._maybe_get_adapters(request)

tokenizer = await self.async_engine_client.get_tokenizer(lora_request)
tokenizer = await self.async_engine_client.get_tokenizer(
lora_request)

guided_decode_logits_processor = (
await self._guided_decode_logits_processor(request, tokenizer))
Expand Down Expand Up @@ -119,8 +120,8 @@ async def create_completion(self, request: CompletionRequest,
lora_request=lora_request,
prompt_adapter_request=prompt_adapter_request)

is_tracing_enabled = await self.async_engine_client.is_tracing_enabled(
)
is_tracing_enabled = (
await self.async_engine_client.is_tracing_enabled())
trace_headers = None
if is_tracing_enabled:
trace_headers = extract_trace_headers(raw_request.headers)
Expand Down Expand Up @@ -231,7 +232,8 @@ async def completion_stream_generator(

# Abort the request if the client disconnects.
if await raw_request.is_disconnected():
await self.async_engine_client.abort(f"{request_id}-{prompt_idx}")
await self.async_engine_client.abort(
f"{request_id}-{prompt_idx}")
raise StopAsyncIteration()

for output in res.outputs:
Expand Down
3 changes: 2 additions & 1 deletion vllm/entrypoints/openai/serving_embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ async def create_embedding(self, request: EmbeddingRequest,
prompt_adapter_request,
) = self._maybe_get_adapters(request)

tokenizer = await self.async_engine_client.get_tokenizer(lora_request)
tokenizer = await self.async_engine_client.get_tokenizer(
lora_request)

pooling_params = request.to_pooling_params()

Expand Down
2 changes: 1 addition & 1 deletion vllm/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def get_span_exporter(endpoint):
OTLPSpanExporter)
elif protocol == "http/protobuf":
from opentelemetry.exporter.otlp.proto.http.trace_exporter import (
OTLPSpanExporter)
OTLPSpanExporter) # type: ignore
else:
raise ValueError(
f"Unsupported OTLP protocol '{protocol}' is configured")
Expand Down
Loading