Skip to content

vllm.distributed.kv_transfer.kv_connector.v1.nixl.base_scheduler

Base scheduler-side logic for the NIXL connector.

Classes:

NixlBaseConnectorScheduler

Base implementation of Scheduler side methods shared by pull and push.

Methods:

_get_remote_prefill_token_count(request)

D-side only. The number of prompt tokens to load from the prefiller: the prompt minus _num_prefill_backoff_tokens(), mirroring P's cut.

In pull mode P also reports its count in remote_num_tokens, which wins when the two sides disagree (e.g. a heterogeneous P that cuts at a different Mamba checkpoint); that only costs a prefix-cache entry. Push mode registers D's blocks before P finishes, so it relies on the mirrored cut alone.

_nixl_handshake_listener(encoded_data, ready_event, stop_event, host, port) staticmethod

Background thread for getting new NIXL handshakes.

_num_prefill_backoff_tokens(num_prompt_tokens)

Trailing prompt tokens the prefiller skips and the decoder recomputes: _prefill_backoff(), widened for a prefix-cached Mamba model down to the last checkpoint a local prefill would cache. P then backs off up to one block and sends a state that sits on a checkpoint; D recomputes the tail and caches that state, so later D-local turns of the conversation hit it.

_prefill_backoff()

Trailing prompt tokens the prefiller must not compute; the decoder recomputes them locally.

Mamba needs h(N-1) so the decoder can derive h(N) itself. DSV41's sliding window under bounded replay is not replayed after a P/D load, so it must be laid out for the token the decoder recomputes. Multi-module MTP needs to keep its whole lookahead window off of the prefiller, which would otherwise embed the unverified drafts in the MTP layer's KV cache. The decoder would never rebuild them, because the update is sized by the rejection count, which is zero for the first decode.

_stop_heartbeat(req_id)

Remove req_id from heartbeat tracking (if tracked).

_truncate_request_for_prefill(request)

P-side only: drop the trailing _num_prefill_backoff_tokens() prompt tokens so the prefiller stops short of what the decoder recomputes locally. For Mamba that is the single token needed to yield h(N-1), or the tail past a prefix-cache checkpoint; for multi-module MTP it is the drafter's whole lookahead window.

Guarded by _p_side_truncated to avoid repeated truncation if the request is preempted and rescheduled.

get_exchange_clipped_blocks(block_ids, clip_ssm=True)

Clip a request's block lists down to the transferable blocks.

Sliding-window groups keep only the in-window tail: the KV cache manager allocates blocks for the entire sequence length and cleans up out-of-window blocks only prior to the request_finished_all_groups hook.

SSM groups keep only their state-bearing slot: the trailing speculative scratch slots and everything before the running state (null placeholders and the previous step's superseded state) go.

Use this at every block-id exchange point. Pass clip_ssm=False for per-step partial lists (host-buffer save), where the SSM strip does not apply.

on_new_request(request)

Track a request that may need heartbeats.

set_xfer_handshake_metadata(metadata)

Set the KV connector handshake metadata for this connector.

Parameters:

  • metadata

    (dict) –

    the handshake metadata to set.

update_connector_output(connector_output)

Stop heartbeating for requests whose KV transfer completed.