-
Notifications
You must be signed in to change notification settings - Fork 742
[Bugfix] align input_token_ids with gpu_block_ids #7574
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
Open
zccjjj
wants to merge
2
commits into
PaddlePaddle:develop
Choose a base branch
from
zccjjj:bugfix
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |
| # limitations under the License. | ||
| """ | ||
|
|
||
| import os | ||
| import time | ||
| import traceback | ||
| from dataclasses import dataclass | ||
|
|
@@ -51,6 +52,7 @@ class AttentionStoreConfig: | |
| bytes_per_shard_layer_per_block: int = 1024 | ||
| device_id: int = 0 | ||
| dp_id: int = 0 | ||
| splitwise_role: str = "mixed" | ||
|
|
||
|
|
||
| class AttentionStore(KVCacheStorage): | ||
|
|
@@ -62,6 +64,13 @@ def __init__(self, **args): | |
| self.config = AttentionStoreConfig(**args) | ||
|
|
||
| try: | ||
| self.config.namespace = os.getenv("AS_NAMESPACE", self.config.namespace) | ||
| self.config.pod_name = os.getenv("AS_POD_NAME", self.config.pod_name) | ||
| if int(os.getenv("ENABLE_EP_DP_IN_FD", "1")): | ||
|
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. 🟡 建议 当环境变量 建议修改为更健壮的写法: if os.getenv("ENABLE_EP_DP_IN_FD", "1") != "0": |
||
| self.config.pod_name = ( | ||
| self.config.pod_name + "_" + self.config.splitwise_role + "_" + str(self.config.dp_id) | ||
| ) | ||
| self.config.model_version = os.getenv("AS_MODEL_VERSION", self.config.model_version) | ||
| logger.info(f"[INIT] Start initializing AttentionStoreSDK with config: {self.config}") | ||
| self.sdk = AttentionStoreSDK( | ||
| self.config.namespace, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
❓ 疑问 移除
enable_output_caching条件是否符合预期?原代码在
enable_output_caching=False时,input_token_ids只包含 input tokens;现在无论该配置如何,总会追加request.output_token_ids。虽然后续的截断
input_token_ids[: len(keys) * block_size]可能会将 output tokens 剪掉,但这取决于keys覆盖的范围。如果enable_output_caching=False时keys的数量意外覆盖了 output token 区间,缓存内容将包含本不应写入的 output tokens,可能污染下次 prefix cache 命中结果。请确认:当
enable_output_caching=False时,keys的长度是否严格不超过 input 对应的 block 数?如果可以保证,建议在此处添加注释说明该假设。