[feat] support prefix cache clearing when /clear_load_weight is called
#4091
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.
需求描述
在 RL 场景需要交替进行训练和推理,因此每次推理结束后需要调用 /clear_load_weight 清理权重给训练腾出空间,训练结束后需要调用 /update_model_weight 时重新加载权重进行推理。现在 RL 需要开启上下文前缀缓存(Prefix Caching)实现推理加速,因此 KV 缓存也要配套该接口进行与模型权重的清除和加载。本 PR 主要实现该功能点。
主要改动
FD_ENABLE_SWAP_SPACE_CLEARING控制在清除 PrefixCache 时是否要顺带清除 CPU 缓存,默认为 0,即不会清除 CPU 缓存