vllm-rbln¶
Reference: v0.11.3a21, an alpha. Its dependency is vLLM 0.26.0+cpu; the plugin's version is separate. Only the native RBLNScheduler and RBLNKVCacheManager full-attention paths are considered.
Tagged behavior¶
RBLNScheduler.schedule constrains a batch to decodes or a lone prefill. Accepting a waiting prefill can discard an already selected decode batch. DecodeBatchBudget separates a PP-dependent hard cap from a soft cap based on current demand. Selection, decode budget
The waiting path calls allocate_slots with full_sequence_must_fit=True: admission tests whether the current full sequence fits even when the allocation is only for the next chunk. Admission capacity and actual allocation are different quantities. Scheduler
Sub-block caching finds a prefix inside a larger physical block and creates copy operations into another block. apply_sub_block_match transfers source references to the copy operations; release_copy_ops releases them. Lookup granularity, allocation granularity and copy lifetime must remain separate. Cache manager
Compiled inputs and padding¶
The native runner compiles decode shapes up to the PP-stage ceiling
max_num_seqs // pipeline_parallel_size, then rounds active decode requests
up to the smallest configured bucket. Buckets may be linear, exponential or
manual; a missing covering bucket is an error, not an arbitrary new shape.
Runner bucket configuration,
bucket lookup
For text inputs the runner stages a lone prefill with query dimension
max_num_tokens, even when its actual chunk is shorter. Decode uses padded
request rows and the step's uniform query length. InputStager fills dummy
rows/positions and copies only the actual rectangle. Padding changes device
work and buffers; it must not become extra generated/computed request tokens.
Input layout,
staging
determine_batch_execution_and_padding requires a uniform query length
(num_tokens % num_reqs == 0). Its specialized DP path can force decoding
peers to the top bucket and prefill token dimension when another rank
prefills. This applies even with ordinary one-token full-attention decode;
local phase isolation does not remove cross-rank shape coordination.
Shape routes
For a local non-speculative model, a cost expression can charge fixed
prefill width or bucketed decoders while the logical work stays unchanged.
The current example uses illustrative costs and does not emulate these
compiled shapes.
Executable serQ approximation¶
examples/vendors/rbln.sq is an executable approximation of the native
RBLNScheduler: a step runs one prefill or a decode-only batch, over
vLLM's prefix cache and preemption. PP caps, remote-KV admission and
sub-block copying are not modeled. The sections below build it a part at a
time: what the plugin does, what the program needs for it, and how serQ
writes it.
The device and the engine¶
One NPU with 8192 tokens of KV, and an engine that keeps at most four requests resident and schedules at most 256 tokens a step. The engine block stays open for the request and the schedule below:
What a request does¶
The RBLN scheduler treats one request as vLLM does: prefill what the cache
does not hold, then decode. RBLNScheduler hands a preemption to upstream
vLLM (_preempt_request), which keeps the generated tokens and
drops their KV, so a resumed request prefills from what it had computed.
The engine keeps both values the program needs, as in
examples/multi-turn/vllm.sq: request.known, every token the request
has, and request.hit, the cached full blocks of known − 1. The
scheduler reads them when it admits the request, and so the live token
budget, budget_left(llm), rather than a value captured before queuing.
A waiting request looks up its prefix hit (get_computed_blocks),
which the admission's reuse names. The step's blocks are cached once
scheduling is final (cache_blocks), which is its cache.
One prefill or a decode-only batch¶
RBLNScheduler.schedule constrains a batch to decodes or a lone prefill,
and the waiting path calls allocate_slots with
full_sequence_must_fit=True (Scheduler). In serQ the first is
exclusive prefill, and the second is a reserve beside the units the
admission takes. The step's cost follows and closes the engine block:
scheduler {
exclusive prefill each at most (128);
admit waiting while (running.preempted == 0) each at most (128)
taking reqs (1), kv (min(request.known, request.hit + min(128, budget_left(llm))))
reserve (request.known)
reuse (floor(request.known - 1, blocksize(kv)))
cache (request.input + request.output - 1);
}
worker {
forward (0.002 + 0.00001 * batch.tokens);
}
}
exclusive prefill selects either one prefill or a decode-only batch.
A fitting waiting prefill can replace tentative resident decodes and use the
full token budget. Cancelled decode work does not advance computed KV; its
already acquired allocation stays held. A selected prefill stops further
waiting admission. Ordinary capacity, budget-exhaustion and preemption gates
still apply. See the exclusive prefill reference.
The admission takes the reused prefix plus a chunk of at most 128, if the
whole sequence fits. reserve (known) tests the current sequence's capacity
(the prompt, or what a resumed request had computed), while taking
allocates only the initial chunk and growing kv extends it as computation
advances.
The prefix cache and preemption¶
A failed allocation preempts the last running request under FCFS
(running.pop()). That is preempt lifo on kv, beside the
16-token blocks and LRU eviction of vLLM's prefix cache; the waiting queue
is FCFS:
The workload¶
Six requests at once, each a 256-token prompt wanting 16 tokens back. The
workload is not in the program: it is a file of its own,
examples/workloads/rbln_batch.sq, given when the program runs (serq run
examples/vendors/rbln.sq --workload examples/workloads/rbln_batch.sq):
workload {
arrive batch(6);
init { set prompt = 256; set out = 16; }
send (prompt, out);
}
The server takes each request's prompt and output to the engine:
server (prompt, out) {
llm (prompt, out + 1); // the model's `out` decode steps after the prefill's token
}
In this workload neither the prefix cache nor preemption fires: the six requests are separate sessions, and serQ's cache is keyed by session where vLLM's is shared by content hash, so none hits another's prefix; four slots of at most 272 tokens never fill 8192 tokens (512 blocks) of KV.
The example covers local phase isolation. PP caps, remote-KV decode-ready admission guards and sub-block copy semantics remain outside it. The hand-derived interpreter regressions do not establish native scheduler equivalence.
The whole program, and its workload
// vllm-rbln's RBLNScheduler (v0.11.3a21) on one NPU, approximated.
// docs/use-cases/rbln.md explains it a part at a time; its workload is
// examples/workloads/rbln_batch.sq.
fn main() {
device npu { kv cap 8192; }
engine llm on npu {
reqs cap 4;
tokens cap 256;
scheduler {
exclusive prefill each at most (128);
admit waiting while (running.preempted == 0) each at most (128)
taking reqs (1), kv (min(request.known, request.hit + min(128, budget_left(llm))))
reserve (request.known)
reuse (floor(request.known - 1, blocksize(kv)))
cache (request.input + request.output - 1);
}
worker {
forward (0.002 + 0.00001 * batch.tokens);
}
}
pool kv on npu { block 16; evict lru; preempt lifo; }
pool reqs on llm { queue fifo; }
server (prompt, out) {
llm (prompt, out + 1); // the model's `out` decode steps after the prefill's token
}
}
Remaining gaps¶
| Requirement | Needed refinement |
|---|---|
| PP hard/soft decode caps | Per-request selection and batch constraints, separate from resident slot count |
| Sub-block hit and copy | Independent lookup/allocation units and source/destination objects with copy leases |
Reducing block to the sub-block size would also reduce physical allocation. It can match hit counts while predicting the wrong memory pressure.
Validation¶
this reduced example links and completes its six requests. All 44 iteration assignments were checked to contain either a lone prefill or decodes only. The interpreter policy also has six hand-derived regression tests. No native RBLN differential test has been run.