mirror of
https://github.com/lightseekorg/tokenspeed.git
synced 2026-12-04 10:26:50 +08:00
feat(pd): decode-extra-slots
Separate decode execution permits from resident request capacity and expose KV-ready queue occupancy and wait duration. Signed-off-by: sunshengqi <69040952+simple-sun@users.noreply.github.com>
This commit is contained in:
@@ -914,6 +914,29 @@ gets a new identity even if its transport IP and port are reused. The sender
|
||||
refreshes cached remote memory keys on address reuse without changing the
|
||||
public address used by EPD.
|
||||
|
||||
### Decode receive capacity
|
||||
|
||||
On a decode node, --disaggregation-decode-extra-slots adds shared resident
|
||||
request slots per attention DP rank. It defaults to zero. A positive value
|
||||
is rejected on prefill, fused and encode nodes.
|
||||
|
||||
If the rank-local execution limit is B = max-num-seqs / attention DP size
|
||||
and the extra count is E, the resident pool has C = B + E real request rows.
|
||||
For example, max-num-seqs=48 and E=16 with two attention DP ranks gives
|
||||
B=24 and C=40 on each rank. TP replicas use the same rank-local limits.
|
||||
|
||||
The extra rows allow KV reception and ready requests to overlap a full
|
||||
decode batch. They do not enlarge the execution batch, CUDA graph ladder,
|
||||
or single-forward scratch. Request-indexed persistent state grows with C,
|
||||
and every admitted request still consumes the ordinary LCM KV capacity.
|
||||
Receiving all configured requests at their maximum context length is not
|
||||
guaranteed. More rows can reduce the remaining KV budget.
|
||||
|
||||
Use an explicit extra count when measuring the feature. Restart with zero
|
||||
to restore the original capacity; shrinking a live request pool is not
|
||||
supported. A request keeps its original slot when reception completes and
|
||||
waits for an execution permit before its first decode.
|
||||
|
||||
## Observability
|
||||
|
||||
| Parameter | Purpose |
|
||||
@@ -1032,16 +1055,41 @@ metrics on its `--prometheus-port`.
|
||||
`tokenspeed:num_requests_running` counts the rank's running batch: local
|
||||
prefill forwards, prompts whose prefill is done (about to decode on a fused
|
||||
rank, or awaiting the PD transfer on a prefill rank), and decode rows. On a
|
||||
decode rank that is the decode batch, bounded by the rank's
|
||||
`max_num_seqs / attention-DP size`; it excludes `RemotePrefilling` requests
|
||||
waiting for the prefill peer's KV.
|
||||
decode rank it includes requests whose KV has landed but that are waiting
|
||||
for an execution permit; it excludes `RemotePrefilling` requests waiting
|
||||
for the prefill peer's KV. With extra resident slots, this gauge can exceed
|
||||
the execution batch limit. The decode batch line's #running-req remains
|
||||
the actual number of rows dispatched.
|
||||
`tokenspeed:num_requests_inflight` counts every request the rank admitted and
|
||||
has not finished, including the scheduler's waiting and retracted requests and
|
||||
the PD states the batch excludes — a decode rank's `RemotePrefilling` and
|
||||
`PdTransferring` requests wait for the prefill node's KV and take no batch row.
|
||||
On a PD decode rank the inflight gauge therefore exceeds the running gauge while
|
||||
prompts wait for transfer; use `num_requests_running` for batch saturation and
|
||||
`num_requests_inflight` for how much work the rank holds.
|
||||
prompts wait for transfer. The inflight gauge also includes unadmitted work,
|
||||
so it does not measure request-slot occupancy.
|
||||
|
||||
Three additional rank-local gauges expose the decode capacity split:
|
||||
|
||||
| Metric | Meaning |
|
||||
| --- | --- |
|
||||
| tokenspeed:num_requests_resident | Requests holding a request-pool slot, bounded by B + E. Includes slots still held while a finished request's work drains. |
|
||||
| tokenspeed:num_active_decode_slots | Execution permits held by requests or their in-flight work, bounded by B. Includes permits reserved for restore and permits awaiting the final forward result. |
|
||||
| tokenspeed:num_decode_ready_waiting_reqs | Resident requests whose KV is ready but that have no execution permit. |
|
||||
|
||||
The decode line reports these as #slots(resident/active-decode/ready-waiting).
|
||||
For B=36 and E=128, sustained resident=164 proves the resident pool is full;
|
||||
active-decode=36 proves the execution permits are occupied. Use the actual
|
||||
batch row count and throughput alongside these counters: draining or
|
||||
restoring work can hold a permit without dispatching a row that round.
|
||||
|
||||
The rank-local histogram tokenspeed:decode_ready_wait_seconds measures E-queue
|
||||
wait from the decode host observing complete prefill KV arrival to the first
|
||||
decode forward dispatch. It records once per request, including requests that
|
||||
dispatch immediately, and excludes requests cancelled or finished before decode.
|
||||
It excludes prefill computation and KV transfer; dispatch is the host boundary,
|
||||
not a GPU kernel start timestamp. The 0.1-second bucket measures how many observed
|
||||
waits meet a 100 ms target. Requests still waiting have no histogram observation
|
||||
yet; read it alongside tokenspeed:num_decode_ready_waiting_reqs.
|
||||
|
||||
The decode role splits that PD wait into its own gauges.
|
||||
`tokenspeed:num_decode_kv_wait_reqs` counts `RemotePrefilling` requests: the
|
||||
|
||||
@@ -2032,10 +2032,15 @@ sets both sides: the arena holds at least that many parent blocks (more when
|
||||
admitting one token per group needs more), and the concurrency is that many
|
||||
rows, capped at the scheduler's `max_bs`.
|
||||
|
||||
The runtime divides its global `max_num_seqs` across attention DP ranks to
|
||||
produce each scheduler's rank-local `max_batch_size`. These values limit
|
||||
simultaneous sequence slots; they do **not** reserve enough history cache for
|
||||
that many maximum-length requests. Aggregate prompt and decode growth must
|
||||
The runtime divides its global max_num_seqs across attention DP ranks to
|
||||
produce each scheduler's rank-local max_batch_size, the execution capacity.
|
||||
The separate max_resident_requests sizes its request pool. A D role adds
|
||||
disaggregation-decode-extra-slots per attention DP rank to that pool so
|
||||
requests can receive KV while the model executes a full batch. Concurrent
|
||||
group sizing prices resident states, tails and protected windows against
|
||||
the resident capacity; execution scratch and checkpoint retention keep the
|
||||
execution bound. Neither value reserves enough history cache for that many
|
||||
maximum-length requests. Aggregate prompt and decode growth must
|
||||
still fit the recipe's reported token capacity. When that dynamic pool is
|
||||
overcommitted, admission can fail even though the batch still has a free
|
||||
sequence slot.
|
||||
|
||||
@@ -9,6 +9,29 @@ Companion documents: `event-loop.md` (the control/data plane split that
|
||||
consumes these plans), `cache-concepts.md` (the vocabulary below —
|
||||
prefix granularity, cache groups, LCM blocks).
|
||||
|
||||
## Request slots and active decode capacity
|
||||
|
||||
The rank-local max_batch_size bounds model forwards and active decode
|
||||
permits. The separate max_resident_requests bounds the shared request pool.
|
||||
On a D role, disaggregation-decode-extra-slots adds resident rows without
|
||||
enlarging model batches. RemotePrefilling and a PrefillDone waiting for its
|
||||
first decode hold a request row and KV pages but no execution permit. All
|
||||
these requests share one pool; extra rows are not a dedicated transfer pool.
|
||||
|
||||
A first local decode acquires a move-only permit and keeps it across rounds.
|
||||
Newly completed prefills cannot displace an already streaming request.
|
||||
Restoring a Decoding request reserves a permit before issuing the restore;
|
||||
the transfer owns it until acknowledgement, including after cancellation.
|
||||
Finishing requests keep their resources until outstanding results land.
|
||||
An abort drains those results without publishing its completed pages.
|
||||
Retraction relinquishes the permit once the existing in-flight guards allow
|
||||
the request to leave; readmission obtains a new one ahead of fresh work.
|
||||
|
||||
A missing request row or decode permit is a scheduling wait, not a cache
|
||||
capacity failure. Only a failed KV admission enters the existing capacity
|
||||
recovery policy. The P role hands execution to its peer and does not consume
|
||||
a local decode permit.
|
||||
|
||||
## 1. Admission is per chunk
|
||||
|
||||
An optional `--chunk-prefill-kv-size` also bounds the KV read by a local
|
||||
|
||||
@@ -94,6 +94,13 @@ ranks; callers need not establish an inference context.
|
||||
|
||||
### Buffer sizing: the ladder is a performance subset, never a capacity limit
|
||||
|
||||
Request slot capacity is independent of forward batch capacity. PD decode
|
||||
extra slots increase the real request range to 1..C, keep null row 0, and
|
||||
place padding at C+1. Persistent state indexed by request slot covers C+2
|
||||
rows. A batch of at most B requests can contain a slot index greater than B;
|
||||
batch-indexed inputs, metadata, graph buckets and scratch remain bounded by
|
||||
B. Passing a larger resident pool must not enlarge the execution ladder.
|
||||
|
||||
`ForwardStepRunner` distinguishes `max_capture_bs` (top of the capture ladder,
|
||||
bounded by `max_cudagraph_capture_size`) from `max_decode_bs`
|
||||
(`max_num_seqs // dp_size`, floored at `max_capture_bs`). Persistent decode
|
||||
|
||||
@@ -240,6 +240,7 @@ def scheduler_config_from_args(
|
||||
storage_config: StorageConfig | None,
|
||||
max_scheduled_tokens: int,
|
||||
max_batch_size: int,
|
||||
max_resident_requests: int,
|
||||
decode_input_tokens: int,
|
||||
overlap_schedule_depth: int,
|
||||
enable_kv_cache_events: bool,
|
||||
@@ -255,6 +256,7 @@ def scheduler_config_from_args(
|
||||
when no storage backend is configured.
|
||||
max_scheduled_tokens: Per-step prefill token budget.
|
||||
max_batch_size: Rank-local batch slots.
|
||||
max_resident_requests: Rank-local resident request slots.
|
||||
decode_input_tokens: Verify width per decode step.
|
||||
overlap_schedule_depth: Dispatched-but-uncommitted plans allowed.
|
||||
enable_kv_cache_events: Whether KV cache events are published.
|
||||
@@ -272,6 +274,7 @@ def scheduler_config_from_args(
|
||||
// geometry.prefix_granularity
|
||||
),
|
||||
max_batch_size=max_batch_size,
|
||||
max_resident_requests=max_resident_requests,
|
||||
prefix_granularity=geometry.prefix_granularity,
|
||||
num_host_pages=specs.num_host_pages,
|
||||
disable_l2_cache=not server_args.enable_kvstore,
|
||||
|
||||
@@ -1270,6 +1270,9 @@ class HostBootstrap:
|
||||
)
|
||||
# The scheduler's request slots are per attention-DP rank.
|
||||
max_batch_size = server_args.max_num_seqs // max(mapping.attn.dp_size, 1)
|
||||
max_resident_requests = (
|
||||
max_batch_size + server_args.disaggregation_decode_extra_slots
|
||||
)
|
||||
device = build_device_side(
|
||||
server_args=server_args,
|
||||
model_config=model_config,
|
||||
@@ -1281,6 +1284,7 @@ class HostBootstrap:
|
||||
overlap_schedule_depth=overlap_schedule_depth,
|
||||
decode_input_tokens=decode_input_tokens,
|
||||
max_batch_size=max_batch_size,
|
||||
max_resident_requests=max_resident_requests,
|
||||
kv_transfer_builder=functools.partial(
|
||||
build_host_peer, outbox=pd_outbox
|
||||
),
|
||||
@@ -1311,6 +1315,7 @@ class HostBootstrap:
|
||||
storage_config=storage_config,
|
||||
max_scheduled_tokens=server_args.chunked_prefill_size,
|
||||
max_batch_size=max_batch_size,
|
||||
max_resident_requests=max_resident_requests,
|
||||
decode_input_tokens=decode_input_tokens,
|
||||
overlap_schedule_depth=overlap_schedule_depth,
|
||||
enable_kv_cache_events=kv_events,
|
||||
|
||||
@@ -112,6 +112,7 @@ def make_config(
|
||||
enable_l3_storage: bool,
|
||||
role: str,
|
||||
*,
|
||||
max_resident_requests: int,
|
||||
num_snapshot_pages: int,
|
||||
host_group_packing: Sequence[int],
|
||||
max_retracted_requests: int,
|
||||
@@ -144,6 +145,8 @@ def make_config(
|
||||
oldest-request protection; False preserves submission order.
|
||||
max_batch_size: Per-rank batch slots -- the most requests this rank
|
||||
runs at once (``--max-num-seqs`` over the attention-DP ranks).
|
||||
max_resident_requests: Per-rank requests that may own a request slot,
|
||||
including requests waiting for remote KV or their first decode.
|
||||
prefix_granularity: Prefix-hash page size in tokens.
|
||||
num_host_pages: Host L2 LCM blocks including the null page; 0 without
|
||||
the L2 tier.
|
||||
@@ -258,6 +261,7 @@ def make_config(
|
||||
if max_kv_page_num:
|
||||
cfg.max_kv_page_num = max_kv_page_num
|
||||
cfg.max_batch_size = max_batch_size
|
||||
cfg.max_resident_requests = max_resident_requests
|
||||
cfg.prefix_granularity = prefix_granularity
|
||||
|
||||
cfg.num_host_pages = num_host_pages
|
||||
|
||||
@@ -1413,6 +1413,7 @@ def _retraction_pool_request(
|
||||
*,
|
||||
host_group_packing,
|
||||
max_batch_size: int,
|
||||
max_resident_requests: int,
|
||||
max_context_len: int,
|
||||
decode_input_tokens: int,
|
||||
overlap_schedule_depth: int,
|
||||
@@ -1443,7 +1444,8 @@ def _retraction_pool_request(
|
||||
virtual_packing=host_group_packing,
|
||||
limits=SchedulerLimits(
|
||||
role=scheduler_role(server_args.disaggregation_mode),
|
||||
max_live_requests=max_batch_size,
|
||||
max_batch_size=max_batch_size,
|
||||
max_resident_requests=max_resident_requests,
|
||||
max_scheduled_tokens=int(server_args.chunked_prefill_size),
|
||||
max_context_len=max_context_len,
|
||||
decode_input_tokens=decode_input_tokens,
|
||||
@@ -1474,6 +1476,7 @@ def build_device_side(
|
||||
overlap_schedule_depth: int,
|
||||
decode_input_tokens: int,
|
||||
max_batch_size: int,
|
||||
max_resident_requests: int,
|
||||
kv_transfer_builder,
|
||||
) -> DeviceBuild:
|
||||
"""Construct the whole device side and return the three views of it.
|
||||
@@ -1502,9 +1505,9 @@ def build_device_side(
|
||||
size the KV budget.
|
||||
overlap_schedule_depth: Decode KV reservation depth.
|
||||
decode_input_tokens: Tokens each decode step feeds per request.
|
||||
max_batch_size: Rank-local scheduler batch bound; the executor
|
||||
sizes its request pool one row past it for the graph-padding
|
||||
sink row.
|
||||
max_batch_size: Rank-local scheduler execution bound.
|
||||
max_resident_requests: Rank-local request-pool bound. Null row 0 and
|
||||
the graph-padding row sit outside the live range.
|
||||
kv_transfer_builder: Builds the PD transfer peer from the finished
|
||||
attention build, or returns None outside disaggregation: the
|
||||
host's ``build_host_peer`` (``pd/host_peer.py``), bound to the
|
||||
@@ -1654,7 +1657,7 @@ def build_device_side(
|
||||
server_args=server_args,
|
||||
model_config=model_config,
|
||||
model=target.model,
|
||||
max_req_pool_size=RequestSlotLayout(max_batch_size).padding,
|
||||
max_req_pool_size=RequestSlotLayout(max_resident_requests).padding,
|
||||
gpu_id=gpu_id,
|
||||
global_rank=global_rank,
|
||||
prefix_granularity=views.cache_geometry.prefix_granularity,
|
||||
@@ -1741,6 +1744,7 @@ def build_device_side(
|
||||
views.token_to_kv_pool.arena.runtime_contract,
|
||||
host_group_packing=host_tail_packing,
|
||||
max_batch_size=max_batch_size,
|
||||
max_resident_requests=max_resident_requests,
|
||||
max_context_len=model_config.context_len + server_args.spec_context_pad,
|
||||
decode_input_tokens=decode_input_tokens,
|
||||
overlap_schedule_depth=overlap_schedule_depth,
|
||||
|
||||
@@ -390,7 +390,7 @@ class ModelExecutorConfig:
|
||||
"""
|
||||
|
||||
# Rank-local graph-padding req-pool index. The C++ scheduler owns real rows
|
||||
# 1..max_batch_size and row 0 is reserved, so this must sit after the
|
||||
# 1..max_resident_requests and row 0 is reserved, so this must sit after the
|
||||
# scheduler-owned range.
|
||||
max_req_pool_size: int
|
||||
output_length: int
|
||||
@@ -918,6 +918,7 @@ class ModelExecutor:
|
||||
)
|
||||
if self.draft_attn_backend is not None:
|
||||
self.draft_attn_backend.configure_runtime(
|
||||
request_slot_capacity=self.config.max_req_pool_size + 1,
|
||||
cache_group_specs=tuple(
|
||||
_cache_arena_attr(
|
||||
self.draft_token_to_kv_pool, "cache_group_specs", ()
|
||||
|
||||
@@ -241,7 +241,7 @@ class InklingAttnBackend(AttentionBackend):
|
||||
conv_pool = InklingConvStatePool(
|
||||
num_layers=num_layers,
|
||||
# Row 0 is reserved; the additional slot covers padding.
|
||||
num_slots=attn_config.max_bs + 2,
|
||||
num_slots=attn_config.max_resident_requests + 2,
|
||||
conv_dim=inkling_conv_total_dim(
|
||||
text_config, attn_config.component(SoftmaxAttnConfig).attn_tp_size
|
||||
),
|
||||
@@ -251,7 +251,7 @@ class InklingAttnBackend(AttentionBackend):
|
||||
)
|
||||
logger.info(
|
||||
f"Inkling {('draft ' if is_draft else '')!s}conv state pool: {num_layers:d} "
|
||||
f"layers x {attn_config.max_bs + 2:d} slots, "
|
||||
f"layers x {attn_config.max_resident_requests + 2:d} slots, "
|
||||
f"{conv_pool.mem_usage_bytes() / (1 << 20):.1f} MiB",
|
||||
)
|
||||
return cls(
|
||||
|
||||
@@ -204,6 +204,8 @@ class AttnConfig:
|
||||
# against this; user-facing limits stay on the logical context_len.
|
||||
context_len: int
|
||||
max_bs: int
|
||||
# Real resident requests. Null row 0 and graph padding are additional rows.
|
||||
max_resident_requests: int
|
||||
# True iff server_args.disaggregation_mode != "null"; cache recipes use
|
||||
# it to stamp transfer policies onto the cache group specs.
|
||||
pd_disaggregation_enabled: bool = False
|
||||
@@ -231,6 +233,13 @@ class AttnConfig:
|
||||
components: tuple[AttnComponentSpec, ...]
|
||||
|
||||
def __post_init__(self):
|
||||
from tokenspeed.runtime.execution.request_slots import RequestSlotLayout
|
||||
|
||||
if type(self.max_bs) is not int or self.max_bs <= 0:
|
||||
raise ValueError("max_bs must be a positive integer")
|
||||
RequestSlotLayout(self.max_resident_requests)
|
||||
if self.max_resident_requests < self.max_bs:
|
||||
raise ValueError("max_resident_requests must be at least max_bs")
|
||||
softmax_components = [
|
||||
c for c in self.components if isinstance(c, SoftmaxAttnConfig)
|
||||
]
|
||||
@@ -353,6 +362,9 @@ def model_wide_kwargs(
|
||||
context parallel shard (GPU DSA through the MLA config, and V4.1). It only
|
||||
affects a draft config; ``__post_init__`` refuses a target that cannot shard.
|
||||
"""
|
||||
max_bs = server_args.max_num_seqs // (
|
||||
server_args.data_parallel_size or server_args.mapping.attn.dp_size
|
||||
)
|
||||
kwargs = dict(
|
||||
device=server_args.device,
|
||||
dtype=model_config.dtype,
|
||||
@@ -360,8 +372,8 @@ def model_wide_kwargs(
|
||||
kv_cache_mxfp8=kv_cache_mxfp8,
|
||||
kv_cache_quant_method=server_args.kv_cache_quant_method,
|
||||
context_len=model_config.context_len + server_args.spec_context_pad,
|
||||
max_bs=server_args.max_num_seqs
|
||||
// (server_args.data_parallel_size or server_args.mapping.attn.dp_size),
|
||||
max_bs=max_bs,
|
||||
max_resident_requests=max_bs + server_args.disaggregation_decode_extra_slots,
|
||||
pd_disaggregation_enabled=server_args.disaggregation_mode != "null",
|
||||
is_draft=is_draft,
|
||||
draft_block_decode=draft_block_decode,
|
||||
|
||||
@@ -178,8 +178,12 @@ class CacheRecipe(ABC):
|
||||
None
|
||||
if policy is None
|
||||
else policy.bind(
|
||||
request_slots=RequestSlotLayout(self.attn_config.max_bs).capacity,
|
||||
device_rows=RequestSlotLayout(self.attn_config.max_bs).capacity
|
||||
request_slots=RequestSlotLayout(
|
||||
self.attn_config.max_resident_requests
|
||||
).capacity,
|
||||
device_rows=RequestSlotLayout(
|
||||
self.attn_config.max_resident_requests
|
||||
).capacity
|
||||
* (policy.hot_tokens + policy.reserved_tokens),
|
||||
)
|
||||
)
|
||||
@@ -497,13 +501,19 @@ class CacheRecipe(ABC):
|
||||
unless verify scratch lives in the pool, which then needs a row per
|
||||
request whatever pool is bound.
|
||||
"""
|
||||
serving_limits = self.probe_batch_rows is None or self.verify_scratch_in_pool()
|
||||
max_batch_size = (
|
||||
self.attn_config.max_bs
|
||||
if serving_limits
|
||||
else min(self.attn_config.max_bs, self.probe_batch_rows)
|
||||
)
|
||||
return SchedulerLimits(
|
||||
role=scheduler_role(self.server_args.disaggregation_mode),
|
||||
# One live request per fabricated row; serving concurrency is elsewhere.
|
||||
max_live_requests=(
|
||||
self.attn_config.max_bs
|
||||
if self.probe_batch_rows is None or self.verify_scratch_in_pool()
|
||||
else min(self.attn_config.max_bs, self.probe_batch_rows)
|
||||
max_batch_size=max_batch_size,
|
||||
max_resident_requests=(
|
||||
self.attn_config.max_resident_requests
|
||||
if serving_limits
|
||||
else max_batch_size
|
||||
),
|
||||
max_scheduled_tokens=int(self.server_args.chunked_prefill_size),
|
||||
max_context_len=self.attn_config.context_len,
|
||||
|
||||
@@ -431,9 +431,11 @@ class Glm53FlashRecipe(CacheRecipe):
|
||||
|
||||
@override
|
||||
def pool_options(self) -> Glm53FlashPoolOptions:
|
||||
max_bs = self.attn_config.max_bs
|
||||
max_resident_requests = self.attn_config.max_resident_requests
|
||||
if self.draft_attn_config is not None:
|
||||
max_bs = max(max_bs, self.draft_attn_config.max_bs)
|
||||
max_resident_requests = max(
|
||||
max_resident_requests, self.draft_attn_config.max_resident_requests
|
||||
)
|
||||
return Glm53FlashPoolOptions(
|
||||
index_kpool=require_positive_int(
|
||||
"index_kpool", self._dsa_config.index_kpool
|
||||
@@ -444,7 +446,7 @@ class Glm53FlashRecipe(CacheRecipe):
|
||||
),
|
||||
# Scheduler request IDs are 1-based; row 0 and one graph-padding
|
||||
# sentinel sit outside the live range.
|
||||
num_request_slots=max_bs + 2,
|
||||
num_request_slots=max_resident_requests + 2,
|
||||
dsa_layer_ids=tuple(
|
||||
layer_id
|
||||
for layer_id, group_id in enumerate(self.group_ids)
|
||||
|
||||
@@ -340,7 +340,7 @@ def inkling_layer_kv_head_counts(model_config) -> tuple[int, ...]:
|
||||
def _conv_ring_bytes(*, text_config, attn_config, num_layers: int, spec_tokens: int):
|
||||
from tokenspeed.runtime.configs.inkling_config import inkling_conv_total_dim
|
||||
|
||||
rows = int(attn_config.max_bs) + 2
|
||||
rows = int(attn_config.max_resident_requests) + 2
|
||||
# Match InklingAttnBackend.from_config: (W-1) taps + K chunk rows.
|
||||
spec_tokens = max(1, int(spec_tokens))
|
||||
ring_rows = int(text_config.sconv_kernel_size) - 1 + spec_tokens
|
||||
|
||||
@@ -135,7 +135,8 @@ class SchedulerLimits:
|
||||
"""
|
||||
|
||||
role: SchedulerConfig.Role
|
||||
max_live_requests: int
|
||||
max_batch_size: int
|
||||
max_resident_requests: int
|
||||
max_scheduled_tokens: int
|
||||
max_context_len: int
|
||||
decode_input_tokens: int
|
||||
@@ -167,7 +168,8 @@ def capacity_model(
|
||||
config.role = limits.role
|
||||
config.prefix_granularity = prefix_granularity
|
||||
config.max_scheduled_tokens = limits.max_scheduled_tokens
|
||||
config.max_batch_size = limits.max_live_requests
|
||||
config.max_batch_size = limits.max_batch_size
|
||||
config.max_resident_requests = limits.max_resident_requests
|
||||
config.decode_input_tokens = limits.decode_input_tokens
|
||||
config.overlap_schedule_depth = limits.overlap_schedule_depth
|
||||
config.disable_prefix_cache = limits.disable_prefix_cache
|
||||
|
||||
@@ -409,6 +409,9 @@ class ServerArgs:
|
||||
# Memory and scheduling
|
||||
gpu_memory_utilization: float | None = None
|
||||
max_num_seqs: int | None = None
|
||||
# Additional resident requests per attention-DP rank; forwards still use
|
||||
# max_num_seqs. Zero leaves the request pool at its execution capacity.
|
||||
disaggregation_decode_extra_slots: int = 0
|
||||
max_total_tokens: int | None = None
|
||||
chunked_prefill_size: int | None = None
|
||||
max_prefill_tokens: int = 8192
|
||||
@@ -857,6 +860,7 @@ class ServerArgs:
|
||||
return _SPEC_OVERSHOOT_SPANS * int(self.speculative_num_draft_tokens)
|
||||
|
||||
def __post_init__(self):
|
||||
self.validate_decode_extra_slots()
|
||||
self.validate_weight_memory_policy()
|
||||
self.validate_forward_reload()
|
||||
self.resolve_basic_defaults()
|
||||
@@ -2771,6 +2775,7 @@ class ServerArgs:
|
||||
)
|
||||
|
||||
def validate(self):
|
||||
self.validate_decode_extra_slots()
|
||||
if (
|
||||
type(self.ttft_trace_sampling_percentage) is not int
|
||||
or not 0 <= self.ttft_trace_sampling_percentage <= 100
|
||||
@@ -2859,6 +2864,17 @@ class ServerArgs:
|
||||
os.environ.setdefault("TRTLLM_ENABLE_PDL", "1")
|
||||
os.environ.setdefault("TLLM_LOG_LEVEL", "INFO")
|
||||
|
||||
def validate_decode_extra_slots(self) -> None:
|
||||
extra = self.disaggregation_decode_extra_slots
|
||||
if type(extra) is not int or extra < 0:
|
||||
raise ValueError(
|
||||
"--disaggregation-decode-extra-slots must be a non-negative integer"
|
||||
)
|
||||
if extra and self.disaggregation_mode != "decode":
|
||||
raise ValueError(
|
||||
"--disaggregation-decode-extra-slots requires --disaggregation-mode decode"
|
||||
)
|
||||
|
||||
def validate_prefill_delay(self) -> None:
|
||||
intervals = self.prefill_delay
|
||||
if intervals is None:
|
||||
@@ -3108,6 +3124,14 @@ class ServerArgs:
|
||||
default=ServerArgs.max_num_seqs,
|
||||
help="Maximum number of sequences to process concurrently.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--disaggregation-decode-extra-slots",
|
||||
type=int,
|
||||
default=ServerArgs.disaggregation_decode_extra_slots,
|
||||
help="Additional resident request slots per attention-DP rank on a "
|
||||
"decode server. These receive KV without increasing the execution "
|
||||
"concurrency set by --max-num-seqs. Defaults to zero.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--max-total-tokens",
|
||||
type=int,
|
||||
|
||||
@@ -236,6 +236,7 @@ def storage_scheduler():
|
||||
cfg.num_snapshot_pages = 1
|
||||
cfg.max_scheduled_tokens = 8
|
||||
cfg.max_batch_size = 4
|
||||
cfg.max_resident_requests = 4
|
||||
cfg.disable_l2_cache = False
|
||||
cfg.enable_l3_storage = True
|
||||
cfg.storage_config = ts.StorageConfig(
|
||||
|
||||
@@ -109,6 +109,7 @@ def kimi_recipe(
|
||||
kv_cache_dtype=kv_cache_dtype,
|
||||
kv_cache_quant_method=None,
|
||||
max_bs=max_bs,
|
||||
max_resident_requests=max_bs,
|
||||
# K3's per-group demand reads the scheduler's concurrency through
|
||||
# CacheRecipe.scheduler_limits, context length included.
|
||||
context_len=context_len,
|
||||
|
||||
@@ -74,6 +74,7 @@ def run_case(*, rank, mapping, context, dtype, queries, draft, block):
|
||||
kv_cache_quant_method="",
|
||||
context_len=blocks * granularity,
|
||||
max_bs=batch + num_extends,
|
||||
max_resident_requests=batch + num_extends,
|
||||
speculative_num_draft_tokens=spec_queries,
|
||||
is_draft=draft,
|
||||
draft_block_decode=block,
|
||||
@@ -266,6 +267,7 @@ def _make_prefill_backend(
|
||||
kv_cache_quant_method="",
|
||||
context_len=context_len,
|
||||
max_bs=3,
|
||||
max_resident_requests=3,
|
||||
speculative_num_draft_tokens=1,
|
||||
is_draft=False,
|
||||
draft_block_decode=False,
|
||||
|
||||
@@ -375,6 +375,7 @@ def test_pd_derives_ordinary_transfer_metadata_from_physical_plan(
|
||||
kv_cache_dtype=torch.bfloat16,
|
||||
context_len=256,
|
||||
max_bs=4,
|
||||
max_resident_requests=4,
|
||||
kv_cache_quant_method="none",
|
||||
pd_disaggregation_enabled=True,
|
||||
components=(spec,),
|
||||
|
||||
@@ -90,6 +90,7 @@ def _attn_config(family: str, pd_enabled: bool):
|
||||
kv_cache_dtype=torch.bfloat16,
|
||||
context_len=1024,
|
||||
max_bs=1,
|
||||
max_resident_requests=1,
|
||||
kernel_page_size=_P,
|
||||
kv_cache_quant_method="",
|
||||
pd_disaggregation_enabled=pd_enabled,
|
||||
|
||||
@@ -94,6 +94,7 @@ def _config(layer_ids=(0,)):
|
||||
kv_cache_quant_method="none",
|
||||
context_len=4096,
|
||||
max_bs=8,
|
||||
max_resident_requests=8,
|
||||
is_draft=False,
|
||||
speculative_num_draft_tokens=1,
|
||||
components=(spec, gdn),
|
||||
|
||||
@@ -84,6 +84,7 @@ def _backend():
|
||||
kv_cache_quant_method="none",
|
||||
context_len=4096,
|
||||
max_bs=8,
|
||||
max_resident_requests=8,
|
||||
is_draft=False,
|
||||
speculative_num_draft_tokens=1,
|
||||
components=(spec, mamba2),
|
||||
|
||||
@@ -76,6 +76,7 @@ def _attn_config(spec: DSAConfig) -> AttnConfig:
|
||||
kv_cache_dtype=torch.bfloat16,
|
||||
context_len=256,
|
||||
max_bs=1,
|
||||
max_resident_requests=1,
|
||||
kernel_page_size=PREFIX,
|
||||
kv_cache_quant_method="",
|
||||
pd_disaggregation_enabled=False,
|
||||
@@ -170,6 +171,7 @@ def _qcp_attn_config(spec: DSAConfig) -> AttnConfig:
|
||||
kv_cache_dtype=torch.bfloat16,
|
||||
context_len=256,
|
||||
max_bs=1,
|
||||
max_resident_requests=1,
|
||||
kernel_page_size=PREFIX,
|
||||
kv_cache_quant_method="none",
|
||||
pd_disaggregation_enabled=False,
|
||||
|
||||
@@ -87,6 +87,7 @@ def test_beam_scheduler_preserves_nonmixed_capacity_and_explicit_opt_in(mixed):
|
||||
storage_config=None,
|
||||
max_scheduled_tokens=args.chunked_prefill_size,
|
||||
max_batch_size=args.max_num_seqs,
|
||||
max_resident_requests=args.max_num_seqs,
|
||||
decode_input_tokens=1,
|
||||
overlap_schedule_depth=0,
|
||||
enable_kv_cache_events=False,
|
||||
|
||||
@@ -187,6 +187,7 @@ def _attn_config(layer_types, window) -> AttnConfig:
|
||||
kernel_page_size=64,
|
||||
context_len=262144,
|
||||
max_bs=64,
|
||||
max_resident_requests=64,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -164,6 +164,7 @@ def test_sliding_window_draft_layer_rides_a_sliding_cache_group(
|
||||
kernel_page_size=64,
|
||||
context_len=1024,
|
||||
max_bs=2,
|
||||
max_resident_requests=2,
|
||||
)
|
||||
draft_attn_config = AttnConfig(
|
||||
components=(replace(target, cache_layer_types=("sliding_attention",)),),
|
||||
|
||||
@@ -187,6 +187,7 @@ def _msa_server_args(**overrides) -> SimpleNamespace:
|
||||
attention_backend="trtllm",
|
||||
drafter_attention_backend=None,
|
||||
max_num_seqs=16,
|
||||
disaggregation_decode_extra_slots=0,
|
||||
data_parallel_size=1,
|
||||
attn_tp_size=4,
|
||||
max_cudagraph_capture_size=16,
|
||||
|
||||
@@ -545,6 +545,7 @@ def _prefill_cache_and_backend(monkeypatch, *, options):
|
||||
kv_cache_quant_method="none",
|
||||
context_len=512,
|
||||
max_bs=4,
|
||||
max_resident_requests=4,
|
||||
components=(spec,),
|
||||
)
|
||||
return pool, AscendMLABackend(config, spec, kernel_page_size=128)
|
||||
|
||||
@@ -191,6 +191,7 @@ class _RuntimeMixedAttention:
|
||||
kv_cache_quant_method="none",
|
||||
context_len=1024,
|
||||
max_bs=3,
|
||||
max_resident_requests=3,
|
||||
speculative_num_draft_tokens=width,
|
||||
is_draft=False,
|
||||
draft_block_decode=False,
|
||||
|
||||
@@ -59,6 +59,7 @@ def scheduler_forward_op():
|
||||
cfg.num_snapshot_pages = 1
|
||||
cfg.max_scheduled_tokens = 64
|
||||
cfg.max_batch_size = 8
|
||||
cfg.max_resident_requests = 8
|
||||
cfg.enable_l3_storage = False
|
||||
cfg.disable_l2_cache = True
|
||||
cfg.disable_prefix_cache = True
|
||||
@@ -632,6 +633,7 @@ def _scheduler_bridge_config(ts, *, max_scheduled_tokens: int, num_usable_pages:
|
||||
cfg.enable_l3_storage = False
|
||||
cfg.max_scheduled_tokens = max_scheduled_tokens
|
||||
cfg.max_batch_size = 8
|
||||
cfg.max_resident_requests = 8
|
||||
cfg.num_snapshot_pages = cfg.num_device_pages
|
||||
cfg.max_retracted_requests = cfg.max_batch_size
|
||||
cfg.prefix_granularity = PAGE
|
||||
|
||||
@@ -72,6 +72,7 @@ def mha_recipe(
|
||||
kernel_page_size=64,
|
||||
context_len=1024,
|
||||
max_bs=1,
|
||||
max_resident_requests=1,
|
||||
components=(
|
||||
MHAConfig(
|
||||
backend_name="fa2",
|
||||
@@ -184,6 +185,7 @@ def test_qcp_reserves_one_shared_workspace_before_sizing(qcp, draft):
|
||||
kernel_page_size=64,
|
||||
context_len=65536,
|
||||
max_bs=1,
|
||||
max_resident_requests=1,
|
||||
kvp_size=8,
|
||||
qcp_size=qcp,
|
||||
components=(
|
||||
|
||||
@@ -185,7 +185,7 @@ def _model_wide_kwargs(**overrides) -> dict:
|
||||
max_bs=2,
|
||||
)
|
||||
kwargs.update(overrides)
|
||||
return kwargs
|
||||
return {"max_resident_requests": kwargs["max_bs"], **kwargs}
|
||||
|
||||
|
||||
def _mha_config() -> AttnConfig:
|
||||
@@ -204,8 +204,9 @@ def _mha_config() -> AttnConfig:
|
||||
"is_draft,width,num_layers,layerwise,ring_rows",
|
||||
[(False, 1, 3, True, 4), (True, 4, 1, False, 7)],
|
||||
)
|
||||
@pytest.mark.parametrize("resident_requests", [2, 5])
|
||||
def test_inkling_construction_matches_ring_reservation(
|
||||
is_draft, width, num_layers, layerwise, ring_rows
|
||||
is_draft, width, num_layers, layerwise, ring_rows, resident_requests
|
||||
):
|
||||
from tokenspeed.runtime.layers.attention.backends.specific.inkling import (
|
||||
InklingAttnBackend,
|
||||
@@ -225,6 +226,7 @@ def test_inkling_construction_matches_ring_reservation(
|
||||
config,
|
||||
components=(spec,),
|
||||
is_draft=is_draft,
|
||||
max_resident_requests=resident_requests,
|
||||
speculative_num_draft_tokens=width,
|
||||
)
|
||||
text = SimpleNamespace(
|
||||
@@ -242,7 +244,12 @@ def test_inkling_construction_matches_ring_reservation(
|
||||
is_draft=is_draft,
|
||||
enable_layerwise_cache_ready=layerwise,
|
||||
)
|
||||
assert backend.conv_pool.conv_state.shape == (num_layers, 4, ring_rows, 24)
|
||||
assert backend.conv_pool.conv_state.shape == (
|
||||
num_layers,
|
||||
resident_requests + 2,
|
||||
ring_rows,
|
||||
24,
|
||||
)
|
||||
assert backend.conv_spec_num_tokens == width
|
||||
assert backend.enable_layerwise_cache_ready is layerwise
|
||||
assert backend.fixed_workspace_bytes() == _conv_ring_bytes(
|
||||
@@ -2019,6 +2026,7 @@ def test_every_boot_leaves_the_receive_pool_out_of_the_cache_budget(
|
||||
overlap_schedule_depth=0,
|
||||
decode_input_tokens=1,
|
||||
max_batch_size=8,
|
||||
max_resident_requests=8,
|
||||
kv_transfer_builder=functools.partial(build_host_peer, outbox=None),
|
||||
)
|
||||
budget, rows = sized.value.args
|
||||
|
||||
@@ -26,6 +26,7 @@ def _scheduler(*, mixed: bool = False):
|
||||
cfg.num_snapshot_pages = 1
|
||||
cfg.max_scheduled_tokens = 64
|
||||
cfg.max_batch_size = 8
|
||||
cfg.max_resident_requests = 8
|
||||
cfg.enable_l3_storage = False
|
||||
cfg.disable_l2_cache = True
|
||||
cfg.disable_prefix_cache = True
|
||||
|
||||
@@ -275,6 +275,7 @@ class TestFinishTailHitCopyCudaTest:
|
||||
num_device_pages=page_count,
|
||||
max_scheduled_tokens=256,
|
||||
max_batch_size=4,
|
||||
max_resident_requests=4,
|
||||
prefix_granularity=self.PAGE,
|
||||
num_host_pages=0,
|
||||
disable_l2_cache=True,
|
||||
@@ -493,6 +494,7 @@ class TestWriteBackOfPagesThePlanReusesCudaTest:
|
||||
).num_device_pages,
|
||||
max_scheduled_tokens=256,
|
||||
max_batch_size=4,
|
||||
max_resident_requests=4,
|
||||
prefix_granularity=self.PAGE,
|
||||
num_host_pages=executor.num_host_pages,
|
||||
disable_l2_cache=False,
|
||||
|
||||
@@ -480,6 +480,7 @@ def _startup_charge(monkeypatch, *, init_keeps, tune_keeps, enforce_eager, is_nv
|
||||
overlap_schedule_depth=0,
|
||||
decode_input_tokens=1,
|
||||
max_batch_size=8,
|
||||
max_resident_requests=8,
|
||||
kv_transfer_builder=functools.partial(build_host_peer, outbox=None),
|
||||
)
|
||||
return charged, set(reads), stack[0]
|
||||
|
||||
@@ -57,6 +57,7 @@ def make_leaf(monkeypatch):
|
||||
kv_cache_quant_method="",
|
||||
context_len=context,
|
||||
max_bs=8,
|
||||
max_resident_requests=8,
|
||||
speculative_num_draft_tokens=queries,
|
||||
is_draft=draft,
|
||||
draft_block_decode=block,
|
||||
|
||||
@@ -60,6 +60,7 @@ def _leaf(dtype, cache_dtype, device):
|
||||
kv_cache_quant_method="",
|
||||
context_len=1024,
|
||||
max_bs=4,
|
||||
max_resident_requests=4,
|
||||
components=(spec,),
|
||||
)
|
||||
return CuteDSLMLABackend(config, spec, kernel_page_size=64)
|
||||
|
||||
@@ -0,0 +1,327 @@
|
||||
# Copyright (c) 2026 LightSeek Foundation
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
"""Resident slots can outnumber the requests in a decode forward."""
|
||||
|
||||
from dataclasses import replace
|
||||
from test.ci_system.ci_register import register_cuda_ci
|
||||
from test.runtime.conftest import kimi_recipe
|
||||
|
||||
import pytest
|
||||
import torch
|
||||
from transformers import LlamaConfig
|
||||
|
||||
register_cuda_ci(est_time=15, suite="runtime-1gpu")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("dp,extra,want", [(1, 0, 8), (1, 4, 12), (2, 3, 7)])
|
||||
def test_cli_extra_slots_preserve_execution_capacity(tmp_path, dp, extra, want):
|
||||
from tokenspeed.runtime.engine.rank_setup import load_model_config
|
||||
from tokenspeed.runtime.layers.attention.configs.base import model_wide_kwargs
|
||||
from tokenspeed.runtime.utils.server_args import prepare_server_args
|
||||
|
||||
LlamaConfig(
|
||||
architectures=["LlamaForCausalLM"],
|
||||
hidden_size=64,
|
||||
intermediate_size=128,
|
||||
num_attention_heads=4,
|
||||
num_key_value_heads=4,
|
||||
num_hidden_layers=1,
|
||||
vocab_size=128,
|
||||
max_position_embeddings=256,
|
||||
).save_pretrained(tmp_path)
|
||||
args = prepare_server_args(
|
||||
[
|
||||
"--model",
|
||||
str(tmp_path),
|
||||
"--max-num-seqs",
|
||||
"8",
|
||||
"--tensor-parallel-size",
|
||||
str(dp),
|
||||
"--data-parallel-size",
|
||||
str(dp),
|
||||
"--disaggregation-mode",
|
||||
"decode",
|
||||
"--disaggregation-decode-extra-slots",
|
||||
str(extra),
|
||||
]
|
||||
)
|
||||
args.mapping.rank = 0
|
||||
model_config = load_model_config(args, args.model, draft_of=None)
|
||||
config = model_wide_kwargs(args, model_config, False, kv_cache_dtype=torch.bfloat16)
|
||||
assert config["max_bs"] == 8 // dp
|
||||
assert config["max_resident_requests"] == want
|
||||
|
||||
|
||||
@pytest.mark.parametrize("role", ["null", "prefill", "encode"])
|
||||
def test_positive_extra_slots_require_decode_role(role):
|
||||
from tokenspeed.runtime.utils.server_args import ServerArgs
|
||||
|
||||
with pytest.raises(ValueError, match="extra-slots"):
|
||||
ServerArgs(
|
||||
model="x", disaggregation_mode=role, disaggregation_decode_extra_slots=1
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("extra", [-1, True, 1.5])
|
||||
def test_extra_slots_reject_invalid_capacity(extra):
|
||||
from tokenspeed.runtime.utils.server_args import ServerArgs
|
||||
|
||||
with pytest.raises(ValueError, match="extra-slots"):
|
||||
ServerArgs(
|
||||
model="x",
|
||||
max_num_seqs=8,
|
||||
disaggregation_mode="decode",
|
||||
disaggregation_decode_extra_slots=extra,
|
||||
)
|
||||
|
||||
|
||||
def test_recipe_prices_residents_without_growing_execution_workspace():
|
||||
small = kimi_recipe(max_bs=2)
|
||||
expanded = kimi_recipe(max_bs=2)
|
||||
expanded.server_args.disaggregation_mode = "decode"
|
||||
expanded.attn_config = replace(
|
||||
expanded.attn_config,
|
||||
max_resident_requests=5,
|
||||
pd_disaggregation_enabled=True,
|
||||
)
|
||||
assert expanded.workspace_bytes() == small.workspace_bytes()
|
||||
groups = expanded.groups()
|
||||
from tokenspeed.runtime.layers.attention.kv_cache.recipes.scheduler_bridge import (
|
||||
capacity_model,
|
||||
)
|
||||
|
||||
model = capacity_model(
|
||||
tuple(spec for spec, _ in groups),
|
||||
prefix_granularity=expanded.prefix_granularity,
|
||||
virtual_packing=expanded.packing(groups),
|
||||
limits=expanded.scheduler_limits,
|
||||
)
|
||||
pages = model.concurrent_group_pages(max_total_tokens=512, max_context_len=4096)
|
||||
assert [
|
||||
pages[index]
|
||||
for index, (group, _) in enumerate(groups)
|
||||
if group.attn_kind == "state"
|
||||
] == [10, 10, 10]
|
||||
|
||||
|
||||
def test_probe_keeps_fabricated_batch_small_with_extra_residents():
|
||||
def arena_bytes(residents):
|
||||
recipe = kimi_recipe(max_bs=2)
|
||||
recipe.attn_config = replace(
|
||||
recipe.attn_config, max_resident_requests=residents
|
||||
)
|
||||
recipe.probe_batch_rows = 2
|
||||
recipe.cache_budget_bytes = 0
|
||||
return recipe.setup().spec.memory_plan.arena_bytes
|
||||
|
||||
assert arena_bytes(2) == arena_bytes(20)
|
||||
|
||||
|
||||
def test_glm_tail_reserves_rows_for_resident_slots():
|
||||
from test.runtime.test_glm53_flash_cache_spec import _recipe
|
||||
|
||||
recipe = _recipe(tp_size=8, mla_cache_dtype=torch.bfloat16)
|
||||
recipe.attn_config = replace(recipe.attn_config, max_bs=2, max_resident_requests=5)
|
||||
options = recipe.pool_options()
|
||||
assert options.num_request_slots == 7
|
||||
# 11 DSA layers, KPool=4, one overlap tail, 128 BF16 channels,
|
||||
# two generations, seven rows (null and padding included).
|
||||
assert options.workspace_bytes == 11 * 2 * 7 * options.tail_width * 128 * 2
|
||||
|
||||
|
||||
@pytest.mark.parametrize("probe_rows", [None, 2])
|
||||
def test_offload_prices_every_resident_partition(tmp_path, probe_rows):
|
||||
from test.runtime.test_cache_setup import _mla_config
|
||||
|
||||
from tokenspeed.runtime.engine.rank_setup import load_model_config
|
||||
from tokenspeed.runtime.layers.attention.kv_cache.offload_config import (
|
||||
KVOffloadPolicy,
|
||||
)
|
||||
from tokenspeed.runtime.layers.attention.kv_cache.recipes.ordinary import (
|
||||
OrdinaryRecipe,
|
||||
)
|
||||
from tokenspeed.runtime.utils.server_args import ServerArgs
|
||||
|
||||
class OffloadRecipe(OrdinaryRecipe):
|
||||
def offload_policy(self):
|
||||
return KVOffloadPolicy(
|
||||
field_ids=("layer.0.latent_kv",),
|
||||
hot_tokens=64,
|
||||
reserved_tokens=4,
|
||||
topk=16,
|
||||
queries=1,
|
||||
host_budget_bytes=1 << 20,
|
||||
overlap=True,
|
||||
cyclic_tokens=0,
|
||||
selection_consumers=(),
|
||||
)
|
||||
|
||||
LlamaConfig(
|
||||
architectures=["LlamaForCausalLM"],
|
||||
hidden_size=64,
|
||||
intermediate_size=128,
|
||||
num_attention_heads=4,
|
||||
num_key_value_heads=4,
|
||||
num_hidden_layers=1,
|
||||
vocab_size=128,
|
||||
max_position_embeddings=256,
|
||||
).save_pretrained(tmp_path)
|
||||
args = ServerArgs(
|
||||
model=str(tmp_path),
|
||||
max_num_seqs=2,
|
||||
device="cpu",
|
||||
disaggregation_mode="decode",
|
||||
disaggregation_decode_extra_slots=3,
|
||||
chunked_prefill_size=128,
|
||||
)
|
||||
recipe = OffloadRecipe(
|
||||
family="mla",
|
||||
server_args=args,
|
||||
model_config=load_model_config(args, args.model, draft_of=None),
|
||||
attn_config=replace(
|
||||
_mla_config(),
|
||||
max_resident_requests=5,
|
||||
pd_disaggregation_enabled=True,
|
||||
),
|
||||
draft_model_config=None,
|
||||
draft_attn_config=None,
|
||||
cache_budget_bytes=1 << 28,
|
||||
probe_batch_rows=probe_rows,
|
||||
decode_input_tokens=1,
|
||||
overlap_schedule_depth=0,
|
||||
)
|
||||
storage = recipe.setup().spec.storage_plan
|
||||
assert storage.offload.request_slots == 7
|
||||
# Hot and receive/verify reserve partitions are per resident slot. Probe
|
||||
# builds retain them because the same backend persists into serving.
|
||||
assert storage.offload.hot_rows == 476
|
||||
# The MLA field has 64 rows per page; its physical workspace rounds the
|
||||
# seven 68-row request partitions up to eight complete pages.
|
||||
assert storage.offload.device_rows == 512
|
||||
|
||||
|
||||
@pytest.mark.parametrize("device", ["cpu", "cuda"])
|
||||
def test_high_slot_bootstrap_and_reset_preserve_padding(device):
|
||||
if device == "cuda" and not torch.cuda.is_available():
|
||||
pytest.skip("requires CUDA")
|
||||
|
||||
from tokenspeed.runtime.execution.request_slots import RequestSlotLayout
|
||||
from tokenspeed.runtime.execution.runtime_states import RuntimeStates
|
||||
|
||||
layout = RequestSlotLayout(5)
|
||||
states = RuntimeStates(layout.padding, 32, 32, 3, device)
|
||||
states.init_draft_trees(3)
|
||||
states.init_draft_probs(spec_num_tokens=3, reject_threshold=2.0)
|
||||
states.valid_cache_lengths.fill_(17)
|
||||
states.future_input_map.fill_(9)
|
||||
states.spec_candidates_ready.fill_(True)
|
||||
states.reset_states(
|
||||
torch.tensor([5], device=device),
|
||||
torch.tensor([100], dtype=torch.int32, device=device),
|
||||
)
|
||||
assert states.valid_cache_lengths.tolist() == [17, 17, 17, 17, 17, 100, 17]
|
||||
assert states.spec_candidates_ready.tolist() == [
|
||||
True,
|
||||
True,
|
||||
True,
|
||||
True,
|
||||
True,
|
||||
False,
|
||||
True,
|
||||
]
|
||||
assert states.future_input_map[layout.padding].tolist() == [9, 9, 9]
|
||||
|
||||
# A B=2 forward may use either slot 4 or 5 when C=5. The real exporter
|
||||
# copies every persistent row through a Host image before slot reuse.
|
||||
expected = [row.clone() for row in states.slot_state_rows(5)]
|
||||
padding = [row.clone() for row in states.slot_state_rows(layout.padding)]
|
||||
image = torch.empty(
|
||||
states.slot_state_bytes(), dtype=torch.uint8, pin_memory=device == "cuda"
|
||||
)
|
||||
stream = torch.cuda.current_stream() if device == "cuda" else None
|
||||
states.export_slot_state(5, image, stream, request_id="high-slot")
|
||||
if stream is not None:
|
||||
stream.synchronize()
|
||||
for row in states.slot_state_rows(5):
|
||||
row.zero_()
|
||||
for row, saved in zip(states.slot_state_rows(4), expected, strict=True):
|
||||
row.copy_(saved.logical_not() if saved.dtype == torch.bool else saved + 1)
|
||||
states.import_slot_state(4, image, stream, request_id="high-slot")
|
||||
if stream is not None:
|
||||
stream.synchronize()
|
||||
assert all(
|
||||
torch.equal(row, saved)
|
||||
for row, saved in zip(states.slot_state_rows(4), expected, strict=True)
|
||||
)
|
||||
assert all(
|
||||
torch.equal(row, saved)
|
||||
for row, saved in zip(
|
||||
states.slot_state_rows(layout.padding), padding, strict=True
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.skipif(not torch.cuda.is_available(), reason="requires CUDA")
|
||||
def test_two_row_graph_replay_resets_high_resident_slots():
|
||||
from tokenspeed.runtime.execution.request_slots import RequestSlotLayout
|
||||
from tokenspeed.runtime.execution.runtime_states import RuntimeStates
|
||||
|
||||
layout = RequestSlotLayout(5)
|
||||
states = RuntimeStates(layout.padding, 32, 32, 3, "cuda")
|
||||
states.init_draft_probs(spec_num_tokens=3, reject_threshold=2.0)
|
||||
indices = torch.tensor([1, 2], dtype=torch.int64, device="cuda")
|
||||
lengths = torch.tensor([11, 12], dtype=torch.int32, device="cuda")
|
||||
graph = torch.cuda.CUDAGraph()
|
||||
stream = torch.cuda.Stream()
|
||||
stream.wait_stream(torch.cuda.current_stream())
|
||||
with torch.cuda.stream(stream):
|
||||
states.reset_states(indices, lengths)
|
||||
torch.cuda.current_stream().wait_stream(stream)
|
||||
with torch.cuda.graph(graph, stream=stream):
|
||||
states.reset_states(indices, lengths)
|
||||
|
||||
# The captured forward still has B=2 rows, but their real slots change
|
||||
# from 1,2 to 4,5. Neither old capture slots nor padding 6 may be reset.
|
||||
indices.copy_(torch.tensor([4, 5], dtype=torch.int64, device="cuda"))
|
||||
lengths.copy_(torch.tensor([104, 105], dtype=torch.int32, device="cuda"))
|
||||
states.valid_cache_lengths.fill_(17)
|
||||
states.spec_candidates_ready.fill_(True)
|
||||
states.stopped.fill_(True)
|
||||
states.draft_probs[:, :-1].fill_(0.25)
|
||||
graph.replay()
|
||||
|
||||
assert states.valid_cache_lengths.tolist() == [17, 17, 17, 17, 104, 105, 17]
|
||||
assert states.spec_candidates_ready.tolist() == [
|
||||
True,
|
||||
True,
|
||||
True,
|
||||
True,
|
||||
False,
|
||||
False,
|
||||
True,
|
||||
]
|
||||
assert states.stopped.tolist() == [True, True, True, True, False, False, True]
|
||||
assert torch.equal(states.draft_probs[4:6, :-1].cpu(), torch.full((2, 2, 32), 3.0))
|
||||
assert torch.equal(states.draft_probs[:4, :-1].cpu(), torch.full((4, 2, 32), 0.25))
|
||||
assert torch.equal(
|
||||
states.draft_probs[layout.padding, :-1].cpu(), torch.full((2, 32), 0.25)
|
||||
)
|
||||
assert torch.equal(states.draft_probs[:, -1].cpu(), torch.zeros((7, 32)))
|
||||
@@ -123,6 +123,7 @@ def _config(device):
|
||||
kernel_page_size=64,
|
||||
context_len=512,
|
||||
max_bs=2,
|
||||
max_resident_requests=2,
|
||||
pd_disaggregation_enabled=False,
|
||||
speculative_num_steps=0,
|
||||
speculative_num_draft_tokens=1,
|
||||
@@ -198,6 +199,7 @@ def _verify_backend(device, max_bs, verify_width):
|
||||
recipe.attn_config = replace(
|
||||
recipe.attn_config,
|
||||
max_bs=max_bs,
|
||||
max_resident_requests=max_bs,
|
||||
speculative_num_draft_tokens=verify_width,
|
||||
components=(
|
||||
replace(
|
||||
@@ -1092,6 +1094,7 @@ def test_workspace_reserves_full_paged_decode_scores(chunk, overlap_depth):
|
||||
config,
|
||||
context_len=context,
|
||||
max_bs=max_bs,
|
||||
max_resident_requests=max_bs,
|
||||
speculative_num_draft_tokens=verify_width,
|
||||
components=(replace(spec, max_query_tokens=max(chunk, max_bs * verify_width)),),
|
||||
)
|
||||
@@ -1108,7 +1111,9 @@ def test_workspace_reserves_full_paged_decode_scores(chunk, overlap_depth):
|
||||
def test_workspace_reserves_windowless_paged_prefill_scores():
|
||||
recipe = _recipe("cpu")
|
||||
context = 1 << 20
|
||||
config = replace(recipe.attn_config, context_len=context, max_bs=1)
|
||||
config = replace(
|
||||
recipe.attn_config, context_len=context, max_bs=1, max_resident_requests=1
|
||||
)
|
||||
spec = config.component(DeepseekV41Config)
|
||||
|
||||
def workspace(queries):
|
||||
|
||||
@@ -257,6 +257,7 @@ def test_dflash_rebound_stream_is_eagerly_warmed_before_final_capture(
|
||||
overlap_schedule_depth=0,
|
||||
decode_input_tokens=16,
|
||||
max_batch_size=16,
|
||||
max_resident_requests=16,
|
||||
kv_transfer_builder=functools.partial(build_host_peer, outbox=None),
|
||||
)
|
||||
# Once, before tuning and capture, only where the checkpoint declares the contract.
|
||||
@@ -437,6 +438,7 @@ def _profile_batch(mode):
|
||||
config.prefix_granularity = 16
|
||||
config.max_scheduled_tokens = 8
|
||||
config.max_batch_size = 4
|
||||
config.max_resident_requests = 4
|
||||
config.num_device_pages = 64
|
||||
config.num_snapshot_pages = 1
|
||||
config.enable_mixed_prefill_decode = True
|
||||
|
||||
@@ -85,6 +85,7 @@ def _recipe(*, draft_layers: int, pd: bool):
|
||||
kv_cache_quant_method="none",
|
||||
context_len=8192,
|
||||
max_bs=2,
|
||||
max_resident_requests=2,
|
||||
pd_disaggregation_enabled=pd,
|
||||
components=(dsa,),
|
||||
)
|
||||
@@ -392,6 +393,7 @@ def test_scheduler_reuses_both_history_groups():
|
||||
config.num_snapshot_pages = 1 # The null page alone; this test does not retract.
|
||||
config.max_scheduled_tokens = 1024
|
||||
config.max_batch_size = 2
|
||||
config.max_resident_requests = 2
|
||||
config.enable_l3_storage = False
|
||||
config.disable_l2_cache = True
|
||||
config.disable_prefix_cache = False
|
||||
@@ -493,7 +495,9 @@ def dots_runtime(monkeypatch):
|
||||
from tokenspeed.runtime.layers.attention.registry import create_paged_router
|
||||
|
||||
recipe = _recipe(draft_layers=0, pd=False)
|
||||
recipe.attn_config = replace(recipe.attn_config, device="cuda", max_bs=3)
|
||||
recipe.attn_config = replace(
|
||||
recipe.attn_config, device="cuda", max_bs=3, max_resident_requests=3
|
||||
)
|
||||
setup = recipe.setup()
|
||||
arena = CacheArena(
|
||||
_layout(recipe).bind(40),
|
||||
|
||||
@@ -51,6 +51,7 @@ def _cfg() -> AttnConfig:
|
||||
kernel_page_size=64,
|
||||
context_len=4096,
|
||||
max_bs=8,
|
||||
max_resident_requests=8,
|
||||
kv_cache_quant_method="none",
|
||||
speculative_num_steps=3,
|
||||
speculative_num_draft_tokens=4,
|
||||
@@ -289,6 +290,7 @@ def _msa_backend() -> MSAAttnBackend:
|
||||
kernel_page_size=64,
|
||||
context_len=4096,
|
||||
max_bs=8,
|
||||
max_resident_requests=8,
|
||||
kv_cache_quant_method="none",
|
||||
speculative_num_steps=3,
|
||||
speculative_num_draft_tokens=4,
|
||||
|
||||
@@ -83,6 +83,7 @@ def _config(monkeypatch, device, backend_name, **overrides):
|
||||
kv_cache_quant_method="none",
|
||||
context_len=4096,
|
||||
max_bs=4,
|
||||
max_resident_requests=4,
|
||||
kvp_size=8,
|
||||
kvp_rank=0,
|
||||
kvp_group=tuple(range(8)),
|
||||
|
||||
@@ -128,6 +128,7 @@ def _backend():
|
||||
kv_cache_quant_method="none",
|
||||
context_len=128,
|
||||
max_bs=2,
|
||||
max_resident_requests=2,
|
||||
components=(spec,),
|
||||
speculative_num_draft_tokens=2,
|
||||
)
|
||||
|
||||
@@ -851,6 +851,7 @@ def test_the_registry_allocates_the_workspace_once_and_the_draft_shares_it():
|
||||
kvp_group=tuple(range(WORLD)),
|
||||
context_len=max_model_len,
|
||||
max_bs=4,
|
||||
max_resident_requests=4,
|
||||
kv_cache_dtype=torch.bfloat16,
|
||||
kv_cache_quant_method="none",
|
||||
kernel_page_size=PAGE,
|
||||
|
||||
@@ -462,6 +462,7 @@ def _decode_batch(bs: int, width: int):
|
||||
num_device_pages=65,
|
||||
max_scheduled_tokens=bs * width,
|
||||
max_batch_size=bs,
|
||||
max_resident_requests=bs,
|
||||
prefix_granularity=4,
|
||||
num_host_pages=0,
|
||||
disable_l2_cache=True,
|
||||
|
||||
@@ -112,6 +112,7 @@ def buffers(request, monkeypatch):
|
||||
def _scheduler(*, token_budget: int, mixed: bool) -> Scheduler:
|
||||
config = SchedulerConfig()
|
||||
config.max_batch_size = PAD_POOL - 1
|
||||
config.max_resident_requests = PAD_POOL - 1
|
||||
config.max_scheduled_tokens = token_budget
|
||||
config.prefix_granularity = 4
|
||||
config.num_device_pages = 128
|
||||
|
||||
@@ -133,6 +133,7 @@ def _make_flashmla_backend(
|
||||
kernel_page_size=_KERNEL_PAGE,
|
||||
context_len=8 * pool.arena.prefix_granularity,
|
||||
max_bs=8,
|
||||
max_resident_requests=8,
|
||||
kv_cache_quant_method="",
|
||||
speculative_num_draft_tokens=speculative_num_draft_tokens,
|
||||
is_draft=is_draft,
|
||||
|
||||
@@ -76,6 +76,7 @@ def test_flashmla_prefill_plans_without_device_downloads(
|
||||
kernel_page_size=64,
|
||||
context_len=512,
|
||||
max_bs=4,
|
||||
max_resident_requests=4,
|
||||
kv_cache_quant_method="",
|
||||
components=(spec,),
|
||||
)
|
||||
|
||||
@@ -135,6 +135,7 @@ def _backend(state, *, width: int, max_bs: int, cls=GdnAttnBackend):
|
||||
kv_cache_quant_method="none",
|
||||
context_len=4096,
|
||||
max_bs=max_bs,
|
||||
max_resident_requests=max_bs,
|
||||
speculative_num_draft_tokens=width,
|
||||
components=(spec, linear),
|
||||
)
|
||||
|
||||
@@ -119,6 +119,7 @@ def _scheduler(ts, make_config, *, in_forward: bool):
|
||||
num_device_pages=65,
|
||||
max_scheduled_tokens=BUDGET,
|
||||
max_batch_size=4,
|
||||
max_resident_requests=4,
|
||||
prefix_granularity=PAGE,
|
||||
num_host_pages=0,
|
||||
disable_l2_cache=True,
|
||||
|
||||
@@ -100,6 +100,7 @@ def _mamba_config_pair(
|
||||
kv_cache_quant_method="none",
|
||||
context_len=4096,
|
||||
max_bs=max_bs,
|
||||
max_resident_requests=max_bs,
|
||||
speculative_num_draft_tokens=spec_tokens,
|
||||
components=(spec, linear),
|
||||
)
|
||||
|
||||
@@ -75,6 +75,7 @@ def _scheduler(ts, make_config):
|
||||
num_device_pages=65,
|
||||
max_scheduled_tokens=256,
|
||||
max_batch_size=4,
|
||||
max_resident_requests=4,
|
||||
prefix_granularity=PAGE,
|
||||
num_host_pages=0,
|
||||
disable_l2_cache=True,
|
||||
|
||||
@@ -92,6 +92,7 @@ def test_glm53_flash_pool_binds_paged_cache_and_request_local_tail() -> None:
|
||||
kv_cache_quant_method="none",
|
||||
context_len=4096,
|
||||
max_bs=8,
|
||||
max_resident_requests=8,
|
||||
components=(dsa, linear),
|
||||
)
|
||||
draft_attn_config = replace(
|
||||
|
||||
@@ -85,6 +85,7 @@ def _recipe(
|
||||
kv_cache_quant_method="none",
|
||||
context_len=4096,
|
||||
max_bs=16,
|
||||
max_resident_requests=16,
|
||||
pd_disaggregation_enabled=pd_disaggregation_enabled,
|
||||
speculative_num_steps=2 if draft_layers else 0,
|
||||
speculative_num_draft_tokens=3 if draft_layers else 1,
|
||||
|
||||
@@ -60,6 +60,7 @@ class TestRouterOverMhaLeavesTest:
|
||||
kv_cache_mxfp8=False,
|
||||
draft_block_decode=False,
|
||||
max_bs=8,
|
||||
max_resident_requests=8,
|
||||
kernel_page_size=None,
|
||||
)
|
||||
spec = SimpleNamespace(
|
||||
|
||||
@@ -207,6 +207,7 @@ class _Harness:
|
||||
kernel_page_size=PAGE_SIZE,
|
||||
context_len=1024,
|
||||
max_bs=4,
|
||||
max_resident_requests=4,
|
||||
kv_cache_quant_method="none",
|
||||
components=(spec,),
|
||||
)
|
||||
|
||||
@@ -88,6 +88,7 @@ def _setup(tp: int, kv_cache_dtype: torch.dtype, mxfp8: bool, budget_bytes: int)
|
||||
kernel_page_size=64,
|
||||
context_len=4096,
|
||||
max_bs=4,
|
||||
max_resident_requests=4,
|
||||
)
|
||||
recipe = cache_recipe(
|
||||
"inkling",
|
||||
|
||||
@@ -175,6 +175,7 @@ class _ScheduledKDA:
|
||||
config.max_retracted_requests = 0
|
||||
config.max_scheduled_tokens = _P
|
||||
config.max_batch_size = 1
|
||||
config.max_resident_requests = 1
|
||||
config.decode_input_tokens = 1
|
||||
config.overlap_schedule_depth = 0
|
||||
config.enable_mixed_prefill_decode = False
|
||||
|
||||
@@ -252,6 +252,7 @@ def _scheduler(pool, *, width: int, overlap_schedule_depth: int):
|
||||
config.max_retracted_requests = 0
|
||||
config.max_scheduled_tokens = 8
|
||||
config.max_batch_size = 1
|
||||
config.max_resident_requests = 1
|
||||
config.decode_input_tokens = width
|
||||
config.overlap_schedule_depth = overlap_schedule_depth
|
||||
config.enable_mixed_prefill_decode = False
|
||||
|
||||
@@ -1889,6 +1889,7 @@ def _dsa_leaf(pool, *, q_len: int, heads: int, padded_prefill_replay: bool = Fal
|
||||
kernel_page_size=None,
|
||||
context_len=4096,
|
||||
max_bs=4,
|
||||
max_resident_requests=4,
|
||||
kv_cache_quant_method=None,
|
||||
speculative_num_draft_tokens=q_len,
|
||||
components=(spec,),
|
||||
@@ -2215,6 +2216,7 @@ def _k31_attention_stack(
|
||||
kv_cache_dtype=kv_cache_dtype,
|
||||
kv_cache_quant_method=None,
|
||||
max_bs=4,
|
||||
max_resident_requests=4,
|
||||
context_len=context_len,
|
||||
speculative_num_draft_tokens=spec_width,
|
||||
kvp_size=kvp_size,
|
||||
|
||||
@@ -163,6 +163,7 @@ def test_kimi_k3_bf16_draft_uses_typed_view_over_fp8_target_arena() -> None:
|
||||
dtype=torch.bfloat16,
|
||||
context_len=1024,
|
||||
max_bs=1,
|
||||
max_resident_requests=1,
|
||||
kv_cache_quant_method="none",
|
||||
components=(mla_spec,),
|
||||
)
|
||||
|
||||
@@ -160,6 +160,7 @@ def _backend_config(device: str, *, spec_tokens: int = 1):
|
||||
kv_cache_quant_method="none",
|
||||
context_len=4096,
|
||||
max_bs=8,
|
||||
max_resident_requests=8,
|
||||
is_draft=False,
|
||||
speculative_num_draft_tokens=spec_tokens,
|
||||
components=(spec,),
|
||||
|
||||
@@ -86,6 +86,7 @@ class _Harness:
|
||||
is_draft=False,
|
||||
speculative_num_draft_tokens=draft_tokens,
|
||||
max_bs=max_bs,
|
||||
max_resident_requests=max_bs,
|
||||
components=(spec,),
|
||||
)
|
||||
self.config = config
|
||||
@@ -750,7 +751,7 @@ def test_replay_planning_matches_allocation_and_rejects_drift():
|
||||
)
|
||||
assert planned_bytes == allocated_bytes
|
||||
server_args = SimpleNamespace(speculative_num_draft_tokens=T)
|
||||
config = SimpleNamespace(max_bs=8, qcp_size=1)
|
||||
config = SimpleNamespace(max_bs=8, max_resident_requests=8, qcp_size=1)
|
||||
backend = HybridLinearAttnBackend(
|
||||
AttentionBackend(harness.config, harness.config.components[0]),
|
||||
harness.backend,
|
||||
|
||||
@@ -325,6 +325,7 @@ def backend_factory(cuda_env, gpu_pool, cache_dtype):
|
||||
kernel_page_size=_KERNEL_PAGE,
|
||||
context_len=4 * gpu_pool.arena.prefix_granularity,
|
||||
max_bs=8,
|
||||
max_resident_requests=8,
|
||||
kv_cache_quant_method="",
|
||||
speculative_num_draft_tokens=q_len,
|
||||
components=(spec,),
|
||||
|
||||
@@ -279,6 +279,7 @@ class TestConfigurationTest:
|
||||
kernel_page_size=64,
|
||||
context_len=4096,
|
||||
max_bs=4,
|
||||
max_resident_requests=4,
|
||||
kvp_size=2,
|
||||
kvp_rank=0,
|
||||
kvp_group=(0, 1),
|
||||
|
||||
@@ -106,6 +106,7 @@ def host_cache(request, io_backend):
|
||||
kv_cache_quant_method="none",
|
||||
context_len=4096,
|
||||
max_bs=2,
|
||||
max_resident_requests=2,
|
||||
)
|
||||
recipe_args = dict(
|
||||
server_args=SimpleNamespace(
|
||||
|
||||
@@ -65,6 +65,7 @@ def test_mha_preserves_target_and_block_draft_geometry(draft, heads, name, solut
|
||||
kv_cache_quant_method="none",
|
||||
context_len=50176,
|
||||
max_bs=16,
|
||||
max_resident_requests=16,
|
||||
speculative_num_draft_tokens=16,
|
||||
is_draft=draft,
|
||||
draft_block_decode=draft,
|
||||
|
||||
@@ -76,6 +76,7 @@ def _backend(kv_cache_dtype, *, draft_block_decode=False):
|
||||
kv_cache_quant_method="none",
|
||||
context_len=256,
|
||||
max_bs=4,
|
||||
max_resident_requests=4,
|
||||
speculative_num_draft_tokens=1,
|
||||
is_draft=False,
|
||||
draft_block_decode=draft_block_decode,
|
||||
|
||||
@@ -99,6 +99,7 @@ class _Step:
|
||||
kv_cache_quant_method="none",
|
||||
context_len=CONTEXT,
|
||||
max_bs=MAX_BS,
|
||||
max_resident_requests=MAX_BS,
|
||||
speculative_num_draft_tokens=width,
|
||||
is_draft=is_draft,
|
||||
draft_block_decode=False,
|
||||
|
||||
@@ -72,6 +72,7 @@ def _backend(
|
||||
kv_cache_quant_method="none",
|
||||
context_len=1024,
|
||||
max_bs=16,
|
||||
max_resident_requests=16,
|
||||
speculative_num_draft_tokens=width,
|
||||
is_draft=is_draft,
|
||||
draft_block_decode=block_decode,
|
||||
|
||||
@@ -57,6 +57,7 @@ def _backend(kv_cache_dtype: torch.dtype) -> MHAAttnBackend:
|
||||
kv_cache_quant_method="none",
|
||||
context_len=256,
|
||||
max_bs=4,
|
||||
max_resident_requests=4,
|
||||
speculative_num_draft_tokens=1,
|
||||
is_draft=False,
|
||||
draft_block_decode=False,
|
||||
|
||||
@@ -82,6 +82,7 @@ def test_fresh_prefill_warmup_also_runs_the_cached_extend(monkeypatch, window):
|
||||
kv_cache_quant_method="none",
|
||||
context_len=256,
|
||||
max_bs=4,
|
||||
max_resident_requests=4,
|
||||
speculative_num_draft_tokens=1,
|
||||
is_draft=False,
|
||||
draft_block_decode=False,
|
||||
|
||||
@@ -130,6 +130,7 @@ def _backend():
|
||||
kv_cache_quant_method="none",
|
||||
context_len=1024,
|
||||
max_bs=2,
|
||||
max_resident_requests=2,
|
||||
components=(spec,),
|
||||
)
|
||||
return MLAAttnBackend(config, spec, kernel_page_size=64)
|
||||
|
||||
@@ -100,7 +100,8 @@ def _pages(specs, **kw):
|
||||
virtual_packing={spec.group_id: 1 for spec in specs},
|
||||
limits=SchedulerLimits(
|
||||
role=ts.SchedulerConfig.Role.Fused,
|
||||
max_live_requests=defaults["max_live_requests"],
|
||||
max_batch_size=defaults["max_live_requests"],
|
||||
max_resident_requests=defaults["max_live_requests"],
|
||||
max_scheduled_tokens=defaults["max_scheduled_tokens"],
|
||||
max_context_len=defaults["max_context_len"],
|
||||
decode_input_tokens=1,
|
||||
@@ -130,6 +131,41 @@ class TestMultiWindowPageCountsTest:
|
||||
each, so a window of one charges neither).
|
||||
"""
|
||||
|
||||
def test_decode_extra_residents_each_hold_two_state_slots(self):
|
||||
specs = (
|
||||
CacheGroupSpec(
|
||||
group_id="history",
|
||||
attn_kind="full_history",
|
||||
rows_per_page=PAGE,
|
||||
entry_stride_tokens=1,
|
||||
replayable=False,
|
||||
transfer_policy="full_suffix",
|
||||
),
|
||||
CacheGroupSpec(
|
||||
group_id="state",
|
||||
attn_kind="state",
|
||||
replayable=False,
|
||||
transfer_policy="latest_snapshot",
|
||||
),
|
||||
)
|
||||
model = capacity_model(
|
||||
specs,
|
||||
prefix_granularity=PAGE,
|
||||
virtual_packing={"history": 1, "state": 1},
|
||||
limits=SchedulerLimits(
|
||||
role=ts.SchedulerConfig.Role.D,
|
||||
max_batch_size=2,
|
||||
max_resident_requests=5,
|
||||
max_scheduled_tokens=128,
|
||||
max_context_len=4096,
|
||||
decode_input_tokens=1,
|
||||
overlap_schedule_depth=0,
|
||||
disable_prefix_cache=False,
|
||||
),
|
||||
)
|
||||
pages = model.concurrent_group_pages(max_total_tokens=512, max_context_len=4096)
|
||||
assert pages[1] == 10
|
||||
|
||||
def test_each_window_budgets_independently(self):
|
||||
pages = _pages(
|
||||
[
|
||||
|
||||
@@ -315,6 +315,7 @@ def _make_config(kernel_page_size: int | None):
|
||||
kernel_page_size=kernel_page_size,
|
||||
context_len=4096,
|
||||
max_bs=8,
|
||||
max_resident_requests=8,
|
||||
kv_cache_quant_method="none",
|
||||
components=(spec,),
|
||||
)
|
||||
|
||||
@@ -279,6 +279,7 @@ def _backend(
|
||||
kv_cache_quant_method="none",
|
||||
context_len=4096,
|
||||
max_bs=8,
|
||||
max_resident_requests=8,
|
||||
is_draft=False,
|
||||
speculative_num_draft_tokens=verify_width,
|
||||
components=(spec, mamba2),
|
||||
@@ -459,6 +460,7 @@ def _super_attn_config(tp: int, kv_dtype: torch.dtype, *, is_draft: bool, device
|
||||
kernel_page_size=64,
|
||||
context_len=16384,
|
||||
max_bs=2,
|
||||
max_resident_requests=2,
|
||||
is_draft=is_draft,
|
||||
)
|
||||
|
||||
|
||||
@@ -195,6 +195,7 @@ def test_remote_pd_landing_holds_the_only_hot_request_partition():
|
||||
cfg.prefix_granularity = 64
|
||||
cfg.num_device_pages = 129
|
||||
cfg.max_batch_size = 1 # The configured B is also the fixed hot partition count.
|
||||
cfg.max_resident_requests = 1
|
||||
cfg.max_scheduled_tokens = 64
|
||||
cfg.decode_input_tokens = 1
|
||||
cfg.disable_l2_cache = True
|
||||
@@ -221,17 +222,28 @@ def test_remote_pd_landing_holds_the_only_hot_request_partition():
|
||||
scheduler.advance(
|
||||
ts.ExecutionEvent().add_event(ts.PD.RemotePrefillDoneEvent("first", 100))
|
||||
)
|
||||
scheduler.next_execution_plan()
|
||||
decode = scheduler.next_execution_plan()
|
||||
assert list(decode.forward[0].request_ids) == ["first"]
|
||||
event = ts.ForwardEvent.Abort()
|
||||
event.request_id = "first"
|
||||
scheduler.advance(ts.ExecutionEvent().add_event(event))
|
||||
for _ in range(4):
|
||||
plan = scheduler.next_execution_plan()
|
||||
if plan.remote_prefill is not None:
|
||||
assert list(plan.remote_prefill.request_ids) == ["second"]
|
||||
break
|
||||
else:
|
||||
pytest.fail("released hot partition was not readmitted")
|
||||
assert plan.remote_prefill is None
|
||||
assert scheduler.allocated_request_slots() == 1
|
||||
assert scheduler.active_decode_slots() == 1
|
||||
|
||||
# Cancellation does not retire a forward that can still write this row.
|
||||
result = ts.ForwardEvent.ExtendResult()
|
||||
result.request_id, result.tokens = "first", [101]
|
||||
scheduler.advance(ts.ExecutionEvent().add_event(result))
|
||||
assert scheduler.allocated_request_slots() == 0
|
||||
assert scheduler.active_decode_slots() == 0
|
||||
admitted = scheduler.next_execution_plan()
|
||||
assert list(admitted.remote_prefill.request_ids) == ["second"]
|
||||
assert list(admitted.remote_prefill.request_pool_indices) == list(
|
||||
first.remote_prefill.request_pool_indices
|
||||
)
|
||||
|
||||
|
||||
def test_decode_capacity_abort_releases_the_request_partition_without_recovery():
|
||||
@@ -242,6 +254,7 @@ def test_decode_capacity_abort_releases_the_request_partition_without_recovery()
|
||||
cfg.num_snapshot_pages = 1
|
||||
cfg.max_retracted_requests = 0
|
||||
cfg.max_batch_size = 2
|
||||
cfg.max_resident_requests = 2
|
||||
cfg.max_scheduled_tokens = 256
|
||||
cfg.decode_input_tokens = 1
|
||||
cfg.disable_l2_cache = True
|
||||
|
||||
@@ -26,6 +26,7 @@ def _make_config(*, prefix_replay_tokens: int | None = None):
|
||||
num_device_pages=32,
|
||||
max_scheduled_tokens=64,
|
||||
max_batch_size=8,
|
||||
max_resident_requests=8,
|
||||
prefix_granularity=2,
|
||||
num_host_pages=0,
|
||||
disable_l2_cache=True,
|
||||
@@ -144,6 +145,7 @@ def test_make_config_preserves_explicit_l3_storage(enable_l3_storage: bool) -> N
|
||||
num_device_pages=32,
|
||||
max_scheduled_tokens=64,
|
||||
max_batch_size=8,
|
||||
max_resident_requests=8,
|
||||
prefix_granularity=2,
|
||||
num_host_pages=8,
|
||||
disable_l2_cache=False,
|
||||
|
||||
@@ -111,6 +111,7 @@ def _qsa_config(*, max_bs: int, is_draft: bool, device: str) -> AttnConfig:
|
||||
kernel_page_size=64,
|
||||
context_len=1024,
|
||||
max_bs=max_bs,
|
||||
max_resident_requests=max_bs,
|
||||
pd_disaggregation_enabled=False,
|
||||
speculative_num_steps=0,
|
||||
speculative_num_draft_tokens=4,
|
||||
|
||||
@@ -193,6 +193,7 @@ def _recipe(
|
||||
kernel_page_size=None,
|
||||
context_len=CONTEXT_LEN,
|
||||
max_bs=2,
|
||||
max_resident_requests=2,
|
||||
pd_disaggregation_enabled=role != "null",
|
||||
speculative_num_steps=2 if speculative else 0,
|
||||
speculative_num_draft_tokens=width,
|
||||
@@ -428,6 +429,7 @@ def _config(*, is_draft=False, kv_cache_dtype=FP8):
|
||||
kernel_page_size=None,
|
||||
context_len=CONTEXT_LEN,
|
||||
max_bs=MAX_BS,
|
||||
max_resident_requests=MAX_BS,
|
||||
pd_disaggregation_enabled=False,
|
||||
speculative_num_steps=0,
|
||||
speculative_num_draft_tokens=1,
|
||||
@@ -532,7 +534,7 @@ def test_startup_checks_the_planned_bytes_against_the_allocation(kernels):
|
||||
plan = _plan()
|
||||
kwargs = dict(
|
||||
server_args=SimpleNamespace(speculative_num_draft_tokens=1),
|
||||
config=SimpleNamespace(max_bs=4, qcp_size=1),
|
||||
config=SimpleNamespace(max_bs=4, max_resident_requests=4, qcp_size=1),
|
||||
backend=root,
|
||||
draft_backend=None,
|
||||
uses_paged_state_verify=False,
|
||||
|
||||
@@ -63,6 +63,7 @@ def _config(*, is_draft: bool, width: int):
|
||||
speculative_num_draft_tokens=width,
|
||||
context_len=512,
|
||||
max_bs=4,
|
||||
max_resident_requests=4,
|
||||
qcp_size=1,
|
||||
)
|
||||
|
||||
@@ -181,6 +182,7 @@ def test_verify_workspace_counts_each_consumer_once_and_checks_zero_budget(
|
||||
|
||||
config = _config(is_draft=is_draft, width=width)
|
||||
config.max_bs = 2
|
||||
config.max_resident_requests = 2
|
||||
attention = AttentionBackend(config, config.component(SoftmaxAttnConfig))
|
||||
if has_gdn:
|
||||
attention = HybridLinearAttnBackend(attention, consumer("gdn", 3), [0])
|
||||
|
||||
@@ -552,6 +552,7 @@ def _qsa_config(*, kernel_page_size: int | None, max_bs: int, spec: int) -> Attn
|
||||
kernel_page_size=kernel_page_size,
|
||||
context_len=1024,
|
||||
max_bs=max_bs,
|
||||
max_resident_requests=max_bs,
|
||||
pd_disaggregation_enabled=False,
|
||||
speculative_num_steps=0,
|
||||
speculative_num_draft_tokens=spec,
|
||||
@@ -2320,6 +2321,7 @@ def test_qwen4_exp_cache_recipe_adds_ple_and_qsa_groups() -> None:
|
||||
kv_cache_mxfp8=False,
|
||||
context_len=1024,
|
||||
max_bs=2,
|
||||
max_resident_requests=2,
|
||||
kernel_page_size=64,
|
||||
kv_cache_quant_method="none",
|
||||
components=(softmax, linear),
|
||||
@@ -2410,7 +2412,8 @@ def test_qwen4_exp_cache_recipe_adds_ple_and_qsa_groups() -> None:
|
||||
},
|
||||
limits=SchedulerLimits(
|
||||
role=SchedulerConfig.Role.Fused,
|
||||
max_live_requests=2,
|
||||
max_batch_size=2,
|
||||
max_resident_requests=2,
|
||||
# A chunk must cover one PLE state checkpoint (256 tokens).
|
||||
max_scheduled_tokens=256,
|
||||
max_context_len=max_tokens,
|
||||
@@ -2486,6 +2489,7 @@ def _fp8_kv_qwen4_exp_cache_setup(*, with_ple: bool):
|
||||
kv_cache_mxfp8=False,
|
||||
context_len=1024,
|
||||
max_bs=2,
|
||||
max_resident_requests=2,
|
||||
kernel_page_size=64,
|
||||
kv_cache_quant_method="none",
|
||||
components=(softmax, linear),
|
||||
|
||||
@@ -93,6 +93,7 @@ def _recipe(
|
||||
kernel_page_size=64,
|
||||
context_len=1024,
|
||||
max_bs=2,
|
||||
max_resident_requests=2,
|
||||
pd_disaggregation_enabled=False,
|
||||
speculative_num_steps=2 if speculative else 0,
|
||||
speculative_num_draft_tokens=width,
|
||||
|
||||
@@ -143,6 +143,7 @@ def test_a_target_verify_without_gated_deltanet_keeps_the_regular_path() -> None
|
||||
kernel_page_size=64,
|
||||
context_len=1024,
|
||||
max_bs=2,
|
||||
max_resident_requests=2,
|
||||
pd_disaggregation_enabled=False,
|
||||
speculative_num_steps=3,
|
||||
speculative_num_draft_tokens=4,
|
||||
|
||||
@@ -92,6 +92,7 @@ def _config(args: ServerArgs, specs):
|
||||
storage_config=storage_config,
|
||||
max_scheduled_tokens=args.chunked_prefill_size,
|
||||
max_batch_size=args.retraction_snapshot_max_requests or 8,
|
||||
max_resident_requests=args.retraction_snapshot_max_requests or 8,
|
||||
decode_input_tokens=1,
|
||||
overlap_schedule_depth=0,
|
||||
enable_kv_cache_events=False,
|
||||
@@ -165,6 +166,7 @@ def test_make_config_requires_and_maps_the_host_write_policy():
|
||||
num_device_pages=32,
|
||||
max_scheduled_tokens=64,
|
||||
max_batch_size=8,
|
||||
max_resident_requests=8,
|
||||
prefix_granularity=2,
|
||||
num_host_pages=0,
|
||||
disable_l2_cache=True,
|
||||
@@ -979,6 +981,7 @@ def test_make_config_sets_the_prefill_chunk_yield_only_when_on():
|
||||
num_device_pages=32,
|
||||
max_scheduled_tokens=64,
|
||||
max_batch_size=8,
|
||||
max_resident_requests=8,
|
||||
prefix_granularity=2,
|
||||
num_host_pages=0,
|
||||
disable_l2_cache=True,
|
||||
|
||||
@@ -296,7 +296,8 @@ def _model(specs, packing):
|
||||
virtual_packing=packing,
|
||||
limits=SchedulerLimits(
|
||||
role=ts.SchedulerConfig.Role.Fused,
|
||||
max_live_requests=4,
|
||||
max_batch_size=4,
|
||||
max_resident_requests=4,
|
||||
max_scheduled_tokens=2048,
|
||||
max_context_len=4096,
|
||||
decode_input_tokens=1,
|
||||
@@ -388,6 +389,7 @@ def _device_request(**overrides):
|
||||
contract,
|
||||
host_group_packing=contract.virtual_packing,
|
||||
max_batch_size=4,
|
||||
max_resident_requests=4,
|
||||
max_context_len=4096,
|
||||
decode_input_tokens=1,
|
||||
overlap_schedule_depth=0,
|
||||
|
||||
@@ -215,6 +215,7 @@ def _scheduled_batch():
|
||||
num_device_pages=_PAGES,
|
||||
max_scheduled_tokens=64,
|
||||
max_batch_size=2,
|
||||
max_resident_requests=2,
|
||||
prefix_granularity=4,
|
||||
num_host_pages=0,
|
||||
disable_l2_cache=True,
|
||||
|
||||
@@ -457,6 +457,7 @@ def _scheduler() -> Scheduler:
|
||||
config.prefix_granularity = 16
|
||||
config.max_scheduled_tokens = 64
|
||||
config.max_batch_size = 4
|
||||
config.max_resident_requests = 4
|
||||
config.num_device_pages = 64
|
||||
config.num_snapshot_pages = 1
|
||||
config.cache_groups = [
|
||||
|
||||
@@ -198,6 +198,7 @@ def _config(**overrides):
|
||||
num_device_pages=32,
|
||||
max_scheduled_tokens=64,
|
||||
max_batch_size=8,
|
||||
max_resident_requests=8,
|
||||
prefix_granularity=2,
|
||||
num_host_pages=0,
|
||||
disable_l2_cache=True,
|
||||
|
||||
@@ -142,6 +142,7 @@ class TestAttentionBackendChoices:
|
||||
is_draft=False,
|
||||
speculative_num_draft_tokens=1,
|
||||
max_bs=4,
|
||||
max_resident_requests=4,
|
||||
component=components.get,
|
||||
)
|
||||
model_config = SimpleNamespace(
|
||||
@@ -257,6 +258,7 @@ class TestAttentionBackendChoices:
|
||||
context_len=65536,
|
||||
kernel_page_size=64,
|
||||
max_bs=8,
|
||||
max_resident_requests=8,
|
||||
components=(spec,),
|
||||
)
|
||||
|
||||
@@ -355,6 +357,7 @@ class TestAttentionBackendChoices:
|
||||
kernel_page_size=kernel_page_size,
|
||||
context_len=256,
|
||||
max_bs=2,
|
||||
max_resident_requests=2,
|
||||
kv_cache_quant_method="none",
|
||||
components=(spec,),
|
||||
)
|
||||
@@ -778,6 +781,7 @@ class TestPagedRouterNameResolution:
|
||||
kernel_page_size=64,
|
||||
context_len=256,
|
||||
max_bs=2,
|
||||
max_resident_requests=2,
|
||||
kv_cache_quant_method="none",
|
||||
components=(spec,),
|
||||
)
|
||||
|
||||
@@ -384,6 +384,7 @@ def _dsa_attn_config(**overrides):
|
||||
kernel_page_size=64,
|
||||
context_len=4096,
|
||||
max_bs=4,
|
||||
max_resident_requests=4,
|
||||
kvp_size=2,
|
||||
kvp_rank=0,
|
||||
kvp_group=(0, 1),
|
||||
|
||||
@@ -116,11 +116,12 @@ SAMPLING_BACKENDS = (
|
||||
# The per-slot buffers each sampling backend's rid-flip reset must write.
|
||||
SCATTERED_SLOT_STATE = {SonicSamplingBackend: ("state.temperature", "state.seeds")}
|
||||
|
||||
# One request-pool geometry for every owner: max_bs decode rows, one sink row
|
||||
# (max_req_pool_size = max_bs + 1) and the graph-padding row past it.
|
||||
MAX_BS = 9
|
||||
MAX_REQ_POOL_SIZE = MAX_BS + 1
|
||||
POOL_ROWS = MAX_REQ_POOL_SIZE + 1 # 11: RuntimeStates, drafters, Inkling (max_bs + 2)
|
||||
# Forward buffers are smaller than the resident slot domain. Round trips below
|
||||
# restore slots above MAX_BS, as a decode server with extra receive slots does.
|
||||
MAX_BS = 4
|
||||
MAX_RESIDENT_REQUESTS = 9
|
||||
MAX_REQ_POOL_SIZE = MAX_RESIDENT_REQUESTS + 1
|
||||
POOL_ROWS = MAX_REQ_POOL_SIZE + 1
|
||||
SPEC_TOKENS = 4
|
||||
VOCAB = 32
|
||||
HIDDEN = 8
|
||||
@@ -208,7 +209,7 @@ class _Leaf(AttentionBackend):
|
||||
def _inkling() -> InklingAttnBackend:
|
||||
conv_pool = InklingConvStatePool(
|
||||
num_layers=2,
|
||||
num_slots=MAX_BS + 2,
|
||||
num_slots=POOL_ROWS,
|
||||
conv_dim=HIDDEN,
|
||||
ring_size=5,
|
||||
dtype=torch.bfloat16,
|
||||
@@ -221,7 +222,7 @@ def _kpool_pool() -> HybridGlm53FlashTokenToKVPool:
|
||||
pool = HybridGlm53FlashTokenToKVPool.__new__(HybridGlm53FlashTokenToKVPool)
|
||||
pool._kpool_tail_workspace = _KPoolTailWorkspace(
|
||||
options=None,
|
||||
storage=torch.zeros((2, 2, MAX_BS + 2, 3, HIDDEN), dtype=torch.bfloat16),
|
||||
storage=torch.zeros((2, 2, POOL_ROWS, 3, HIDDEN), dtype=torch.bfloat16),
|
||||
row_by_layer={0: 0, 1: 1},
|
||||
)
|
||||
return pool
|
||||
|
||||
@@ -58,6 +58,7 @@ def _scheduler(*, token_budget: int, with_state: bool, disable_prefix_cache: boo
|
||||
num_device_pages=64,
|
||||
max_scheduled_tokens=token_budget,
|
||||
max_batch_size=1,
|
||||
max_resident_requests=1,
|
||||
prefix_granularity=128,
|
||||
num_host_pages=0,
|
||||
disable_l2_cache=True,
|
||||
|
||||
@@ -73,6 +73,7 @@ def _scheduler(*, with_state: bool = False) -> ts.Scheduler:
|
||||
num_device_pages=64 + 1,
|
||||
max_scheduled_tokens=256,
|
||||
max_batch_size=4,
|
||||
max_resident_requests=4,
|
||||
prefix_granularity=PAGE,
|
||||
num_host_pages=0,
|
||||
disable_l2_cache=True,
|
||||
|
||||
@@ -83,6 +83,7 @@ def _backend(
|
||||
kernel_page_size=PAGE,
|
||||
context_len=2048,
|
||||
max_bs=max_bs,
|
||||
max_resident_requests=max_bs,
|
||||
kv_cache_quant_method="none",
|
||||
speculative_num_steps=3,
|
||||
speculative_num_draft_tokens=num_draft_tokens,
|
||||
@@ -265,6 +266,7 @@ def _mla_backend(cls, num_draft_tokens, max_bs, is_draft, kv_dtype):
|
||||
kernel_page_size=PAGE,
|
||||
context_len=2048,
|
||||
max_bs=max_bs,
|
||||
max_resident_requests=max_bs,
|
||||
kv_cache_quant_method="none",
|
||||
speculative_num_steps=3,
|
||||
speculative_num_draft_tokens=num_draft_tokens,
|
||||
|
||||
@@ -69,6 +69,7 @@ def _backend(num_draft_tokens: int, max_bs: int, is_draft: bool, dim: int):
|
||||
kernel_page_size=PAGE,
|
||||
context_len=2048,
|
||||
max_bs=max_bs,
|
||||
max_resident_requests=max_bs,
|
||||
kv_cache_quant_method="none",
|
||||
speculative_num_steps=3,
|
||||
speculative_num_draft_tokens=num_draft_tokens,
|
||||
@@ -405,6 +406,7 @@ def test_tree_support_blocks_an_fp8_cache():
|
||||
kernel_page_size=PAGE,
|
||||
context_len=2048,
|
||||
max_bs=8,
|
||||
max_resident_requests=8,
|
||||
kv_cache_quant_method="none",
|
||||
speculative_num_steps=3,
|
||||
speculative_num_draft_tokens=4,
|
||||
|
||||
@@ -54,6 +54,7 @@ def _backend(device: str = "cpu") -> trtllm.TRTLLMMHAAttnBackend:
|
||||
kernel_page_size=PAGE,
|
||||
context_len=4096,
|
||||
max_bs=MAX_BS,
|
||||
max_resident_requests=MAX_BS,
|
||||
kv_cache_quant_method="none",
|
||||
components=(spec,),
|
||||
)
|
||||
|
||||
@@ -54,6 +54,7 @@ def _make_backend(is_draft: bool = False) -> TRTLLMMHAAttnBackend:
|
||||
kernel_page_size=PAGE,
|
||||
context_len=4096,
|
||||
max_bs=8,
|
||||
max_resident_requests=8,
|
||||
kv_cache_quant_method="none",
|
||||
speculative_num_steps=3,
|
||||
speculative_num_draft_tokens=SPEC_NUM_TOKENS,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user