Skip to content

[ATOM gRPC] The Session's step delivery: Completions without ids, atomesh's Session on its own thread (14/14) - #3671

Closed
Jasen2201 wants to merge 1 commit into
jasen/atom-grpc-13-mesh-session-routingfrom
jasen/atom-grpc-14-session-step-delivery
Closed

Jasen2201 wants to merge 1 commit into
jasen/atom-grpc-13-mesh-session-routingfrom
jasen/atom-grpc-14-session-step-delivery

Conversation

@Jasen2201

@Jasen2201 Jasen2201 commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Part 14/14 of the stack proposed in #3657. No blocking issues.

Why

Each Completions item resent all of its request's ids, which its StreamBatch entries had already carried. At DP4 and 1,024 concurrent requests, ranks finishing 14 or 15 requests together put about 1 MB on the Session's one HTTP/2 stream at once, and every later step queued behind it.

What changed

  • ATOM's Session sends Completions items without ids (session.py).
  • atomesh keeps a non-streaming request's ids from its StreamBatch entries and puts them in its Complete (Routes::step).
  • Each atomesh Session runs on a connection, thread and runtime of its own (session.rs run), off the router's runtime.

Review focus

  1. Session.flush: the client id read back from the engine's id, and the Completions item it builds.
  2. The Session thread's lifetime: it ends when its call does.

Testing

A non-streaming request over the Session completes with the ids its entries carried, and relay, chunked and a reopened Session complete as before. Measured on CPU instances with a stub model runner, the step lag p99 at 1,024 concurrent requests fell from 2.6 to 1.2 ms at DP1 and from 42 to 5.4 ms at DP4.

jasen/atom-grpc-14-session-step-delivery @ fb4f090: with atom-engine, 1413 lib and 303 integration tests passed; tests/entrypoints and the stack's Python tests, 3,390 passed. ruff, black, cargo fmt clean; clippy adds no warning of this PR's code.

Follow-ups

none

Stack

ATOM serves atom.grpc.v1.AtomEngine beside 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. [ATOM gRPC] Token-id prompts reuse block-hash chains; an idle EngineCore waits for input (1/14) #3658 Token-id prompts reuse block-hash chains; an idle EngineCore waits for input
  2. [ATOM gRPC] atomesh: share ATOM's P/D rank mapping and prefill-info parsing (2/14) #3659 atomesh: share ATOM's P/D rank mapping and prefill-info parsing
  3. [ATOM gRPC] The atom.grpc.v1 proto and its generated Python modules (3/14) #3660 The atom.grpc.v1 proto and its generated Python modules
  4. [ATOM gRPC] gRPC server: --grpc-port, info RPCs, Generate, Abort, structured output (4/14) #3661 gRPC server: --grpc-port, info RPCs, Generate, Abort, structured output
  5. [ATOM gRPC] gRPC server: the Session RPC and its engine_v1 frames codec (5/14) #3662 gRPC server: the Session RPC and its engine_v1 frames codec
  6. [ATOM gRPC] atomesh: compile ATOM's protos in every build (6/14) #3663 atomesh: compile ATOM's protos in every build
  7. [ATOM gRPC] atomesh: an ATOM gRPC client (7/14) #3664 atomesh: an ATOM gRPC client
  8. [ATOM gRPC] atomesh: discover ATOM gRPC workers, their model info and DP ranks (8/14) #3665 atomesh: discover ATOM gRPC workers, their model info and DP ranks
  9. [ATOM gRPC] atomesh: ATOM P/D over gRPC (9/14) #3666 atomesh: ATOM P/D over gRPC
  10. [ATOM gRPC] atomesh: the Session link to an ATOM instance (10/14) #3667 atomesh: the Session link to an ATOM instance
  11. [ATOM gRPC] atomesh: chat structured output to ATOM; refuse media and Responses (11/14) #3668 atomesh: chat structured output to ATOM; refuse media and Responses
  12. [ATOM gRPC] atomesh: gRPC chat and stream output as ATOM's HTTP routes give it (12/14) #3669 atomesh: gRPC chat and stream output as ATOM's HTTP routes give it
  13. [ATOM gRPC] atomesh: route ATOM requests over the Session (13/14) #3670 atomesh: route ATOM requests over the Session
  14. [ATOM gRPC] The Session's step delivery: Completions without ids, atomesh's Session on its own thread (14/14) #3671 The Session's step delivery: Completions without ids, atomesh's Session on its own thread

