Repository navigation
update(distributed): remote pipeline residuals from #2671, #2680, #2684 - #2708
Merged
Merged
Conversation
Seven non-security residuals of the remote pipeline work, one PR as the issue asks. Closes #2694. Frame path: `ProtectedStream::read_frame` interprets the kind byte only after the frame authenticated, so a kind flipped to an invalid value is `FrameRejected` and takes the existing budgeted log path instead of closing silently; an authenticated unknown kind is a distinct error. Messages are encoded straight into their frame buffer (`encode_message_frame`) and sealed in place through the one sealing path (`finish_frame`, `write_prepared_frame`, `MAX_TAG_LEN` with a const assertion), which removes the per-send copy of a 405 KB logits reply. Pipeline: the forward activation carries the coordinator's `RunEntry` nonce (`ActivationMessage::reply_nonce`), middle stages copy it, and the final stage sends `RunResult` straight to the coordinator, which accepts a `RunResult` only from the last stage (`ExchangeMatch::result_peer`). The reverse relay and `pending_entry_replies` are gone: 3 frames per decoded token instead of 4. Zero-config: `Activate` / `Abort` follow `Committed` (`ASSIGNMENT_PROTOCOL_VERSION` 2); a peer writes its TOML and starts a stage only on `Activate`, and a commit-phase failure sends `Abort` to every committed peer. The peer TOML header names the assignment flow (`render_peer_assignment_toml`). Gemma4: `text_prefill_masks` returns `(None, None)` for a stage without a sliding layer, and a `trim_front` parity test covers the `--max-kv-size` path. Validation: fmt, clippy, the touched lib modules, `zero_config_cluster_init`, and `pipeline_remote_runtime_*` on real qwen3, llama and gemma checkpoints on GB10. The decode throughput measurement runs separately on the final code.
The final stage sent its RunResult to the configured coordinator address. A coordinator listed with an unspecified IP (`0.0.0.0:19000`, which `--pp-auto` writes when the control address follows `--host 0.0.0.0`, and which a peer reuses when it runs from a copy of the coordinator's TOML) names no host to dial, so on another machine the final stage dialed its own loopback and every decode timed out. The stage now records the authenticated source of the coordinator's latest command (every RunEntry follows a PrepareSequence broadcast) and sends the RunResult there, as every other reply already does; the configured address is only the fallback before any command. AssignmentPushFailed no longer claims that no stage was activated when the failure was an Activate write: every peer had committed by then, so the other peers run a stage, and the message says to stop them. New tests: `final_stage_sends_run_result_to_authenticated_coordinator_identity` (fails without the fix: the RunResult never reaches the coordinator) and `push_failure_message_distinguishes_activate_failures`. Lib modules remote_service, stage_assignment, runtime and tcp_frame pass; clippy and fmt are clean. Refs #2694
Member
Author
Security and performance review @ 00bb472No CRITICAL, HIGH or MEDIUM findings; nothing changed on the branch. Checked and holding:
LOW (not fixed):
Ran: |
A peer logged the coordinator's Abort detail verbatim, so an oversize or multi-line detail could flood or forge log lines. The detail is now cut to MAX_ABORT_DETAIL_BYTES at a character boundary and escaped with escape_debug before it is logged. finish_frame checked the reserved header with debug_assert! only, so a buffer shorter than FRAME_HEADER_LEN panicked in release. It now returns an error, and write_prepared_frame is narrowed to pub(crate) since nothing outside the crate uses it. Validation: cargo fmt --check; clippy test-fast cuda,test-utils lib+tests -D warnings clean; distributed::tcp_frame (5) and distributed::stage_assignment (18) pass. Refs #2694
inureyes
marked this pull request as ready for review
October 28, 2026 07:41
inureyes
added a commit
that referenced
this pull request
Oct 28, 2026
…ups (#2720) ## Summary Implements the six transport and remote pipeline residuals of #2712 in one PR, each wired into the live path (stage service, coordinator exchange, connection pool, TCP transport, router startup) and each backed by a test that fails on 752db4f. 1. **Stage errors reach the coordinator.** `RemoteStageService::handle_activation` reports an execution failure, or a middle stage's failed downstream forward, as `RemoteStageResponse::Error { nonce, request_id: Some(..), state: Some(..) }` to the coordinator (via `send_run_error`); without a reply nonce it logs one warn and sends nothing. The upstream `nonce: 0` send is gone. `ExchangeMatch` gains `error_peers` (`&self.stage_peers[..]` for `RunEntry`, `from_ref(peer)` otherwise) and requires the `Error` to name the run's `request_id`; `forward_sequence` now fails in well under 1 s instead of after `stage_timeout`. 2. **`ServerAtCapacity` backoff.** `connect_with_retry` retries the at-capacity verdict with the refused-connect backoff and returns it, type preserved in the chain, only when the budget is spent; other handshake failures stay terminal. The warn goes through `handshake_warn_allowed` with the new `AtCapacity` class. 3. **Warning budget.** `HandshakeWarnClass::RouterDrop` (`router-drop`) and `AtCapacity` (`at-capacity`), one window slot per class, `router_front.rs` uses `RouterDrop`; `WarnDecision::previous_window_ended_ago` feeds the summary `N cluster warnings ({class}) were logged at debug during the 60s window that ended Ms ago`. 4. **Unknown authenticated kind is logged.** `tcp_frame::UnknownAuthenticatedKind { kind }` (same `Display` text), returned by `read_frame`, classified as diagnostic by `handshake_warn_class`, and `handle_connection` logs `Closing connection from {peer}: {err} (version skew?)` through the budget. 5. **Pool reuse and accounting.** `ProtectedStream::probe_idle() -> IdleProbe { Idle, PendingData, Closed }` (`peer_closed()` kept); `acquire` reuses only `Idle` and returns a `PooledStream` guard (`Deref`/`DerefMut`, `Arc<AtomicUsize>` per peer, decrement on drop) so failed and cancelled sends release their slot; `PoolConfig::router()` (2 retries from 50 ms, 2 s connect) is used by the router transport in `startup.rs`. 6. **TCP `rpc_call` round-trips.** The response is read on the pooled connection the request went out on; the connection is released only after the matching response and dropped on timeout or error. `rpc_pending` and the `RpcResponse` arm of the accept loop are removed (an `RpcResponse` on an accepted connection is logged at debug). Docs: `docs/distributed.md` (capacity backoff, four classes, summary wording), `docs/CONTINUOUS_BATCHING.md` (router pool profile), and the module docs of `remote_service`, `connection_pool`, `handshake_warn`, `tcp_frame`, `tcp_transport`, `cluster_handshake`. No env vars changed. ## For #2714 Item 1's addressing goes through two helpers on `RemoteStageService` in `src/distributed/pipeline/remote_service.rs`: `fn reply_target(&self, _request_key: &str) -> String` (today `coordinator_identity` with the `coordinator.configured()` fallback; the `Logits` `RunResult` uses it too) and `async fn send_run_error(&self, nonce: u64, request_key: String, message: String) -> Result<()>`, called from `report_activation_failure`. Switching `reply_target` to the per-sequence owner needs no call-site changes. ## Failing-first evidence The behavioral tests were committed first (d7fd980) and run against the unchanged code (752db4f plus only the test files): 11 of 13 failed, each with the expected failure mode. | Test | Failure on 752db4f | |---|---| | `remote_service::tests::final_stage_execution_error_goes_to_coordinator` | `stage must answer within 5s`: the coordinator receives nothing (the Error went upstream with nonce 0) | | `remote_service::tests::final_stage_drops_execution_error_without_reply_nonce` | `expect_silence(upstream)` fails: the upstream received the nonce 0 Error | | `runtime::correlation_tests::error_from_last_stage_fails_forward_promptly` | elapsed assertion: the exchange waited out the 5 s timeout | | `runtime::correlation_tests::error_from_last_stage_with_wrong_{nonce,request_id}_is_dropped` | pass on both sides (main drops every non-addressed Error); they guard the new acceptance rule | | `tcp_transport::tests::robustness::server_at_capacity_is_retried_with_backoff` | `cluster handshake with 127.0.0.1:N failed`: returned at once, no retry | | `tcp_transport::tests::robustness::server_at_capacity_exhausts_retry_budget` | elapsed under 60 ms: no backoff spent | | `tcp_transport::tests::robustness::failed_send_releases_active_slot` | `total_active` stayed 1 | | `tcp_transport::tests::robustness::cancelled_send_releases_active_slot` | `total_active` stayed 1 | | `tcp_transport::tests::robustness::rpc_call_round_trips_over_authenticated_tcp` | `RPC call timed out` | | `tcp_transport::tests::robustness::timed_out_rpc_call_drops_its_stream` | `total_idle` was 1: the stream was pooled before the wait | | `tcp_transport::tests::frame_protection::authenticated_unknown_kind_is_logged_before_close` | zero close lines captured | | `connection_pool::tests::acquire_drops_idle_connection_with_pending_data` | second `accept` timed out: the idle connection was reused | Tests that use a new API cannot compile on 752db4f; `git grep` of the symbol on that commit returns nothing, which is the evidence: `handshake_warn::tests::router_drops_do_not_suppress_diagnostic_warnings` and `rollover_summary_reports_the_window_age` (`HandshakeWarnClass::RouterDrop`, `WarnDecision::previous_window_ended_ago`), `classifies_unknown_authenticated_kind_as_diagnostic` and `frame_protection::read_frame_reports_unknown_authenticated_kind_typed` (`UnknownAuthenticatedKind`), `connection_pool::tests::pool_config_router_values` and `router_pool_config_fails_fast` (`PoolConfig::router`), and the `probe_idle` assertions added to `peer_closed_probe_is_non_consuming` (`IdleProbe`). The behavioral side of each is covered by the table above (items 3 and 4) or by `disaggregated_router_e2e` (item 5's failover). ## Verification GB10 (spark-102), `--profile test-fast --features cuda,test-utils`, built outside the lock and run under `gpu-lock run --tag issue-2712` with `MLXCEL_REQUIRE_MODELS=1 MLXCEL_SDPA_DETERMINISTIC=1 -- --test-threads=1`: | Command | Result | |---|---| | `cargo fmt --check` | clean | | `cargo clippy --profile test-fast --features cuda,test-utils -p mlxcel --lib --tests -- -D warnings` | clean (one deprecated `TcpStream::set_linger` in a new test was replaced by `socket2::SockRef::set_linger` on the way) | | `cargo test ... --lib distributed::` | 1513 passed, 0 failed, 4 ignored (42 s) | | `cargo test ... --lib server::router_front` | 35 passed, 0 failed | | `cargo test ... --test zero_config_cluster_init -- --include-ignored` | 7 passed, 0 failed | | `cargo test ... --test pipeline_remote_real_models -- --include-ignored --skip glm_moe_dsa` | 10 passed, 0 failed, 1 filtered (82 s) | | `cargo test ... --test pipeline_server_remote_real_models -- --include-ignored --skip glm_moe_dsa` | 7 passed, 0 failed, 1 filtered (61 s) | | `cargo test ... --test pipeline_ci_multi_stage_real_models -- --include-ignored --skip glm_moe_dsa` | 4 passed, 0 failed | | `cargo test ... --test disaggregated_serving_e2e -- --include-ignored` | 2 passed, 0 failed | | `cargo test ... --test disaggregated_router_e2e -- --include-ignored` | 7 passed, 0 failed (53 s) | The new tests (25 selected by name, including the adjusted `full_connection_cap_reports_capacity_to_the_client`, `panicking_rpc_handler_releases_its_connection_slot` and `peer_closed_probe_is_non_consuming`) pass on the branch; greedy parity on the real-model targets is unchanged against #2708. `glm_moe_dsa` is skipped as the issue allows (418.6 GB checkpoint). `make verify-env-var-docs` not run: no env var added or changed. Closes #2712
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2694. The seven residuals of #2671, #2680 and #2684 in one PR, each with its own test. Reconciled against current main: the handshake
PROTOCOL_VERSIONstays 4 (#2705), theFrameRejectedcall sites keep theirhandshake_warnbudget unchanged, andProtectedStream::peer_closed(#2700) is untouched.Per item
read_frameinterprets the kind byte afterFrameOpener::openon a protected stream: a tampered invalid kind isFrameRejectedthrough the existing budgeted call sites (no call-site change); an authenticated unknown kind isunknown message kind {n} from an authenticated peer. Plain streams and the header-only oversize check are unchanged.encode_message_framereserves the header andMAX_TAG_LEN(32, const-asserted againstFrameSuite::ALL);finish_frameis the one sealing path, used bywrite_prepared_frame(TcpTransport::send) and bywrite_frame(kind, &[u8]). A buffer shorter than the header is an error, not a panic, andwrite_prepared_frameispub(crate).serialize_messageis test-only.ActivationMessage::reply_nonce(serde(default)) carries theRunEntrynonce from the entry stage through middle stages; the final stage sendsRunResultto the coordinator's authenticated identity (the source of its most recent command, so a coordinator configured on0.0.0.0still gets the reply across hosts). A reverse activation, or a nonce-less forward activation on the final stage, is dropped with a warn.PendingEntryReply, its map and thepending_entry_repliesfields are gone.ExchangeMatch::result_peerisstage_peers.last()forRunEntryand the command's peer otherwise;Ack,State,Errorkeeppeer. Frames per decoded token: 3 (RunEntry, forward activation,RunResult) instead of 4.render_peer_assignment_toml(sharedrender_toml_body) is what a--pp-peerwrites; the coordinator renderer and its callers are unchanged.Activate/Abort { detail }afterCommitted,ASSIGNMENT_PROTOCOL_VERSION2. The peer delivers only onActivate;Abort, another frame, close or the commit timeout resetcommittedand return it to listening. The coordinator activates all peers after every commit (a failedActivatewrite is anAssignmentPushFailedentry whose message says the other peers are running) or aborts every committed peer (detail cut to 1 KiB) when any commit failed. The peer logs a received detail bounded to 1 KiB and escaped to one line. The residual window is in the module docs.text_prefill_masksreturns(None, None)whensliding_attnisNone.two_stage_split_matches_dense_after_front_trim_bitwise(12-token prefill,trim_front(4)on everyCache::Standard, 3-token continuation, one decode step, bitwise against dense).Docs:
docs/distributed.md(assignment protocol, peer TOML header, reply authorization, 3-frame per-token flow); no Korean counterpart exists for these sections.Failing-first evidence
Run against the unchanged behaviour before each fix, green after:
protected_stream_rejects_tampered_invalid_kind_as_frame_rejected:a tampered invalid kind must surface as FrameRejected, got: unknown message kind: 255;protected_stream_reports_authenticated_unknown_kind_distinctly:unexpected error: unknown message kind: 255.final_stage_sends_run_result_to_coordinator_not_upstream:stage must answer within 5s (it may have died): Elapsed(());run_result_from_last_stage_completes_forward:remote stage 10.1.1.1:1 timed out after 5s;run_result_from_entry_stage_is_dropped_in_multi_stage_pipeline:a RunResult from a stage other than the last must not complete the exchange;final_stage_sends_run_result_to_authenticated_coordinator_identity(coordinator configured as[::]:port):Elapsed(())when the reply went to the configured address.peer_discards_committed_assignment_on_abort_and_activates_on_the_next:the peer delivered an assignment that was never activated;coordinator_aborts_committed_peers_when_another_commit_fails:the real peer delivered an assignment the coordinator aborted.text_prefill_masks_without_sliding_layer_builds_no_mask:a stage without a sliding layer must not allocate a sliding mask.Item 7 sensitivity
A temporary mutation (never committed, file restored byte for byte, sha256
de5f8b65…c457036before and after) gave the stage path an offset-sized global prefill mask (Some(create_causal_mask(seq_len, first_cache_offset(caches, "full_attention")))instead ofNone). The trim test then fails with3-token continuation prefill after trim_front(4): stage logits differ from the dense logits (max abs diff 5.46875e-2). It is the only gemma4 stage test whose scenario hasoffset != live_len(12 vs 8).Decode throughput
pipeline_remote_decode_bench(qwen3-0.6b-4bit, 2 stages, loopback, 128 tokens, 7 timed repeats after a warm-up per run), main 433560c (A) and this branch (B) interleaved A B over 5 rounds on a quiet GB10, each run undergpu-lock. Both binaries were built with the bench's fixed port moved to 19990 (local only, not committed). Greedy tokens are identical in all 80 repeats.The branch is about 15% faster, and its slowest round beats main's fastest.
Verification (GB10 spark-102,
--profile test-fast --features cuda,test-utils, test binaries built outside the lock and run undergpu-lock,--test-threads=1,MLXCEL_REQUIRE_MODELS=1 MLXCEL_SDPA_DETERMINISTIC=1, at 7c8d340)cargo fmt --checkandcargo clippy ... --lib --tests -- -D warnings: clean.--lib distributed::: 1494 passed, 4 ignored.--lib models::gemma4: 127 passed, 15 ignored.zero_config_cluster_init --include-ignored: 7/7 (thezero_config_cli_*rehearsals drive the real binaries through Activate).pipeline_remote_real_models --include-ignored --skip glm_moe_dsa: 10/10.pipeline_server_remote_real_models --include-ignored --skip glm_moe_dsa: 7/7. The skippedglm_moe_dsatests need the 418.6 GBglm5-4bitcheckpoint, which cannot load on a 128 GB GB10.pipeline_ci_multi_stage_real_models --include-ignored: 4/4, includingpipeline_multi_stage_three_host_real_model_parity(logits now skip the middle stage) and the two-host smoke.disaggregated_serving_e2e2/2,disaggregated_router_e2e7/7,disaggregated_e2e51/51 (all--include-ignored).Compatibility
The stage RPC messages change shape (
pending_entry_repliesis gone fromAckandState,RunResultcomes from the final stage) while the handshakePROTOCOL_VERSIONstays 4. A node built from main between #2705 and this PR therefore completes the handshake with a node built from this PR and then fails with exchange timeouts instead of a version error. No tagged release is affected (the latest is v0.8.0-beta.1, before the v3 and v4 handshakes); upgrade all nodes together.