Skip to content

[ATOM gRPC] atomesh: an ATOM gRPC client, ATOM's protos in every build, the shared P/D rank mapping - #3675

Open
Jasen2201 wants to merge 49 commits into
jasen/atom-grpc-c-session-serverfrom
jasen/atom-grpc-d-mesh-client
Open

Jasen2201 wants to merge 49 commits into
jasen/atom-grpc-c-session-serverfrom
jasen/atom-grpc-d-mesh-client

Conversation

@Jasen2201

@Jasen2201 Jasen2201 commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

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

Based on C, the PR below it; it compiles B's proto and uses none of C's code.

Why

atomesh's gRPC router spoke only SGLang's and vLLM's protocols, its shipped binary compiled neither ATOM proto, and ATOM's P/D rank mapping was private to the HTTP P/D router.

What changed

  • apply_atom_pd_rank_mapping_policy and parse_atom_prefill_info move from PDRouter to core/placement/backend/atom.rs, unchanged, so a gRPC P/D router picks the same ranks.
  • The default grpc-client feature compiles engine_v1 and atom.grpc.v1 from the repository root (build.rs); Inbound decodes ZMQ messages and gRPC Frames alike, and build_mesh.sh copies both protos beside the mesh.
  • AtomClient (RuntimeType::Atom): a GenerateRequest carries stop strings and stop_token_ids as id sequences, the DP rank and the DP session headers; logprobs get 400; any reply size is read.
  • Unstreamed, each sibling's Complete comes back in index order with its timing. A refusal keeps ATOM's HTTP status; a drop cancels the call.
  • AtomStream and the P/D merger report a SourceClock: TTFT and e2e_latency count from the start.

Size: over 1,000 lines and 15 files: the client cannot build without the proto compile, and both carry the build scripts and CI paths they touch.

Review focus

  1. The two compile passes and the extern_path in build.rs.
  2. A streamed ATOM response begins at its first message, which decides the status.

Testing

Against in-process ATOM stubs: the GenerateRequest, chunks and siblings in order, statuses, cancel on drop, TTFT and e2e_latency, a 5 MiB reply. test_ci_latency_reports.py sees both protos copied.

jasen/atom-grpc-d-mesh-client @ 2159bdb: lib and integration tests pass with and without atom-engine; the Python tests reaching the build scripts pass; fmt clean, no new clippy warning.

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 fbbe59a: cargo fmt --check, cargo clippy --all-targets with and without atom-engine, cargo check --features ext-proc --tests and proto/vendor_ext_proc.py --check pass.

cargo test --features atom-engine --lib            1375 passed, 0 failed, 7 ignored
cargo test --features atom-engine --test <each>    303 passed, 0 failed, 1 ignored

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

[clippy] base 108, branch 110, new 2, gone 0
  NEW x2: src/atom_engine/wire.rs: warning: using `chunks_exact` with a constant chunk size
[clippy-ae] base 110, branch 110, new 0, gone 0

Python, on this branch: ruff and black clean on tests/test_ci_latency_reports.py; tests/entrypoints with the test files reaching the changed modules, test_ci_latency_reports.py among them, 7,315 passed, the one failure the import timeout B's evidence describes.

The two clippy warnings come from main's atom_engine/wire.rs, which the default build now compiles; main shows them under atom-engine.

🤖 Generated with Claude Code

…d, the shared P/D rank mapping

`apply_atom_pd_rank_mapping_policy` (none or idx2idx over the worker
registry) and `parse_atom_prefill_info` (tp_size, kv_role and the chunked
template from one `/kv_transfer_info` body) move from `PDRouter` into
`core/placement/backend/atom.rs` beside `AtomAdapter`, unchanged but for
parameters replacing `&self`, so a gRPC P/D router can pick the same ranks
as the HTTP one. The HTTP router calls both, with the same results, error
texts and log lines as before.

The default `grpc-client` feature compiles engine_v1 and atom.grpc.v1 from
the repository root: engine_v1 into `atom_engine::wire::pb`, and
atom.grpc.v1's messages, client and server into `atom_engine::grpc`.
`atom_engine::wire` builds in every default build, and `Inbound` decodes
any frame that derefs to bytes, a ZMQ message or a gRPC `Frames` entry;
`link`, `spec` and zmq stay behind `atom-engine`, which turns on
`grpc-client`.

`build_mesh.sh` copies the mesh to `atom/mesh` and both protos to their
repository paths beside it; `setup_mesh.sh`, `MANIFEST.in` and the
mocker workflow count the two protos as atomesh build inputs.

atomesh talks to an ATOM worker over `atom.grpc.v1`: a request reaches
ATOM as a GenerateRequest with its stop strings turned into token ids and
the worker's DP rank attached, ATOM's stream comes back as tokens in order,
a refusal carries ATOM's HTTP status (`EngineError::Http`), and dropping a
request cancels the call. The tokenizer reaches dispatch through
`Dispatcher::dispatch_with_tokenizer`; ATOM gets its own `AtomStream`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Jasen2201 and others added 2 commits November 22, 2026 13:40
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@valar-cop valar-cop left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

some changes needed..

ci green.

n: Some(sampling.n.max(0) as u32),
..Default::default()
}),
stop_token_sequences: stop_token_sequences(stops, tokenizer)?,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

stop_token_ids and return_logprob are dropped here, so a stop id never stops the engine and logprobs return nulls instead of ATOM's 4xx. append stop_token_ids to stop_token_sequences and set the logprobs oneof, add a test for each?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thanks; the halves differ, since a gRPC answer should match ATOM's HTTP route.

