Skip to content

[ATOM gRPC] atomesh: route ATOM requests over the Session (--atom-grpc-session) - #3679

Open
Jasen2201 wants to merge 45 commits into
jasen/atom-grpc-g-mesh-session-linkfrom
jasen/atom-grpc-h-mesh-session-routing
Open

Jasen2201 wants to merge 45 commits into
jasen/atom-grpc-g-mesh-session-linkfrom
jasen/atom-grpc-h-mesh-session-routing

Conversation

@Jasen2201

@Jasen2201 Jasen2201 commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Part H of the 8 PRs proposed in #3657 (regrouped by function). No blocking issues.

Based on G; it needs F and G, and at runtime the Session RPC that C serves.

Why

atomesh sent each request to an ATOM worker on a Generate call of its own. 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 via RouterConfigBuilder::atom_grpc_session, which embedders can call too.
  • AtomCalls::start is the one per-request call for the single path and each relay and chunked leg: a Generate call, or the instance's Session with the flag.
  • Over the Session, a chat calls PrepareStructuredOutput first and copies its four derived fields into the request's sampling. Its RequestSpec carries dp_session_id and dp_parent_session_id.
  • Both gRPC routers pass their worker registry, so a removed instance's Session is released.
  • G's dead-code allowances go, and 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

Over an in-process Session stub, a chat runs after ATOM prepares its structured output and carries its session ids. Relay runs D once P completes, chunked runs both legs at once, and a removed instance's Session is released.

jasen/atom-grpc-h-mesh-session-routing @ e1041c8: all tests pass, with and without atom-engine (Evidence); gRPC Python: 115 passed. cargo fmt clean; clippy adds no warning.

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. One linear stack, merged bottom to top: A, B, C, D, E, F, G, H; each PR's base is the one before it.

Evidence

In atom/mesh (rustc and clippy 1.100.0), at e1041c8: cargo fmt --check passes, and cargo clippy --all-targets, with and without atom-engine, warns on none of the lines this PR adds.

cargo test --features atom-engine --lib            1567 passed, 0 failed
cargo test --features atom-engine --test <each>    304 passed, 0 failed
cargo test --lib                                   1562 passed, 0 failed
cargo test --test <each>                           304 passed, 0 failed

The integration branch's end-to-end tests, not part of this stack, ran against the whole stack 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 reading 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

Jasen2201 and others added 2 commits November 21, 2026 13:42
Each ATOM instance gets one Session, shared by its ranks and opened by its
first request. Outputs are split by seq_id into one stream per request that
carries what a Generate call sends, so `AtomStream` turns it into token
chunks; a dropped request sends Abort, a broken Session fails its requests
and the next request opens a new one, a Ready of another protocol version
is refused, and seq ids stay below 2^24. Nothing routes requests over it until
`--atom-grpc-session`.

A non-streaming request's ids are kept from its StreamBatch entries for
its Complete, since a Completions item carries none, and each Session runs
on a connection, thread and runtime of its own, off the router's runtime.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…c-session)

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.

This branch carries the Session link's commit, which it builds on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mod.rs, stream.rs and session_test.rs under engine/atom keep this branch's
version: it already holds the Session link's change to them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Jasen2201
Jasen2201 changed the base branch from jasen/atom-grpc-f-mesh-chat-render to jasen/atom-grpc-g-mesh-session-link November 23, 2026 07:59
@Jasen2201
Jasen2201 added this pull request to stack #3735 November 23, 2026 07:59
…lds at their defaults

GetServerInfoResponse now also carries kv_event_sources_json.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 23, 2026 09:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The opt-in ATOM gRPC Session routing change has no active review issues.

1 open issue

Review effort: Balanced

…on routing

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 24, 2026 16:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the opt-in ATOM gRPC Session routing change.

1 open issue

Review effort: Balanced

…on routing

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 24, 2026 17:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the opt-in gRPC Session routing change.

1 open issue

Review effort: Balanced

…late admission, per-call Qwen arguments, conservative cut-off close) into Session routing

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 24, 2026 18:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the opt-in ATOM gRPC Session transport integration.

1 open issue

Review effort: Balanced

…rker's removal into Session routing

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 24, 2026 21:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The opt-in ATOM gRPC Session routing change has no active review issues.

1 open issue

Review effort: Balanced

…uctured output's fixes into routing over the Session

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 24, 2026 21:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the opt-in ATOM Session routing integration.

1 open issue

Review effort: Balanced

…outes over the Session

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 26, 2026 14:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are identified for the optional ATOM gRPC Session integration.

1 open issue

Review effort: Balanced

--atom-grpc-session sits beside main's --atom-pd-concurrent and the
kv-storage options in the CLI and router config.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 27, 2026 14:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the opt-in ATOM Session routing change.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

This branch has not been deployed

No deployments
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.

3 participants