Repository navigation
fix(distributed): reject model-owned paged families from the prefill handoff - #716
Merged
Merged
Conversation
…handoff A disaggregated request for a model-owned paged family (gemma3 / gemma4 / llama4 / qwen3_5 / qwen3_next) crashed the prefill node's serving-role loop and took the whole node down: one request left every subsequent request returning 503 peer-down. Root cause: `CachePool::extract_paged_blocks` guarded against model-owned sequences with `!caches.iter().all(is_paged_backed)`, but a model-owned family's `make_caches()` returns an EMPTY vec, so `.all()` on the empty iterator is vacuously true and the guard fell through. These families are routed through the paged backend for shadow block-table accounting only, so `sync_paged_state_with_lengths` populates the block ids while the pool tensors are never written; the fall-through then read those unwritten tensors and `PagedBlockPool::read_block_contents` failed with "layer 0 has no pool tensors to read from". The error propagated out of `prefill_text_request_for_handoff` and the serving-role loop treated it as fatal and exited. extract_paged_blocks now detects the empty-caches case explicitly: a populated shadow block table with no pool-backed caches returns a clean error instead of issuing the doomed pool read, and an empty shadow table takes the empty fast path. BatchScheduler gains a `handoff_supported()` node-level check (natural backend is `DenseKvCache`); `prefill_text_request_for_handoff` rejects unsupported models up front before any allocation or prefill work. The prefill serving-role loop checks `handoff_supported` once at startup (logging a single warning) and rejects each request with a clean per-request error frame, and it no longer exits on a per-request prefill/extract failure: it reports an error frame for that request and keeps serving, reserving loop exit for transport-level conditions. The router renders the error frame as a 500 chat/completions failure. Retargets `disaggregated_router_completions_match_single_node_byte_fallback` from the model-owned Gemma checkpoint (unrunnable by construction) to MiniCPM-2B (llama-format, byte-fallback AND pool-backed), mirroring the chat-usage test. Adds `disaggregated_router_rejects_model_owned_family_and_keeps_serving`, which sends two model-owned requests through the 3-node stack and asserts a clean per-request 500 (not 503 peer-down) on both, proving the prefill node keeps serving. Adds `extract_paged_blocks_rejects_model_owned_shadow_sequence` pinning the guard against a model-owned sequence with a populated shadow block table. Validation on Apple M1 Ultra: cache/coordinator/serving unit tests, the retargeted completions E2E (byte-identical to single-node on minicpm-2b-4bit), the new rejection E2E (gemma-3-1b-it-4bit), and the pre-existing chat-usage E2E all pass; clippy and fmt clean. Refs #708
…loop Review follow-ups on the #708 fix: a malformed-but-well-framed request payload now drops the request instead of exiting the serving loop (the same availability symptom via a different trigger), every error/first-token frame encode failure inside the loop degrades to a per-request drop instead of a loop exit, and the issue-number reference moved out of the client-facing rejection message (the startup warning keeps it for operators).
docs/distributed.md described disaggregated inference without stating which model families the paged prefill/decode handoff supports, unlike CONTINUOUS_BATCHING.md's existing scope note. Add a short paragraph noting the pool-backed-Fp16-only scope (qwen3, llama3) and that model-owned paged families (gemma3, gemma4, llama4, qwen3_5, qwen3_next) are now rejected at the prefill node with a clean per-request error instead of crashing the serving loop, linking to the fuller scope-and-limitations list. Refs #708
be-free-snowboy
pushed a commit
to freestylejs/snowbrain-mlxcel
that referenced
this pull request
Oct 27, 2026
…handoff (lablup#716) ## Summary A disaggregated request for a model-owned paged family (gemma3 / gemma4 / llama4 / qwen3_5 / qwen3_next) crashed the prefill node's serving-role loop and took the whole node down: one request left every subsequent request returning 503 peer-down. This rejects those families with a clean per-request error and keeps the node serving. ## Root cause `CachePool::extract_paged_blocks` guarded against model-owned sequences with `!caches.iter().all(is_paged_backed())`, but a model-owned family's `make_caches()` returns an EMPTY vec, so `.all()` on the empty iterator is vacuously true and the guard fell through. These families are routed through the paged backend for shadow block-table accounting only, so `sync_paged_state_with_lengths` populates the block ids while the pool tensors are never written. The fall-through then read those unwritten tensors and `PagedBlockPool::read_block_contents` failed with "layer 0 has no pool tensors to read from". The error propagated out of `prefill_text_request_for_handoff` and the serving-role loop treated it as fatal and exited, so the router health monitor marked the peer down. ## What changed - `src/lib/mlxcel-core/src/cache.rs`: `extract_paged_blocks` now detects the empty-caches case explicitly. A populated shadow block table with no pool-backed caches returns a clean error instead of issuing the doomed pool read; an empty shadow table takes the empty fast path. Added the `extract_paged_blocks_rejects_model_owned_shadow_sequence` unit test (with a model-owned empty-caches stub) pinning this. - `src/server/batch/scheduler.rs`: new `BatchScheduler::handoff_supported()` (natural sequence-state backend is `DenseKvCache`). `prefill_text_request_for_handoff` rejects unsupported models up front, before any allocation or prefill work. - `src/distributed/disaggregated/coordinator.rs`: `run_prefill_role_networked` checks `handoff_supported` once at startup (single warning, which keeps the `lablup#708` reference for operators) and rejects each request with a clean per-request error frame. It also no longer exits on a per-request prefill/extract failure: it reports an error frame for that request and keeps serving, reserving loop exit for transport-level conditions. - `tests/disaggregated_router_e2e.rs`: retargeted `disaggregated_router_completions_match_single_node_byte_fallback` from Gemma (model-owned, unrunnable by construction) to MiniCPM-2B (byte-fallback AND pool-backed), mirroring the chat-usage test; updated the `GEMMA_DIR` doc comment to note its new use. Added `disaggregated_router_rejects_model_owned_family_and_keeps_serving`. A follow-up hardening pass addressed three review findings in the same serving loop: a malformed-but-well-framed request payload (a decode failure with no `reply_to` to answer) now drops just that request via `continue` instead of exiting the loop, since it is the same availability symptom as the original bug through a different trigger; every error/first-token `ResultFrame` encode failure at each in-loop send site now degrades to a per-request drop (logged and skipped) instead of propagating out and exiting the loop; and the issue number was moved out of the client-facing rejection message into the startup warning only, so operators still get the `lablup#708` pointer in logs without leaking an internal issue reference to API clients. ## What the client sees A completions/chat request for a model-owned family is rejected at the prefill node before any prefill work. The prefill node returns an error frame; the router renders it as an HTTP 500 JSON error (`{"error":{"message":"prefill node error: the disaggregated handoff does not support this model's model-owned paged sequence-state backend; only pool-backed dense Fp16 families (qwen3 / llama3) can be handed off"}}`). The node stays alive, so a second identical request receives the same clean 500, not a 503 peer-down. ## Test plan All run on Apple M1 Ultra with `--features metal,accelerate`. - [x] `cargo check --lib --tests` (workspace) and `cargo clippy --lib --tests --features metal,accelerate -- -D warnings`: clean. - [x] `cargo fmt --all -- --check`: clean. - [x] `cargo test --release --features metal,accelerate -p mlxcel-core cache::tests -- --test-threads=1`: 60 passed, including `extract_paged_blocks_rejects_model_owned_shadow_sequence`. - [x] `cargo test --release --features metal,accelerate --lib -- distributed::disaggregated`: 177 passed (coordinator / serving-protocol / stream-bridge). - [x] E2E `disaggregated_router_rejects_model_owned_family_and_keeps_serving` on gemma-3-1b-it-4bit, re-run on the final hardened code (after the malformed-frame and encode-failure fixes): PASS, two consecutive requests, two consecutive clean HTTP 500s with the model-owned rejection message, no 503 peer-down. - [x] E2E `disaggregated_router_completions_match_single_node_byte_fallback` on minicpm-2b-4bit: PASS, router body byte-identical to single-node (`" café, café, café.\n..."`, completion_tokens 16, finish_reason length). - [x] E2E `disaggregated_router_chat_usage_matches_single_node_byte_fallback` on minicpm-2b-4bit (regression check on serving-loop changes): PASS. Closes lablup#708
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
A disaggregated request for a model-owned paged family (gemma3 / gemma4 / llama4 / qwen3_5 / qwen3_next) crashed the prefill node's serving-role loop and took the whole node down: one request left every subsequent request returning 503 peer-down. This rejects those families with a clean per-request error and keeps the node serving.
Root cause
CachePool::extract_paged_blocksguarded against model-owned sequences with!caches.iter().all(is_paged_backed()), but a model-owned family'smake_caches()returns an EMPTY vec, so.all()on the empty iterator is vacuously true and the guard fell through. These families are routed through the paged backend for shadow block-table accounting only, sosync_paged_state_with_lengthspopulates the block ids while the pool tensors are never written. The fall-through then read those unwritten tensors andPagedBlockPool::read_block_contentsfailed with "layer 0 has no pool tensors to read from". The error propagated out ofprefill_text_request_for_handoffand the serving-role loop treated it as fatal and exited, so the router health monitor marked the peer down.What changed
src/lib/mlxcel-core/src/cache.rs:extract_paged_blocksnow detects the empty-caches case explicitly. A populated shadow block table with no pool-backed caches returns a clean error instead of issuing the doomed pool read; an empty shadow table takes the empty fast path. Added theextract_paged_blocks_rejects_model_owned_shadow_sequenceunit test (with a model-owned empty-caches stub) pinning this.src/server/batch/scheduler.rs: newBatchScheduler::handoff_supported()(natural sequence-state backend isDenseKvCache).prefill_text_request_for_handoffrejects unsupported models up front, before any allocation or prefill work.src/distributed/disaggregated/coordinator.rs:run_prefill_role_networkedcheckshandoff_supportedonce at startup (single warning, which keeps the#708reference for operators) and rejects each request with a clean per-request error frame. It also no longer exits on a per-request prefill/extract failure: it reports an error frame for that request and keeps serving, reserving loop exit for transport-level conditions.tests/disaggregated_router_e2e.rs: retargeteddisaggregated_router_completions_match_single_node_byte_fallbackfrom Gemma (model-owned, unrunnable by construction) to MiniCPM-2B (byte-fallback AND pool-backed), mirroring the chat-usage test; updated theGEMMA_DIRdoc comment to note its new use. Addeddisaggregated_router_rejects_model_owned_family_and_keeps_serving.A follow-up hardening pass addressed three review findings in the same serving loop: a malformed-but-well-framed request payload (a decode failure with no
reply_toto answer) now drops just that request viacontinueinstead of exiting the loop, since it is the same availability symptom as the original bug through a different trigger; every error/first-tokenResultFrameencode failure at each in-loop send site now degrades to a per-request drop (logged and skipped) instead of propagating out and exiting the loop; and the issue number was moved out of the client-facing rejection message into the startup warning only, so operators still get the#708pointer in logs without leaking an internal issue reference to API clients.What the client sees
A completions/chat request for a model-owned family is rejected at the prefill node before any prefill work. The prefill node returns an error frame; the router renders it as an HTTP 500 JSON error (
{"error":{"message":"prefill node error: the disaggregated handoff does not support this model's model-owned paged sequence-state backend; only pool-backed dense Fp16 families (qwen3 / llama3) can be handed off"}}). The node stays alive, so a second identical request receives the same clean 500, not a 503 peer-down.Test plan
All run on Apple M1 Ultra with
--features metal,accelerate.cargo check --lib --tests(workspace) andcargo clippy --lib --tests --features metal,accelerate -- -D warnings: clean.cargo fmt --all -- --check: clean.cargo test --release --features metal,accelerate -p mlxcel-core cache::tests -- --test-threads=1: 60 passed, includingextract_paged_blocks_rejects_model_owned_shadow_sequence.cargo test --release --features metal,accelerate --lib -- distributed::disaggregated: 177 passed (coordinator / serving-protocol / stream-bridge).disaggregated_router_rejects_model_owned_family_and_keeps_servingon gemma-3-1b-it-4bit, re-run on the final hardened code (after the malformed-frame and encode-failure fixes): PASS, two consecutive requests, two consecutive clean HTTP 500s with the model-owned rejection message, no 503 peer-down.disaggregated_router_completions_match_single_node_byte_fallbackon minicpm-2b-4bit: PASS, router body byte-identical to single-node (" café, café, café.\n...", completion_tokens 16, finish_reason length).disaggregated_router_chat_usage_matches_single_node_byte_fallbackon minicpm-2b-4bit (regression check on serving-loop changes): PASS.Closes #708