Repository navigation
FEAT: support bidirectional Xavier P/D between NVIDIA and MLX - #5641
Merged
Merged
Conversation
qinxuye
force-pushed
the
feat/xavier-gpu-mlx-pd
branch
from
October 7, 2026 03:56
d3294d9 to
52cc6b2
Compare
rogercloud
approved these changes
Oct 7, 2026
rogercloud
left a comment
Contributor
There was a problem hiding this comment.
Major
xinference/model/llm/xavier/backends/bytes/pd.py:59— fixed 512 MiB reject-only byte budget: an MLX prefill whose pages exceed it fails only after the full Metal prefill, and concurrent requests fail instead of waiting. Make it configurable, check ceil(n/64)*page_bytes before prefill, and wait for capacity.
Minor
xinference/model/llm/mlx/xavier.py:522— 5 ms busy-poll hits the supervisor directory ~200-400 RPC/s per request (also_fetch_hostsource/chunk polls). Usewait_source/wait_complete/wait_chunkwith atransfer_timeout()timeout.xinference/model/llm/mlx/xavier.py:410—releaseis not shielded in_fetch_host, andsource.abortfailure in_prefill_hostskips the directory release. Shield it and use try/finally.xinference/core/supervisor.py:5517— worker-localdestroy_actorhas no timeout; an unreachable worker stalls termination. Usexo.wait_for(..., timeout=5).xinference/model/llm/xavier/backends/torch/pd.py:335—directory.request_infoRPC runs per batch undersend_lock. Fetch once per room before the lock.xinference/model/llm/mlx/xavier.py:359—xavier-cross-engine-transfer-{rank}is hard-coded here and incore/pd_model.py, duplicatingCrossEngineGPUActor.default_uid(). Share a torch-free constant.xinference/model/llm/mlx/xavier.py:165— host mode callsconfigure(fingerprint)without the contract (alsobytes/pd.py:60), so mismatches get the generic GPU-namespace message;sglang/xavier/pd.py:42still says "Missing SGLang Xavier GPU bootstrap metadata". Passcontract.to_dict()and derive messages from mode.xinference/model/llm/mlx/xavier.py:504— first token ignores min_p/presence/frequency penalty/seed, which are honored afterwards. Reject them in the router for MLX-prefill requests or document.- Tests: none for
XavierHostPDSource.publishrejection/rollback branches,SGLangXavierHandoff.preparein host mode,_fetch_hostmulti-chunk and page-count/incomplete-prefix errors, or budget rejection after MLX prefill.
Simplification
xinference/core/supervisor.pyL3413: delete: redundant hasattr guard;__init__sets_xavier_source_mapping. Callself._xavier_source_mapping.setdefault(model_uid, []).append(source)directly. (-2)xinference/core/supervisor.pyL5515: delete: getattr default unnecessary. Useself._xavier_source_mapping.pop(model_uid, []). (0)xinference/model/llm/mlx/xavier.pyL317: shrink:_fetch_hostand_prefill_host(L450) duplicate the 11-line handoff validation. Extract one helper returninghandoff["room"]. (~-7)
net: -9 lines possible
Blocking: no — recommended event: APPROVE
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.
Adds bidirectional NVIDIA/Metal P/D: vLLM → MLX, SGLang → MLX, MLX → vLLM and MLX → SGLang, including streaming/non-streaming chat and completions. CUDA/Metal handoff uses canonical FP16 64-token pages through bounded CPU staging and actor RPC. MLX prefill owns pages on its worker under a configurable
xavier_cache_bytesin-flight budget (default 512 MiB), reserved before Metal prefill; concurrent requests wait for capacity. MLX uses event-driven handoff waits; SGLang decode commits full prompt KV and P’s first token, while vLLM/MLX decode recomputes the last prompt token. Cancellation drains CUDA operations before releasing engine slots, and termination/failed launch removes worker-local source actors with a bounded worker RPC. MLX-prefill requests reject unsupported first-token sampling parameters before scheduling either role.Dependencies
Based on
mainat4969faffdafter #5631, #5638 and #5639 merged; no unmerged PR dependencies. The PR now contains only the NVIDIA/MLX host-handoff extension and its integration tests/docs.Initial scope: identical original unquantized Qwen2/Qwen3/Llama full-attention checkpoints and tokenizer assets, effective FP16 weights, TP=PP=DP=1 and
n=1, without LoRA or multimodal/hybrid caches. Per-replicaengine_configaccepts worker-local model paths/formats. Weight/tokenizer/context/token-ID mismatches and transfer failures raise errors. Supervisor and worker/model environments must use matching Python and RPC serialization versions. Documentation and all nine translations are updated; the benchmark runs either or both directions on an existing cluster.Final performance
Median TTFT (ms):
Qwen2.5-0.5B-Instruct, FP16, RTX 3090 Ti and M5 Pro/64 GB, vLLM 0.28.0 / SGLang 0.5.21 / mlx-lm 0.31.3. Context 8,192, eager CUDA execution, C1, greedy streaming, 32 output tokens, five samples per prompt length after warmup, distinct early prefixes and no complete-page cache reuse. Standalone vLLM uses its default 16-token blocks; P/D uses canonical 64-token pages. Median end-to-end TTFT includes routing, prefill, CPU/network copies and decode. Measured LAN payload throughput is approximately 85 MB/s in both directions. Each retained GPU sample passed the external ownership monitor; runs with observed measurement interference are retried. These P/D combinations have no TTFT advantage over standalone decode on this small model and current link. The table retains the previous final measurements; this revision reruns functional/lifecycle validation and does not claim a new full performance comparison.
Validation
imported_tokens/host_bytes, with zerogpu_bytesand no active handoffs after completion. The merged vLLM/SGLang cancellation retry and page-allocation fixes remain in place; host imports also cover minimum/full target allocation. Invalid per-replica weight formats fail before directory/source/model creation.Latest-head CI is running.