1 and 2 stand alone; 6 to 13 need only part 3 of the Python side; 14 changes both sides of the Session.

Evidence

In atom/mesh (rustc and clippy 1.100.0), at fb4f090:

cargo fmt --check                                         ok
cargo clippy --all-targets                                ok
cargo clippy --all-targets --features atom-engine         ok
cargo check --features ext-proc --tests                   ok
python3 proto/vendor_ext_proc.py --check                  ok
cargo test --features atom-engine --lib                   1413 passed, 0 failed, 7 ignored
cargo test --features atom-engine --test <each> -- --test-threads=1
                                                          303 passed, 0 failed, 1 ignored

Clippy against main cccc96a (warnings matched by message and file):

[clippy] base 108, branch 114, new 6, gone 0
  NEW x3: src/routers/render/tests.rs: warning: field assignment outside of initializer for an instance created with Default::default()
  NEW x1: src/routers/render/chat_aggregator.rs: warning: the `Err`-variant returned from this function is very large
  NEW x2: src/atom_engine/wire.rs: warning: using `chunks_exact` with a constant chunk size
[clippy-ae] base 110, branch 114, new 4, gone 0
  NEW x3: src/routers/render/tests.rs: warning: field assignment outside of initializer for an instance created with Default::default()
  NEW x1: src/routers/render/chat_aggregator.rs: warning: the `Err`-variant returned from this function is very large

Against the PR below (part 13):

[clippy] base 114, branch 114, new 0, gone 0
[clippy-ae] base 114, branch 114, new 0, gone 0

Python, at fb4f090: ruff check and black --check (26.10.1) on the 2 changed .py files, clean; pytest tests/entrypoints tests/test_grpc_proto.py tests/test_token_prefix_chains.py tests/test_engine_core_idle_wait.py tests/test_ci_latency_reports.py: 3,390 passed, 100 skipped, 0 failed.

The full CPU suite on this Python code against main cccc96a, on a host at load average 50 to 70: 14,947 passed and 13 failed, against main's 14,936 and 10.

  • Nine failures are main's: seven Engram host-path tests (no GPU), a Mooncake Store lookup timeout and a multiprocess-metrics restart test.
  • The other four time out in a subprocess or wait: a Unix socket path over 107 bytes under the run's basetemp (passes with a short one), and three subprocess import budgets of 20 to 30 s.
  • The import they time takes 19 to 32 s on main and on this branch alike here; main fails the same family under the same load.

The integration branch's end-to-end tests, not part of this stack, ran against the same code on CPU instances with a stub model runner, with atomesh built from it (single, P/D relay and chunked, DP P/D, 22 DP ranks, structured output, stops, refusals, Session): 290 passed and 2 failed. One is a timing case that reads an atomesh debug event this stack does not carry; the other, a P/D client-cancel case, passed 4 of 4 on a rerun.

🤖 Generated with Claude Code

…mesh's Session on its own thread (14/14)

ATOM's Session sends each Completions item without the request's ids,
which its StreamBatch entries already carried. At DP4 and 1,024
concurrent requests, ranks that finish 14 or 15 requests together resent
about 1 MB of ids at once on the Session's one HTTP/2 stream, and every
later step queued behind it. atomesh builds a non-streaming request's
output from its StreamBatch entries, and each atomesh Session runs on a
connection, thread and runtime of its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Jasen2201

Copy link
Copy Markdown
Collaborator Author

Superseded by #3674 and #3678 after regrouping by function (see #3657).

@Jasen2201 Jasen2201 closed this Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant