Repository navigation
[None][feat] Frontend Proto-over-ZMQ feasibility prototype (Server + tensorrt_llm/engine_client) - #3
Closed
JunyiXu-nv wants to merge 11 commits into
Closed
JunyiXu-nv wants to merge 11 commits into
JunyiXu-nv wants to merge 11 commits into
Conversation
…sorrt_llm/engine_client Move the nine frontend-side client modules out of tensorrt_llm/executor/ into top-level tensorrt_llm/engine_client/ without changing runtime behavior: executor.py, result.py, proxy.py, rpc_proxy.py, rpc_proxy_mixin.py, ray/executor.py -> ray_executor.py, postproc_worker.py, postprocessor_hook.py, and prompt_tail.py. Engine-used definitions stay under tensorrt_llm/executor/: - executor/logprobs.py: Logprob types and prompt-logprob helpers - executor/request.py: PostprocArgs and PostprocParams - executor/utils.py: PostprocWorkerConfig, ResponseWrapper, get_metrics_dict, and _check_collective_rpc_guard Keep FutureWarning compatibility shims for external callers (executor/__init__.py, executor/result.py, executor/postprocessor_hook.py, executor/ray/executor.py, executor/ray_executor.py) and update internal imports, serialization allowlists, legacy-file lists, CODEOWNERS, and CI multi-GPU trigger paths. Signed-off-by: JunyiXu-nv <219237550+JunyiXu-nv@users.noreply.github.com>
…e, and serve wiring Add the versioned trtllm.serve_engine.v1 (+ v1.1 Dynamo additions) Proto contract and implement the Phase 1 ZMQ-Proto frontend client stack: - tensorrt_llm/contracts/serve_engine/v1/: 8 .proto sources, v1.1 fields (P-2 sampled_at_unix_nanos, P-3 image_routing_version, P-4 KvEventSourceInfo), Python pb2 codegen script, and shared pickle-free ZMQ wire framing (zmq_wire.py). - tensorrt_llm/engine_client/: EngineClientInterface, CapabilityGate, RequestMapper, columnar FrameBuilder/decode_frame, pluggable EngineTransport + ZmqEngineTransport (DEALER<->ROUTER session/control + HMAC + zero-copy aux tensor frames), and ProtoEngineFacade. - tensorrt_llm/executor/proto_bridge.py: thin opt-in rank-0 ZMQ-Proto bridge behind TRTLLM_ENGINE_PROTOCOL=v1_zmq. - tensorrt_llm/serve/openai_server.py & commands/serve.py: wire EngineClientInterface / ProtoEngineFacade opt-in via TRTLLM_ENGINE_ENDPOINT while keeping existing startup and pickle paths unchanged. Signed-off-by: JunyiXu-nv <219237550+JunyiXu-nv@users.noreply.github.com>
…d HTTP E2E tests Add test coverage for the trtllm.serve_engine.v1 ZMQ-Proto frontend stack: - tests/test_common/engine_client/mock_proto_engine.py: real ZMQ-speaking mock engine implementing SessionService, ControlService (13 RPCs), columnar Frame emission, zero-copy aux tensors, disagg SignedHandoff / ReleaseHandoffs, and fault injection (ENGINE_DEAD, SubmitAck rejection). - tests/unittest/contracts/test_serve_engine_proto_sync.py: verifies generated _pb2 bindings stay in sync with .proto sources and v1.1 fields. - tests/unittest/engine_client/test_layering_and_shims.py: enforces pickle-free ZMQ wire modules, unidirectional engine_client/proto_bridge layering, and compatibility shim identity. - tests/unittest/engine_client/test_proto_zmq_stack.py: Hypothesis columnar Frame property tests, TensorRef inline/aux round-trip, HMAC tamper checks, CapabilityGate & RequestMapper checks, live multi-frontend ZMQ & Rank0ProtoBridge tests, and OpenAIServer HTTP ASGI E2E tests. - Register the three cpu_only test modules in l0_cpu.yml and apply small proto field fixes surfaced by the new tests. Signed-off-by: JunyiXu-nv <219237550+JunyiXu-nv@users.noreply.github.com>
…and metrics into Frontend Move runtime post-processing and output-side frontend responsibilities out of tensorrt_llm/executor/ into tensorrt_llm/engine_client/postproc_pool.py on the trtllm.serve_engine.v1 Proto path: - FrontendPostprocPool: handle-sharded frontend worker pool (strict per-handle ordering, replacing rank-0 PostprocWorker spawning). - Incremental detokenization, stop_index / text stop-string truncation, and explicit CancelBatch(CANCEL_REASON_STOP_STRING) emission when a text-level stop string triggers before engine completion. - post_processor_hook execution even when detokenize=False, emitting CancelBatch(CANCEL_REASON_POSTPROC_TERMINATE) on terminate() verdicts. - Frontend best_of > n selection by cumulative_logprob and FinalInfo usage/decoding/spec/timing extraction. - Add CPU unit and live ZMQ tests in test_frontend_postproc.py and register in l0_cpu.yml. Signed-off-by: JunyiXu-nv <219237550+JunyiXu-nv@users.noreply.github.com>
…handoff, and multimodal boundaries Complete the remaining boundary cleanups between Frontend and Engine on the trtllm.serve_engine.v1 Proto-over-ZMQ path: - tensorrt_llm/engine_client/handoff.py: implement DG-04/DG-60 opaque SignedHandoff / RendezvousTicket base64 helpers, frontend-readable key extraction, and HandoffReleaseTracker. - tensorrt_llm/serve/openai_protocol.py & openai_server.py: add optional signed_handoff_b64 and rendezvous_ticket_b64 fields on HTTP DisaggregatedParams and expose POST /_internal/release_handoffs delegating to ControlService.ReleaseHandoffs. - tensorrt_llm/engine_client/request_mapper.py: support both MEDIA (including v1.1 P-3 image uuid) and PREPROCESSED (zero-copy TensorRef over ZMQ aux frames) multimodal inputs alongside sparse logit_bias and declarative thinking_budget. - Add CPU unit and live ZMQ/HTTP tests in test_declarative_disagg_mm.py and register in l0_cpu.yml. Signed-off-by: JunyiXu-nv <219237550+JunyiXu-nv@users.noreply.github.com>
…e_for_ipc_batched and deserialize LlmResult Fix two issues discovered during real H100 NVL Qwen3-0.6B GPU A/B parity testing: - Intercept Rank0ProtoBridge responses inside BaseWorker.handle_for_ipc_batched using namespaced bridge client_ids instead of competing with await_response_thread on worker.await_responses(), and clean up worker._results on completion. - Deserialize serialized LlmResult payloads before reading output_token_ids and avoid double-calling GenerationRequest.set_id(). Signed-off-by: JunyiXu-nv <219237550+JunyiXu-nv@users.noreply.github.com>
Replace Chinese comments in the eight trtllm.serve_engine.v1 .proto files with concise English comments. Verified zero protobuf descriptor changes via scripts/generate_serve_engine_proto.py --check. Signed-off-by: JunyiXu-nv <219237550+JunyiXu-nv@users.noreply.github.com>
…ontend, wire, bridge, and serve Fix all P1/P2/P3 issues surfaced by the gpt-6.2-astra review of PR #3: - Frontend correctness & isolation (#1, #3, NVIDIA#7, NVIDIA#10, NVIDIA#11, NVIDIA#14, NVIDIA#15, NVIDIA#31, NVIDIA#33, NVIDIA#35): owned per-step stream snapshots, sticky aresult() future, single ordered outbound writer with batched aux blob_id rebasing, per-handle postproc exception isolation, prefix-safe streaming stop-string buffering preserving sibling n>1 choices, beam replace_from logprob alignment, chunked prompt logprobs / streaming tensor concatenation, async postproc dispatch, and aclose() waiter wakeup. - Request mapping, capabilities & wire hardening (#2, NVIDIA#5, NVIDIA#6, NVIDIA#8, NVIDIA#12, NVIDIA#17, NVIDIA#18, NVIDIA#20, NVIDIA#28, NVIDIA#29, NVIDIA#30, NVIDIA#32): lazy PEP 562 engine_client exports (no eager _pb2 import on default serve), sparse tuple logit_bias handling, DisaggScheduleStyle IntEnum mapping, sampling/beam cardinality and merged stop+bad token sequences, full TokenizerFingerprint and multimodal capability gating, BF16 TensorRef and strict CSR bounds validation, exact HTTP error status mapping, strict zmq_wire header checks, connection-unique DEALER identity, and late control RPC reply discarding. - Rank0ProtoBridge, worker & serve security/fidelity (#4, NVIDIA#9, NVIDIA#13, NVIDIA#16, NVIDIA#19, NVIDIA#21, NVIDIA#22, NVIDIA#23, NVIDIA#24, NVIDIA#25, NVIDIA#26, NVIDIA#27, NVIDIA#34, NVIDIA#36): session handshake/version negotiation and reconnect fencing, duplicate handle rejection and transactional rollback on submit failure, bounded HWM and max_rows_per_frame splitting, separate engine-only handoff HMAC key, camelCase GetKvCapacity, explicit UNSUPPORTED for unimplemented admin RPCs, atomic 0600 bridge info file with stop() cleanup, worker.py finally init, HTTP DisaggregatedParams envelope round-trip, authenticated POST /_internal/release_handoffs, and CLI hook/worker/endpoint wiring. - Add test_astra_review_regressions.py (registered in l0_cpu.yml) covering all fixes and language-independent wire vectors. Signed-off-by: JunyiXu-nv <219237550+JunyiXu-nv@users.noreply.github.com>
… gate, hook suppress/final error, multi-choice diffs, stream _done, signed handoff) Address all critical blockers and regressions caught by gpt-6.2-astra Round-2 review: - commands/serve.py (NVIDIA#9): import load_post_processor_hook (fixes ImportError on TRTLLM_ENGINE_ENDPOINT). - executor/worker.py (NVIDIA#18): check TRTLLM_ENGINE_PROTOCOL env var before importing proto_bridge so default pickled worker never touches protobuf bindings. - engine_client/postproc_pool.py (NVIDIA#11 + suppress regression): restore stream._done when final hook raises so stream.fail() wakes waiters, and sync out._raw_text = out.text after hook execution so suppressed chunks never resurface. - engine_client/facade.py (#1, NVIDIA#20, NVIDIA#34 + include_usage regression): advance sibling choice diff cursors on every row, add _done property and candidate_metrics on ProtoStreamStep/ProtoGenerationStream, and carry signed_handoff_b64 directly on output.disaggregated_params. - executor/proto_bridge.py (NVIDIA#15, NVIDIA#24): use O_EXCL + fchmod(0o600) + inode check on bridge info file, and keep routing intact during CancelBatch.all so terminal CANCELLED rows still deliver. Signed-off-by: JunyiXu-nv <219237550+JunyiXu-nv@users.noreply.github.com>
…d model vocab_size in verify_tokenizer Fix issue surfaced on real H100 Qwen3-0.6B parity run: - TransformersTokenizer inherits PreTrainedTokenizerBase whose outer .vocab_size raises NotImplementedError; check inner .tokenizer first and guard NotImplementedError. - Do not copy padded model.config.vocab_size (e.g., 151936 on Qwen3) into TokenizerFingerprint.vocab_size (151643). Signed-off-by: JunyiXu-nv <219237550+JunyiXu-nv@users.noreply.github.com>
…edError in verify_tokenizer Signed-off-by: JunyiXu-nv <219237550+JunyiXu-nv@users.noreply.github.com>
Owner
Author
|
Superseded by #4, which stacks cleanly on NVIDIA/TensorRT-LLM NVIDIA#23145/NVIDIA#23146/NVIDIA#23147 with zero duplicated moves or proto files. |
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
Feasibility prototype PR (5 structured commits) demonstrating the target Frontend (
Server+ top-leveltensorrt_llm/engine_client/) ↔ Pure Engine architecture on thetrtllm.serve_engine.v1(+ v1.1 Dynamo additions) Proto contract over ZMQ (Phase 1 transport).Key Design Decisions
tensorrt_llm/engine_client/(synced with QiJune): replaces serving-sidellmapi+proxyroles soserve/,llmapi/, andgrpc/share one client layer without cyclic or inverted dependencies.contracts/serve_engine/v1/zmq_wire.py):[hmac_sha256_32B, kind_1B, proto_bytes, aux_tensor_0, ...]over twoDEALER<->ROUTERchannels (SessionService+ 13ControlServiceRPCs), with large tensors carried as zero-copy ZMQ multipart aux frames (TensorRef). Designed so a future Rust frontend or gRPCengine_hosttransport can plug in cleanly.TRTLLM_ENGINE_PROTOCOL=v1_zmq(rank-0 thin bridge) andTRTLLM_ENGINE_ENDPOINT(frontend attachment), leaving the default pickled path untouched.Commit Breakdown
773e72a6c4) — Pure Move: Relocate the 9 existing frontend-side modules out oftensorrt_llm/executor/into top-leveltensorrt_llm/engine_client/withFutureWarningcompatibility shims and updated allowlists/CI lists.19ceb26551) — Core Proto-over-ZMQ Stack: Landtensorrt_llm/contracts/serve_engine/v1/(8.proto+ v1.1P-2/P-3/P-4+ codegen +zmq_wire.py), buildengine_client/{interface,capabilities,request_mapper,frame_decoder,transport,transport_zmq,facade}.py, add thin opt-inexecutor/proto_bridge.py, and wireserve/openai_server.py+commands/serve.py.51abf435bd) — Tests: Add real ZMQMockProtoEngine+ CPU unit, Hypothesis property, AST layering/pickle-free, shim identity, multi-frontendRank0ProtoBridge, andOpenAIServerHTTP ASGI E2E tests (registered inl0_cpu.yml).b3a97c9033) — Lift Postproc/Detok/Stop/Metrics Into Frontend: Addengine_client/postproc_pool.py(handle-sharded pool, incremental detok, text stop truncation + explicitCancelBatch(STOP_STRING)fixing H1,post_processor_hookwithdetokenize=False+CANCEL_REASON_POSTPROC_TERMINATE,best_of > nselection,FinalInfometrics extraction).5ed7b744ae) — Lift Declarative Request Prep, Disagg Handoff & Multimodal: Addengine_client/handoff.py(DG-04/DG-60),signed_handoff_b64/rendezvous_ticket_b64+POST /_internal/release_handoffs, sparselogit_bias/ declarativethinking_budgetengine-side materialization, andMEDIA(v1.1uuid) + zero-copyPREPROCESSEDmultimodal support.Verification
pre-commit(ruff,ruff-format,ruff-legacy,isort,yapf,l0_cpu.ymlAST, DCO sign-off).contracts/+engine_client/tests + 128 existingexecutor/tests).computelab-sc-01(4u4g-0074, NVIDIA H100 NVL 96GB, Slurm job6474375,Qwen3-0.6B):PyTorchLLM):tokens=[12095, 13, 576, 6722, 315, 9625, 374, 1083, 279, 6722, 315, 279],text=' Paris. The capital of France is also the capital of the'ProtoEngineFacade->ZmqEngineTransport->Rank0ProtoBridge->PyExecutor): exact 12/12 token & text matchOpenAIServerHTTP/health,/v1/completionsnon-streaming & SSEdata: [DONE]streaming): exact text match (COMPLETED 0:0).Additional Verification (Round-2 Review Fixes + 16xGB300 Kimi K3.1 Pro E2E)
gpt-6.2-astra): Completed Round-1 (36 findings) + Round-2 verification; fixed all P1/P2/P3 blockers and addedtests/unittest/engine_client/test_astra_review_regressions.py(CPU suite now 155 passed, 0 failed, lazy-import verified with 0 eager_pb2modules loaded).computelab-sc-01, Slurm job6660467,a1u1g-mil-0689,Qwen3-0.6B):COMPLETED 0:0, exact 12/12 token & HTTP text parity on latest fixes.nsc-lhr, isolated Slurm job1004125,nvl72d044-t[07,12,14,18]):COMPLETED 0:0in 9m00s (zero impact on production gateway/instances):0o600; handshakev1.1(vocab=163840);ControlServiceverifiedHEALTH_STATE_SERVING, v1.1sampled_at_unix_nanos, andGetKvCapacity(29,272blocks ×64=1,873,408tokens).trtllm-servevsProtoEngineFacade(non-stream + streaming snapshots) vsOpenAIServerHTTP (/v1/completionsnon-stream + SSEinclude_usage=true): exact text match (' Paris. It is known for the Eiffel Tower and the Louvre Museum.').nsc-lhr, isolated Slurm job1006127,nvl72d007-t[09,11,17-18]CTX +nvl72d037-t[11-12,15,17]GEN):COMPLETED 0:0in 8m40s (zero impact on production gateway/instances):INTEGRITY_SCHEME_HMAC_SHA256with shared engine-onlyTRTLLM_DISAGG_HANDOFF_KEY_HEX,GetKvCapacity(ctx_kv_blocks=29,272,gen_kv_blocks=41,270), and0o600discovery files.PHASE_CONTEXT_ONLYon 16xGB300 CTX) emitted opaqueSignedHandoff(first_toks=[17374], real NIXL endpointtcp://7.247.18.211:40323); tampered MAC rejected by GEN withERROR_CODE_HANDOFF_INVALID.PHASE_GENERATION_ONLYon 16xGB300 GEN via real cross-rack NIXL KV transfer, streamingsteps=3) matched baseline HTTP 1P1D NIXL Disagg byte-for-byte.ControlService.ReleaseHandoffsverified idempotent (RELEASED->NOT_FOUND).