Skip to content

fix(server): close disaggregated router parity residuals from #2700 - #2719

Merged
inureyes merged 5 commits into
mainfrom
fix/issue-2715-router-parity-residuals
Oct 28, 2026
Merged

inureyes merged 5 commits into
mainfrom
fix/issue-2715-router-parity-residuals

Conversation

@inureyes

@inureyes inureyes commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Non-stream chat content parity. The single-node no-tools shaping (clean_structural_tokens, answer wrapper, unclosed primed thinking, --reasoning-format placement, reasoning extraction) is now routes::chat::shape_plain_chat_reply. Single node calls it, and the router's non-stream branch accumulates the raw handoff text and shapes it with the same helper, so " Café" becomes "Café" on both. --skip-chat-parsing still returns raw text, and streaming is unchanged (neither side trims a stream).
  • Llama3 EOS ids. llama3::ModelArgs reads eos_token_id (int or list). eos_token_ids() returns the declared ids, deduplicated, and appends 128001/128009 only for vocab 128256. It never invents ids. Llama3Model stores the result and gains set_eos_token_ids. MiniCPM-2B now reports [2]. The fix(distributed): disaggregated serving and router e2e tests fail on main #2695 regression asserts [2], then sets [128001, 128009] so the decode-intake premise still holds.
  • prompt_tokens_details follows the worker. ResultFrame.prompt_cache_enabled: Option<bool> (serde(default)) is set on the prefill node's successful first-token frame from BatchScheduler::has_prompt_cache_store(). Error and decode frames carry None. HandoffOutcome carries it, and all four usage builders use prompt_cache_enabled.unwrap_or(router flag). Docs: docs/CONTINUOUS_BATCHING.md (no Korean counterpart exists).

Failing-first evidence (main 752db4f, new tests written before the fix)

  • disaggregated_router_chat_usage_matches_single_node_byte_fallback: router non-stream content diverges from single-node, left: String(" Café"), right: String("Café").
  • router_front_tests::router_non_stream_chat_content_is_shaped_like_single_node (a fake prefill peer sends [" Café"]): left: String(" Café"), right: String("Café").
  • prompt_tokens_details_omitted_when_the_worker_cache_is_off: chat usage still had {"cached_tokens":0} (left: Some(..), right: None). prompt_tokens_details_present_when_the_worker_cache_is_on: left: None.
  • MiniCPM handoff parity with the new assertion: left: [128001, 128009], right: [2].
  • Pass on main by design: the None fallback test (it pins the unchanged behavior for older nodes) and the qwen3 non-stream thinking comparison (both sides return content: "" and the same reasoning at 32 tokens). The llama3_tests EOS cases, shape_router_chat_reply_matches_the_single_node_shaping, and the serving_protocol missing-key case test new API, so they cannot compile on main.

Test plan

All with MLXCEL_REQUIRE_MODELS=1 MLXCEL_SDPA_DETERMINISTIC=1 under gpu-lock run --tag issue-2715, --profile test-fast, built outside the lock first.

  • cargo fmt --check. cargo clippy --profile test-fast --features cuda -p mlxcel --lib --tests -- -D warnings is clean.
  • Lib tests (--features cuda, --test-threads=1): server::router_front 40/40, server::routes::chat 73/73, models::llama3 34/34, models::headless_llama 3/3, distributed::disaggregated::serving_protocol 19/19, serving_handoff_parity --include-ignored 6/6. Also models::llama_bidirec 9/9, models::helium 28/28, and distributed::tensor_parallel::llama_runtime 35 passed, 4 ignored.
  • --features cuda,test-utils --test disaggregated_router_e2e -- --include-ignored --test-threads=1: 7/7 (49 s), no skips. --test disaggregated_serving_e2e: 2/2.
  • Real model: a single-node mlxcel-server on 127.0.0.1:19701 with minicpm-2b-sft-4bit-llama-format-mlx, max_tokens 16. "café" returns "Café" with finish_reason: stop and completion_tokens: 1. "Чай" returns "Чай" with stop and 4 tokens. Both stop at </s>.

Out of scope, noted for follow-up: single node's non-stream reply also carries reasoning_only: true when the reply is all reasoning. The router does not emit that extension field.

Closes #2715

Behavior changes

  • Router non-stream chat replies under --reasoning-format none and deepseek-legacy now follow single node's non-stream form instead of mirroring the router's streamed form (fix(server): close remaining streamed vs non-streamed output gaps #2464), so router stream and non-stream agree only as far as single node's do.
  • Llama3Model reports the EOS ids its config declares: a Llama 3.1 Instruct checkpoint now also reports 128008 (<|eom_id|>); a Llama 3 derivative with a resized vocabulary no longer gets 128001/128009 appended; a llama-format checkpoint with no eos_token_id and a non-Llama-3 vocabulary reports none. In-tree generation already merges sidecar EOS ids, so only the llava wrapper and the tensor-parallel runtime see the difference.
  • With prompt_cache_enabled on ResultFrame, the prefill node's setting decides prompt_tokens_details; a router talking to an older node falls back to its own flag.

Router non-stream chat content now matches single node. The no-tools shaping in the single-node chat route moves into shape_plain_chat_reply, which the single-node path and the router's non-stream branch both call; the router accumulates the raw handoff text and shapes it once, so a SentencePiece " Café" becomes "Café" on both. --skip-chat-parsing still returns the raw text and the streaming branch is unchanged.

Llama3Model reports the checkpoint's own EOS ids. llama3::ModelArgs reads eos_token_id (int or list); eos_token_ids() returns the declared ids and appends 128001/128009 only for the Llama 3.x vocabulary (128256), so MiniCPM-2B reports [2] instead of two out-of-vocabulary ids. The #2695 decode-intake regression asserts [2] and then restores its premise with set_eos_token_ids.

prompt_tokens_details follows the worker. ResultFrame gains an optional prompt_cache_enabled that the prefill node sets on its successful first-token frame from BatchScheduler::has_prompt_cache_store(); all four router usage builders use it and fall back to the router's own flag for an older prefill node.

Validated on GB10: router_front, routes::chat, llama3, headless_llama, serving_protocol and serving_handoff_parity (with ignored) lib tests, disaggregated_router_e2e 7/7 and disaggregated_serving_e2e 2/2, clippy and fmt clean.

Closes #2715
@inureyes inureyes added status:review Under review type:bug Bug fixes, error corrections, or issue resolutions priority:medium Medium priority area:router Continuum router routing, config, and integration area:models Model architectures, weights, loading, metadata labels Oct 28, 2026
The new eos_token_id: None had been inserted between the checkpoint_label comment and its field, so the comment read as describing eos_token_id. Move it above the comment and give it its own one-line note.

Validation: cargo fmt --check, clippy -D warnings (lib and tests), and models::helium (28 passed) all clean.

Refs #2715
@inureyes inureyes added status:done Completed and removed status:review Under review labels Oct 28, 2026
@inureyes
inureyes marked this pull request as ready for review October 28, 2026 13:24
@inureyes
inureyes merged commit c8a7fb0 into main Oct 28, 2026
14 checks passed
@inureyes
inureyes deleted the fix/issue-2715-router-parity-residuals branch October 28, 2026 13:24
@inureyes inureyes added this to the 0.8 milestone Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:models Model architectures, weights, loading, metadata area:router Continuum router routing, config, and integration priority:medium Medium priority status:done Completed type:bug Bug fixes, error corrections, or issue resolutions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(server): disaggregated router parity residuals from #2700

1 participant