Repository navigation
Conversation
The CoreManager <-> EngineCore messages are the msgspec structs of zmq_protocol/messages.py (3/N's spec, which atom/mesh's wire.rs mirrors), encoded by zmq_protocol/codec.py, in place of pickled tuples whose payload was a whole Sequence. - Submit: each sequence goes as the SubmitItem that rebuilds it; the Core builds its Sequence through admission.build_sequence, which fills in what it derives from its own config and refuses what the frontend refuses (check_sampling, structured execution options, the model's own validation, an empty prompt, a media-kept decode leg's MRoPE delta and RapidServe's refusal of one), since a client other than this frontend skips the frontend's checks. LLMEngine's InputOutputProcessor runs the same rules from admission. - Output: STREAM items and finished Completions that read like the finished Sequence; share_cache's DP_PREFIX_CREDIT / PREFILL_BACKLOG / DP_REUSE ride the same protocol; metrics and utility replies are pickled inside their message. - A request that does not encode, or whose result does not, ends alone as rejected; a failed add leaves no request state behind. - An abort that overtakes its submit is held in O(1), in the decode scheduler too; a request refused at admission counts as ingested. - A client's prefix_cache_hit_tokens is taken only as an int count of the prompt. The cross-language fixtures 3/N's Rust tests read are checked from Python too (test_engine_wire_cross_language).
This branch has not been deployed
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.
Motivation
Every message between CoreManager and EngineCore is a pickled tuple whose payload is a whole
Sequence, in both directions. A finished sequence returns every field although the frontend reads about fifteen, and pickle is Python-only, which keeps a Rust client (#3908'sEngineClient) from talking to the Core.#3908 (3/N) defined the protocol in
atom/model_engine/zmq_protocol/messages.pyas msgspec structs, which Rust mirrors. This PR puts the Python engine on it. msgpack through msgspec is under pickle on every measured path (encode + decode, one core, median of two runs; measured for #3372 against main's pickle at the time withbench_v2.py, not re-run here):Series: #3908 (3/N, Rust: protocol,
EngineClient,DirectDispatcher) -> this PR (4/N, Python engine on the protocol) -> #3912 (5/N, the launcher's--engine-dispatch direct). Nothing here changes what a client sees; the classic api_server, atomesh's TokenBridge and offlineLLMEngineall run on it.Technical Details
zmq_protocol/codec.py): each request goes as theSubmitItemthat rebuilds itsSequence; each step's tokens as STREAM items; a finished request as aCompletionthat reads like the finishedSequence. Bulk numbers (tokens, logprobs, hashes) ride as little-endian bytes; media tensors beside their pickle as raw buffers. What only Python reads (utility commands and replies, metrics, KV-transfer params) is pickled inside its field.share_cache's DP_PREFIX_CREDIT / PREFILL_BACKLOG / DP_REUSE ride the same protocol.model_engine/admission.py): the Core builds eachSequencethroughbuild_sequence, filling in what it derives from its own config, and refuses what the frontend refuses, in its order:check_sampling, a structured request's execution options, the model's ownvalidate_request, andcheck_prompt(an empty prompt; a media-kept decode leg's MRoPE delta outside its prompt, feat(engine): multimodal PD through the chat path #3410; RapidServe's refusal of such a leg). A client other than this frontend skips the frontend's checks.InputOutputProcessor.preprocess_fanoutruns the same functions, so the two cannot drift.rejected: ...; a failed add leaves no request state behind, online or offline; a request refused at admission counts as ingested.prefix_cache_hit_tokensis taken only as an int count of the prompt, else 0.registry.uses_mrope), without copying the prompt otherwise.Test Plan
test_engine_wire_codec.py(each message both ways, refusals, views vs copies),test_engine_wire_cross_language.py(theclient_*fixtures [3/N atomesh rust runtime] feat(mesh): msgspec EngineCore protocol, Rust EngineClient and DirectDispatcher #3908's Rust wrote decode here; thecore_*ones Python writes are what Rust reads),test_submit_isolation.py,test_unmatched_abort_hold.py,test_engine_credit_backlog_snapshot.py, plus the existing DP / scheduler / admission suites.tests/against [3/N atomesh rust runtime] feat(mesh): msgspec EngineCore protocol, Rust EngineClient and DirectDispatcher #3908's head in the same container; only the differences counted.Test Result
tests/run against [3/N atomesh rust runtime] feat(mesh): msgspec EngineCore protocol, Rust EngineClient and DirectDispatcher #3908's head in the same container differed in 3 tests only (test_pd_prompt_token_ids.py, a hand-builtInputOutputProcessorwithoutuses_mrope), fixed here; the container's ~1.8k environment failures (an older aiter, GPU kernels) are the same on both."known" is main's behaviour (completions
logprobsignored; Qwen3 tool calls as text, no ATOM parser for its format); "refused" is the Rust frontend's documented 400 on logprobs. All within the run-to-run spread of earlier runs on this model (0.830–0.845 flexible).Submission Checklist
🤖 Generated with Claude Code