Repository navigation
Conversation
…ec (5/14) `AtomEngine.Session` carries many requests on one bidirectional stream of engine_v1 messages. `atom/entrypoints/grpc/frames.py` turns a SubmitBatch into one request per entry in the form `InputOutputProcessor.preprocess` takes, and an Abort into seq ids; it writes Ready, StreamBatch, Completions and Rejected, with buffers read through their refs, little-endian data and a protocol version check. Missing sampling fields read as the HTTP routes fill omitted ones; media, n above 1, negative prompt ids and kv_transfer_params engine_v1 cannot express come back as INVALID rejections. Each request is admitted as Generate admits one, under a per-Session seq_id window (`session.py`: 127 windows of 2^24 ids, with the API process's own ids wrapping below them). Each engine step is answered with one StreamBatch, then the step's Completions or Rejected items (INVALID for a 4xx, OVERLOADED for 503, INTERNAL otherwise). An Abort, or the end of the call, aborts its requests as the HTTP stream teardown does; a window returns once its last request ends. `preprocess` takes the caller's seq_id, and structured-output admission counts stop ids as stop strings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 21, 2026
Closed
Closed
Collaborator
Author
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.
Part 5/14 of the stack proposed in #3657. No blocking issues.
Why
With Generate, every request holds its own stream, so a step of 1,024 streaming requests leaves an instance as 1,024 messages. The Session carries an instance's requests on one stream as engine_v1 messages, one StreamBatch per engine step, and ATOM answered it UNIMPLEMENTED.
What changed
frames.py:decode_clientturns a SubmitBatch into one request per entry in the formpreprocesstakes, and an Abort into seq ids;encode_ready,encode_stream,encode_completionsandencode_rejectedwrite the server's messages.FrameError.AtomEngine.Sessionadmits each request as Generate does, under a per-Session seq_id window (session.py: 127 windows of 2^24 ids; the API process's own ids wrap below them).preprocesstakes the caller'sseq_id, and structured-output admission counts stop ids as stop strings, as it counts a chat's stop strings over HTTP.Review focus
frames._sampling: how absent fields read.Session.flush: what a StreamBatch entry and a Completions item carry.Sessions.open).Testing
jasen/atom-grpc-05-session@ 97da97b: the full CPU suite on this PR's Python code, parts 6 to 13 on top (they change no Python), fails only where main fails; 14,943 passed. ruff, black clean.Follow-ups
none
Stack
ATOM serves
atom.grpc.v1.AtomEnginebeside its HTTP server (token ids in, token ids out, ATOM's P/D flow unchanged), and atomesh routes to ATOM gRPC workers, over a Generate call per request or one Session per instance. Bottom to top:1 and 2 stand alone; 6 to 13 need only part 3 of the Python side; 14 changes both sides of the Session.
Evidence
At 97da97b: ruff check and black --check (26.10.1) on the 4 changed .py files, clean.
The full CPU suite (
pytest tests/ --ignore=tests/plugin --ignore=tests/entrypoints/test_openai_server.py --ignore=tests/test_atomesh_mooncake_store.py) on this PR's Python code, with parts 6 to 13 on top (they change no Python), against main cccc96a:test_simulated_tpon its fixed port 29591, held by main's run beside it; alone, 9 passed.test_server_entrypoints_initialize_native_storage_before_import, whose 30 s budget covers an import that takes 27 to 41 s here on main and on the top alike.The integration branch's end-to-end tests, not part of this stack, ran against this branch on CPU instances with a stub model runner (ATOM's own server, CoreManager, EngineCore, Scheduler and BlockManager; atomesh's routers left out):
test_frames11,test_grpc_session13,test_grpc_generate16,test_grpc_info16,test_grpc_structured_output4,test_grpc_refusals_pp_dcp4 andtest_proto5 passed, 118 in all with the stub's own tests.After
frames.pylost the client half the dropped tests used (encode_submit,encode_abort,decode_serverand their helpers), at 97da97b the gRPC modules import andtests/test_grpc_proto.pypasses; at the stack's top fb4f090,tests/entrypointswith the stack's own tests: 3,390 passed, 0 failed.🤖 Generated with Claude Code