Where ATOM's HTTP routes decide this
  • ChatCompletionRequest and CompletionRequest (atom/entrypoints/openai/protocol.py) declare no stop_token_ids and set extra="ignore", so a stop id never stops the engine over HTTP; adding it to stop_token_sequences would make gRPC differ.
  • The HTTP chat route returns logprobs, which Generate does not carry, so a silent null would differ; a 400 says so instead.
  • /v1/completions always answers "logprobs": None (serving_completion.py).
  • The refusal sits beside the media one in routers/grpc/router.rs and pd_router.rs; the router tests add a row per route, regular and P/D.

// Absent, ATOM applies its HTTP routes' default.
max_tokens: sampling.max_new_tokens.map(i64::from),
ignore_eos: sampling.ignore_eos,
stop_strings: payload.stop.stop.as_ref().map(stop_strings),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

stop_strings not read by the server, stops already go in stop_token_sequences.. remove it? or leave a comment why

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Removed it in 0789648. ATOM's server never reads sampling.stop_strings on Generate or on the Session: both build their SamplingParams with stop_strings=None and take the stops as stop_token_sequences (atom/entrypoints/grpc/server.py), as #3673's proto documents. Sending them as well only duplicated the stops on the wire. The request test now expects no stop_strings.

TokenChunk::Complete {
finish_reason: finish_reason(&complete.finish_reason),
// ATOM's reason for a stop token is `stop_<token id>`.
matched_stop: complete

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

matched_stop only from stop_, stop-string hits stay None while sglang reports the string. document it or derive it from the decoder?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Documented in 0789648, beside matched_stop in complete_chunk. ATOM's engine ends a stop-string hit with stop_sequence, which names no string, and the stop decoder's Stopped output carries none either, so there is nothing to derive it from. ATOM's HTTP routes report no matched_stop at all, so None matches them, as a vLLM worker's does.

Jasen2201 and others added 2 commits November 22, 2026 14:13
…e atomesh client

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…g has no matched_stop

ATOM's server reads the stops from stop_token_sequences on Generate and the
Session and never reads sampling.stop_strings, so the client no longer sends
them twice. A stop-string hit ends with `stop_sequence`, which names no string,
so its matched_stop stays None, as ATOM's HTTP routes report none.

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

@valar-cop valar-cop left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

some changes needed..

ci green.

n: Some(sampling.n.max(0) as u32),
..Default::default()
}),
stop_token_sequences: stop_token_sequences(stops, tokenizer)?,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

stop_token_ids and return_logprob still not read here, so stop ids never reach stop_token_sequences and logprobs come back null. please wire both and add a test for each.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for following up; both are decided by route, above request.rs.

Details in the line-41 thread.

Jasen2201 added a commit that referenced this pull request Nov 22, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Jasen2201 added a commit that referenced this pull request Nov 22, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@valar-cop

valar-cop commented Nov 22, 2026 •

Copy link
Copy Markdown

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Jasen2201 added a commit that referenced this pull request Nov 23, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Jasen2201
Jasen2201 changed the base branch from jasen/atom-grpc-b-proto-server to jasen/atom-grpc-c-session-server November 23, 2026 07:59
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 24, 2026 04:28

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.

🔵 Needs a closer look

Default-build protobuf wiring and streaming cancellation/status behavior require exact-head Cargo and gRPC integration validation that could not be performed because project dependencies were unavailable.

No open issues 🎉

Review effort: Balanced

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

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.

🟡 Changes recommended

The client retains tonic’s default 4 MiB response-decoding limit, so valid larger ATOM responses can fail with transport errors despite the increased HTTP/2 windows.

1 open issue

Review effort: Balanced

Jasen2201 and others added 2 commits November 24, 2026 05:58
tonic's client decodes at most 4 MiB a message, while ATOM's gRPC server
sends with grpc's default, no limit. A GetModelInfo carrying a large chat
template, or an unstreamed GenerateComplete with all of a long reply's ids,
failed its call past it. The ATOM client now decodes messages of any size,
matching what the server may send.

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

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 ATOM gRPC client integration.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

…omesh client

main moved the HTTP P/D router's idx2idx onto the planner's idx2idx (#3493)
and added the standalone backend's SeqTiming (#3698). The idx2idx change
goes into apply_atom_pd_rank_mapping_policy, which this branch moved to
core/placement/backend/atom.rs; one SeqTiming remains, main's ttft, tpot
and latency, which ATOM gRPC workers fill from their GenerateComplete.

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

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 block the ATOM gRPC client integration.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 24, 2026 08:15

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.

🔵 Needs a closer look

The ATOM protocol-generation and streaming lifecycle changes need exact-head feature-matrix CI and end-to-end cancellation/refusal verification, with dependency-based builds and gRPC integration tests unavailable here.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 24, 2026 08:43

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.

🔵 Needs a closer look

Shared protobuf build changes and Rust/Python stream-cancellation behavior require human confirmation of exact-head feature-matrix and backend interoperability results that could not be independently verified here.

No open issues 🎉

Review effort: Balanced

…tomesh client

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.

🔵 Needs a closer look

The protobuf-generation and read-ahead gRPC changes require feature-matrix builds and real ATOM service validation of compatibility, refusal timing, and cancellation, which this dependency-free snapshot cannot provide.

No open issues 🎉

Review effort: Balanced

PlacementPlan gained prefill_tokens on main; the ATOM engine tests build
their plans with 0, as main's gRPC engine tests do.

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

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.

🔵 Needs a closer look

Cross-language proto generation, first-message HTTP status selection, and paired gRPC cancellation require human validation of the reported test runs because runtime verification was unavailable.

No open issues 🎉

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