Skip to content

[ATOM gRPC] atomesh: route ATOM requests over the Session (13/14) - #3670

Closed
Jasen2201 wants to merge 1 commit into
jasen/atom-grpc-12-mesh-renderfrom
jasen/atom-grpc-13-mesh-session-routing
Closed

Jasen2201 wants to merge 1 commit into
jasen/atom-grpc-12-mesh-renderfrom
jasen/atom-grpc-13-mesh-session-routing

Conversation

@Jasen2201

@Jasen2201 Jasen2201 commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

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

Why

atomesh sent each request to an ATOM worker on a Generate call of its own, so the per-instance Session carried nothing. A relay request opened one call on P and another on D, where a Session carries every request to an instance on one call.

What changed

  • --atom-grpc-session sets RouterConfig.atom_grpc_session; GrpcRouter::new and GrpcPDRouter::new build their engine with it (GrpcEngine::with_atom_session).
  • AtomCalls::start is the one per-request call: the single path and each relay and chunked leg go through it, over a Generate call by default or the instance's Session with the flag.
  • Over the Session, a chat carrying a StructuredOutput calls PrepareStructuredOutput first and copies its four derived fields into the request's sampling.
  • request_spec turns the GenerateRequest into the RequestSpec the Session sends, its kv_transfer_params an engine_v1 Value.
  • Part 10's two dead-code allowances go; AtomStream::open lost its callers and is removed. atom/mesh/README.md describes ATOM gRPC workers and the flag.

Review focus

  1. The Session arm converts the GenerateRequest the payload became.
  2. Both instances' clients are still taken before P is sent.

Testing

The flag reaches the router config. Over an in-process Session stub, a chat runs after ATOM prepares its structured output, relay runs D once P completes, and chunked runs both legs at once and answers after P.

jasen/atom-grpc-13-mesh-session-routing @ 5a5823c: with atom-engine, 1412 lib and 303 integration tests passed. cargo fmt clean; clippy adds no warning of this PR's code.

GPU results

On DeepSeek-V4.1-Flash 6P16D, AgentX at 1,228 concurrent sessions, TTFT over gRPC is at parity with HTTP: it is bound by the prefill queue. No request failed.

GPU numbers

DeepSeek-V4.1-Flash, 6P16D (P TP2 DP2, D TP4 DP4, shared Mooncake Store), AgentX C1228 for 900 s, two runs per configuration, mean of the two. atomesh's prompt encoding came from ROCm/ATOM#3596 (fastokens) and its V4.1 chat render from ROCm/ATOM#3597, neither part of this stack; the stack's code was the integration branch at this stack's part 14.

HTTP gRPC + fastokens Session + fastokens
TTFT mean (s) 11.78 11.56 11.44
ITL mean (ms) 6.85 7.00 6.93
Output tok/s 34.7K 34.8K 34.9K
Prefix hit 95.6% 95.7% 95.7%
Failed requests 0 0 0

HTTP's two TTFT means were 0.34 s apart, more than either gRPC difference. GSM8K (lm_eval, 1,319 questions, 1P1D, twice each): gRPC 0.930 and 0.929, HTTP 0.927 and 0.930. Prompt token parity between atomesh's render and ATOM's HTTP chat: 59 of 59 (21 GSM8K, 38 AgentX and tool-call prompts).

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 5a5823c:

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                   1412 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 12):

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

🤖 Generated with Claude Code

With `--atom-grpc-session`, both gRPC routers send ATOM requests over each
instance's Session instead of a Generate call per request: the single path
and each relay and chunked leg go through `AtomCalls::start`. A chat
first calls `PrepareStructuredOutput` and copies its four derived fields
into the request's sampling. Without the flag nothing changes. `atom/mesh/README.md` describes
ATOM gRPC workers and the flag.

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

Copy link
Copy Markdown
Collaborator Author

Superseded by #3679 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