Skip to content

[ATOM gRPC] atomesh: ATOM P/D over gRPC (9/14) - #3666

Closed
Jasen2201 wants to merge 1 commit into
jasen/atom-grpc-08-mesh-discoveryfrom
jasen/atom-grpc-09-mesh-pd-pair
Closed

Jasen2201 wants to merge 1 commit into
jasen/atom-grpc-08-mesh-discoveryfrom
jasen/atom-grpc-09-mesh-pd-pair

Conversation

@Jasen2201

@Jasen2201 Jasen2201 commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

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

Why

atomesh's gRPC P/D router sent every pair through SGLang's dual dispatch: an ATOM P and D each got a plain Generate at once, with no kv_transfer_params, so D could not receive P's KV.

What changed

sequenceDiagram
    participant R as GrpcPDRouter
    participant A as AtomPairs (new)
    participant P as ATOM P
    participant D as ATOM D
    R->>A: dispatch, a newly planned pair per attempt
    Note over A: rank mapping, both loads taken, AtomAdapter
    alt relay
        A->>P: Generate, stream off, max_tokens 1
        P-->>A: Complete with kv_transfer_params
        A->>D: Generate with the enriched params
    else chunked
        A->>P: Generate
        A->>D: Generate with P's template params
        Note over A: D's stream returned once P completes
    end
    A-->>R: D's stream, holding D's load
Loading
  • GrpcEngine::dispatch hands a pair of ATOM workers to AtomPairs (engine/atom/pair.rs), which keeps ATOM's HTTP P/D flow; SGLang and vLLM pairs keep the dual dispatch.
  • AtomPairs runs AtomAdapter unchanged on a JSON view, releases P's load when P completes, and in chunked mode cancels either side when the other fails.
  • GrpcPDRouter::new reads each ATOM P's transfer info from GetServerInfo through parse_atom_prefill_info; P is picked by the shared rank mapping.
  • Dispatcher::holds_load keeps the pipeline from taking a second pair of loads.

Review focus

Where the loads live, and the status each failure answers.

Testing

Against in-process ATOM stubs, relay sends D once P completes with its params enriched, and chunked sends both at once and answers once P completes. A failure on either side ends or cancels the other as over HTTP, each retry plans a new pair, and idx2idx runs P on D's rank.

jasen/atom-grpc-09-mesh-pd-pair @ 79214f3: with atom-engine, 1388 lib and 303 integration tests passed. 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 79214f3:

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                   1388 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 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

Against the PR below (part 8):

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

🤖 Generated with Claude Code

A pair of ATOM gRPC workers goes to `AtomPairs` (`engine/atom/pair.rs`),
which keeps ATOM's HTTP P/D flow. Relay runs P with streaming off and
max_tokens 1, releases P's load when P completes, and sends D the enriched
kv_transfer_params; chunked starts P and D together and returns D's stream
only after P completes, a failure on either side cancelling the other. P's
transfer info comes from GetServerInfo through the shared
`parse_atom_prefill_info`, P is picked by the shared rank mapping, and
`Dispatcher::holds_load` keeps the pipeline from taking a second pair.

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

Copy link
Copy Markdown
Collaborator Author

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