-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[None][fix] Respect KVCM V2 initialization and warmup budgets #19213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
5bb3aa8
49abcc6
10fef55
b595aec
f99fae5
4c87a8d
9c3c53b
40466ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2690,20 +2690,34 @@ def _build_base_config( | |
| * (self.max_batch_size - 1) | ||
| ) | ||
|
|
||
| # CUDA graph generation warmup uses one request at max_seq_len and | ||
| # enough minimal decode requests to fill max_batch_size. | ||
| min_decode_capacity = 1 + self.max_draft_len + self.num_extra_kv_tokens | ||
| constraints.append( | ||
| BatchDesc( | ||
| [ | ||
| KVCacheDesc( | ||
| capacity=self.max_seq_len, | ||
| history_length=self.max_seq_len - 1, | ||
| ) | ||
| ] | ||
| + [KVCacheDesc(capacity=min_decode_capacity, history_length=0)] | ||
| * (self.max_batch_size - 1) | ||
| ) | ||
| gpu_quota = next( | ||
| tier.quota for tier in cache_tiers if isinstance(tier, GpuCacheTierConfig) | ||
| ) | ||
| # Native minimum slot counts are divided by the resume watermark. | ||
| # Normalize the quota before estimating a feasible long request. | ||
| estimate = self._get_max_tokens_from_quota( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This estimate excludes buffers registered by |
||
| int(gpu_quota * kv_cache_config.max_util_for_resume) | ||
| ) | ||
| generation_capacity = int(min(self.max_seq_len, max(min_decode_capacity, estimate))) | ||
| # These are independent workloads. Graph warmup shortens its long | ||
| # request after allocating the short requests; requiring both at | ||
| # this estimated length would count their memory twice. | ||
| constraints.extend( | ||
| [ | ||
| BatchDesc( | ||
| [ | ||
| KVCacheDesc( | ||
| capacity=generation_capacity, | ||
| history_length=generation_capacity - 1, | ||
| ) | ||
| ] | ||
| ), | ||
| BatchDesc( | ||
| [KVCacheDesc(capacity=min_decode_capacity, history_length=0)] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please model the final dummy capacity here. |
||
| * self.max_batch_size | ||
| ), | ||
| ] | ||
| ) | ||
|
|
||
| # General and chunked-prefill warmup uses one fresh context request | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3282,6 +3282,14 @@ def free_warmup_requests() -> None: | |
| max_num_draft_tokens=_kv_draft) | ||
| available_tokens = min(available_tokens, draft_available_tokens) | ||
|
|
||
| if isinstance(kv_cache_manager, KVCacheManagerV2): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This clamp starts from total slots and reserves only one minimal page per other row, although short dummies and the optional guard page are already resident. It can overestimate capacity and skip graph capture. |
||
| # V2 reserves one generation token beyond the draft/extra tokens. | ||
| available_tokens -= 1 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The draft cache cannot use the target-style clamp: its warmup resizes omit |
||
| minimum_tokens = ENC_DEC_CUDA_GRAPH_DUMMY_TOKEN_NUM if is_enc_dec else 1 | ||
| if available_tokens < minimum_tokens: | ||
| free_warmup_requests() | ||
| return None | ||
|
|
||
|
yizhang-nv marked this conversation as resolved.
|
||
| token_num = max( | ||
| ENC_DEC_CUDA_GRAPH_DUMMY_TOKEN_NUM if is_enc_dec else 1, | ||
| min( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we consider the indexer K cahe when using sparse attention, for example the MiniMax-M3 INDEX_KEY extra buffer?