Repository navigation
fix(distributed): fast-fail silent stages and sanitize stage logs - #2787
Merged
Merged
Conversation
While one remote pipeline stage stayed silent (a stopped process, a partition, an on-path party dropping frames, none of which needs the cluster secret), every new request blocked the single model worker for a full 30 s stage timeout before failing, and sequences prepared before the outage each paid the same at their next forward. `RemotePipelineRuntime` now keeps an availability gate (`stage_availability.rs`): a full-`stage_timeout` exchange failure opens it, and while open `prepare_sequence_state` and `forward_sequence` fail at once with a typed `PipelineUnavailable` (downcastable through `anyhow`). It is not a fixed cooldown: the first request after the timeout probes every stage with the short teardown wait and is served when they all answer; requests inside the 10 s probe interval are refused without sending anything. Only `exchange` opens it; `Error` replies and teardown-ack misses never do. The forward-path refusal goes through `fail_sequence`, so `Err` still means the coordinator's state was discarded (#2753). While open, the teardown of a sequence is sent to the silent stage with no ack wait. The gate holds its mutex only for state transitions, never across the probe exchanges, and a generation counter keeps a probe from closing an outage that a newer timeout replaced while it was in flight. `PipelineServerModel` logs the refusal at debug; the open and close transitions carry the operator signal at warn and info. A stage's `Error { message }`, and the upstream request id a stage logs, are now bounded to 1024 bytes and `escape_debug`-escaped before they reach a log line, through the shared `peer_text::loggable_peer_text` that `stage_assignment` already used for abort details, so an authenticated peer cannot forge log lines on the coordinator or on a stage. A stage that misses the teardown ack wait while healthy (still finishing a long forward) draws its "did not acknowledge ... within ...; the frame was sent" line from the new `teardown-ack` warning budget, the rest at debug. Tests: `runtime_availability_tests.rs` (gate fast-fail and probe recovery, one dropped reply does not refuse the next request, stage error text escaped, teardown-ack warnings budgeted), `stage_availability` state-machine tests, `peer_text` tests; the stub stage gains `set_silent`, `wait_for_commands` and an `Error { message }`. The scheduler timeout test's pinned command log now expects the `probe_state` before the next prepare. Closes #2782
Member
Author
Implementation Review SummaryIntent
Findings AddressedNo CRITICAL or HIGH findings; no fix commits were needed. Remaining Items
Verification
|
…text Two probes for the same outage can overlap when one outlasts the probe interval. Before this change a probe that failed after its sibling closed the gate reopened it without the open warn line, so the log showed a closed gate that was refusing requests, and a sibling that also succeeded was refused because the gate was already closed. StageAvailability now takes the probe's generation in probe_failed as well as close_after_probe. A succeeded probe for an outage a sibling already closed is served (ProbeClose::AlreadyClosed). A failed probe of the current outage that finds the gate closed reopens it and the coordinator logs the open line again. A failed probe of an older outage leaves the newer state alone and refuses only its own request. Gate lines are logged after the mutex is dropped. The coordinator's dropped-reply warning formatted the serde_json error raw, and serde_json quotes an unknown variant or field name from the payload verbatim, so a stage could forge a log line through it. The reason now goes through loggable_peer_text. Validated with the distributed:: lib tests (1576 passed), scheduler_pipeline_failure_tests (4 passed), fmt and clippy. New unit tests cover the three overlap cases and the escaped serde reason. Refs #2782
Member
Author
Security and performance reviewNo CRITICAL, HIGH or MEDIUM findings. Two LOW items fixed in 487634e. Fixed
Checked, no change
Verification
|
Bilingual report on the coordinator availability gate, peer text escaping and the teardown-ack warning budget from #2782. It records the probe-versus-cooldown and generation-counter decisions, the local gate results, the hosted 2-host logical failure at 487634e on the 50 ms bound of the new availability test, and the slow-but-alive stage risk. Refs #2782
The hosted 2-host logical job (run 41161926566) measured 101 ms for the refused prepare against a 50 ms bound on a loaded runner. The command-log assertion is the precise check that nothing reaches the stage, so the time bound now only separates a refusal from the 1 s stage timeout.
inureyes
marked this pull request as ready for review
October 31, 2026 03:18
On the hosted 2-host logical job (run 41163802130) more than 300 ms passed between B's probe and C's prepare, so C probed again and the command-log assertion saw a second probe_state. A 2 s test interval keeps C inside the window on a loaded runner; the suite now takes about 4.6 s.
This was referenced Oct 31, 2026
inureyes
added a commit
that referenced
this pull request
Oct 31, 2026
inureyes
added a commit
that referenced
this pull request
Oct 31, 2026
Closes the five LOW residuals of #2787, #2788 and #2789 listed in #2790, in one PR. ## Changes - **KV storage report (item 1).** `kv_cache_storage_modes` returns `Option<Vec<Option<KVCacheMode>>>`; a `None` entry is a layer with no KV. Families describe layers with `LayerKv` (`Full`, `Sliding`, `Fp16Only`, `None`) from the predicate their cache builder uses. Llama 4 reports chunked layers as FP16 (`uses_chunked_cache` now drives the builder, the masks and the report). Qwen3-Next, Qwen 3.5, Qwen4-Exp, Bailing linear, LFM2 and NemotronNAS report linear, convolution and skipped layers as stateless. Model-owned families without a mode table report real storage instead of `None`: DeepSeek V4, RecurrentGemma, Muse Glimmer, Mamba, Mamba2 and RWKV7 as listed, plus Nemotron-H, Jamba, Falcon-H1, Plamo2, GraniteMoeHybrid, Kimi Linear, Kimi K3 and Inkling, which had the same gap, and the five VLM wrappers around them. The server log adds `kv_cache_mode_stateless_layers`; `logit_trace` prints the stateless count. - **Sliding window (item 2).** `validate_sliding_window` (via `cache_window`, only when a layer slides) fails the load for 0 or values above `i32::MAX` in Gemma 3, Gemma 4, GPT-OSS, ExaOne 4, Laguna, Step 3.5, Ministral 3, Mellum and AFMoE; Gemma 3 also rejects `sliding_window_pattern: 0`. Gemma 3, GPT-OSS, Laguna, Mellum, ExaOne 4, Ministral 3 and AFMoE store the validated `i32` for their builders. Gemma 4 validates in both the single-process load and the pipeline-stage load (`Gemma4StageModel::from_filtered_weights`) and keeps its casts on the shared `TextConfig` (dozens of sites), now lossless after the check. - **IREE local-task (item 3).** `csrc/xla_local_task.c` builds the device without the flag registry: executor with 8 MiB worker stacks over `MLXCEL_XLA_LOCAL_TASK_WORKERS` workers (1..=256, IREE's topology limit; anything else fails the load naming the variable) or the physical-core topology, all loaders, heap allocator, task driver, default device with the same proactor pool the runtime uses. Both device-creating entry points use it; other drivers are unchanged. Every IREE symbol used is exported by the pinned CUDA tree and by `iree-dist-3.12.0rc20260721-linux-x86_64` (the only dist published for that release; there is no aarch64 dist), and the new C file compiles against both header trees. - **Test support (item 4).** `XlaPreparedPrefillLogits` needs mlxcel-xla `test-support` (root `test-utils`) or `diagnostics`, resets slots before each prefill, and `Qwen25VlLanguageDiagnosticEngine` wraps it. `xla_prepared_prefill` requires `test-utils`; the CI link step passes it. - **Pipeline gate (item 5).** Only `StageUnreachable` (timeout or failed send) opens the gate. A `RunEntry` timeout opens it unattributed, so the entry stage keeps its teardown wait and the next probe names the silent stage; a failed send logs "could not be reached", and a probe that reopens the gate logs its real cause (send failure or timeout). `PipelineUnavailable.stage` is `Option<String>`. `docs/distributed.md` describes the new rule. ## Failing first Each new test fails on `main` 1a257bc or, where it cannot compile there, under a mutation restoring `main`'s behaviour: - Existing local-task tests, main binary: all three fail with `thread creation failed with 22; [runtime-init] failed to open IREE HAL device 'local-task'`. - `local_task_executor_uses_8_mib_stacks_without_iree_flags`, stack set back to 128 KiB: `xla_local_task_probe failed: ... thread creation failed with 22`. - `llama4_chunked_layers_report_fp16_storage_under_int8`: `left: Some([Some(Int8) x8])` vs expected `Int8` only at 3 and 7. - `qwen3_next_linear_layers_report_no_kv_storage`: eight `Some(Int8)` vs `[None, None, None, Some(Int8), ...]`. - `recurrent_gemma_reports_...`, `mamba_reports_every_layer_stateless`, `deepseek_v4_reports_fp16_storage_for_every_layer` (override returning `None`): `left: None` / `a storage report`. - `gemma3_rejects_zero_sliding_window_pattern_at_load`, `sliding_window_zero_is_a_load_error` (validation off): the loads succeed. - `run_entry_timeout_does_not_name_the_entry_stage` (main attribution): `failed_peer` is `Some("127.0.0.1:41749")`, the entry stage. - `send_failure_opens_the_gate_with_a_send_reason`: the open line reads `remote stage 127.0.0.1:40565 did not answer within 1s`. ## Verification (spark-102, GB10) - `cargo fmt --all -- --check`, `make verify-env-var-docs`: clean. - `cargo clippy --profile test-fast --features cuda -p mlxcel -p mlxcel-core -p mlxcel-xla --lib --tests -- -D warnings` and `cargo clippy --release --features cuda,xla-iree,test-utils -p mlxcel-xla -p mlxcel --lib --test xla_prepared_prefill -- -D warnings`: clean. - After the review fixes: clippy on `mlxcel` + `mlxcel-xla` lib and tests clean, `distributed::pipeline::` 416 passed, `mlxcel-xla` `local_task` 6 passed. - Lib tests (`--test-threads=1`, gpu-lock): `models::` + `vision::` 3429 passed; `distributed::` + `server::batch::scheduler` 1845 passed; `mlxcel-core` `cache::` + `generate::` 624 passed; `mlxcel-xla --lib` 370 passed. - Integration (`cuda,test-utils`): `distributed_integration` 20, `pipeline_e2e` 30, `pipeline_remote_real_models` 10, `pipeline_server_remote_real_models` 7, `pipeline_ci_multi_stage_real_models` 4 (`--include-ignored --skip glm_moe_dsa`, `MLXCEL_REQUIRE_MODELS=1 MLXCEL_SDPA_DETERMINISTIC=1`), `disaggregated_serving_e2e` 2, `disaggregated_router_e2e` 8: all pass. - `cargo test --release --features cuda,xla-iree,test-utils --test xla_prepared_prefill -- --ignored`: 4/4 on the default `local-task` device. `MLXCEL_XLA_LOCAL_TASK_WORKERS=0` and `abc` fail the load naming the variable; `2` passes. Unit tests also reject 257 and 1000. - Item 4 gating: a root `use mlxcel_xla::XlaPreparedPrefillLogits` fails `cargo check --features cuda,xla-iree` with E0432 and passes with `test-utils`. `--features cuda,xla-reference-diagnostics --lib --tests` checks clean. (Both checks ran in the `test-fast` profile.) - Server smoke, `--kv-cache-mode int8`, release `mlxcel-server`: `llama-4-scout-17b-16e-instruct-4bit` logs `applied_layers=12 total_layers=48 stateless_layers=0`; `gemma-3-1b-it-4bit` logs `applied_layers=4 total_layers=26`. Not changed: with `MLXCEL_XLA_DEVICE=cuda`, `local_task_gemma3_vlm_prefill_matches_mlx_mask` misses its 1e-3 tolerance (up to 5.4e-3) under the default `f16` CUDA precision, identically on `main`; it passes with `MLXCEL_XLA_PRECISION=f32`. Closes #2790 ## Compatibility notes - `PipelineUnavailable.stage` is a public field and changes from `String` to `Option<String>` (`None` until a probe names the silent stage); callers that read it need `as_deref()`. - The `kv_cache_mode_total_layers` startup log now counts only layers that hold KV, so hybrid models (Qwen3-Next, LFM2, Jamba and similar) log a lower total than before; stateless layers are reported in the new `kv_cache_mode_stateless_layers` field.
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.
Summary
stage_timeoutexchange failure opens a gate that covers the whole runtime. While it is open,prepare_sequence_stateandforward_sequencefail at once with a typedPipelineUnavailable, which callers can downcast throughanyhow. Before this change, each request blocked the model worker for 30 s. The first request after a timeout sendsProbeStateto every stage with the 2 s teardown wait and is served normally if all of them answer. Requests that arrive within the 10 s probe interval are refused without sending anything.Errorreplies and missed teardown acknowledgements never open the gate. A refused forward still goes throughfail_sequence, so the fix(distributed): fail one request, not the coordinator, on stage errors #2753 contract holds. The gate logs one warn when it opens and one info when it closes.PipelineServerModellogs each refusal at debug. Client text is unchanged.peer_text.rsbounds stage-supplied text to 1024 bytes and appliesescape_debug. It covers the stageErrormessage at the fourruntime.rssites, the serde reason in the malformed-reply warning, andrequest_keyat the tworemote_service.rssites.stage_assignmentnow calls the shared helper.HandshakeWarnClass::TeardownAck. The reworded "the frame was sent and a slow stage still applies it" line drops to debug once the budget is spent.docs/distributed.md.Failing-first evidence (9f06fef with only the test-support plumbing)
Verification at 487634e
These ran on GB10 under
gpu-lockwith--test-threads=1,MLXCEL_REQUIRE_MODELS=1andMLXCEL_SDPA_DETERMINISTIC=1. fmt and clippy (--lib --tests -D warnings) are clean.distributed::lib testsscheduler_pipeline_failure_testsdistributed_integrationpipeline_e2epipeline_remote_real_models(--skip glm_moe_dsa)pipeline_server_remote_real_models(--skip glm_moe_dsa)pipeline_ci_multi_stage_real_modelsdisaggregated_serving_e2edisaggregated_router_e2eserver_exit_joins_workerA
RunEntrytimeout is attributed to the entry stage until the first probe names the silent one; per-stage attribution is out of scope per the issue.Closes #2782