Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions examples/offline_inference_kvstar.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def setup_environment_variables():
os.environ["PYTHONHASHSEED"] = "123456"
os.environ["VLLM_TORCH_PROFILER_DIR"] = "./vllm_profile"


@contextlib.contextmanager
def build_llm_with_uc(module_path: str, name: str, model: str):
ktc = KVTransferConfig(
Expand All @@ -41,8 +42,8 @@ def build_llm_with_uc(module_path: str, name: str, model: str):
"local_window_sz": 2,
"sparse_ratio": 0.25,
"retrieval_stride": 8,
"blk_repre_dim_prune_ratio": 0.25, # 块表征维度裁剪
"blk_repre_inner_token_merge": 2 # 块内几个token融合成一个表征
"blk_repre_dim_prune_ratio": 0.25, # 块表征维度裁剪
"blk_repre_inner_token_merge": 2, # 块内几个token融合成一个表征
}
},
},
Expand Down Expand Up @@ -162,8 +163,13 @@ def main():

sampling_params = SamplingParams(temperature=0, top_k=1, max_tokens=300)

print_output(llm, prompts_prefill_more_than_2_full_blk, sampling_params, "first")
print_output(llm, prompts_prefill_more_than_2_full_blk, sampling_params, "second")
print_output(
llm, prompts_prefill_more_than_2_full_blk, sampling_params, "first"
)
print_output(
llm, prompts_prefill_more_than_2_full_blk, sampling_params, "second"
)


if __name__ == "__main__":
main()
4 changes: 3 additions & 1 deletion ucm/integration/vllm/ucm_sparse/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@ def create_sparse_method(
"KvComp", "ucm.sandbox.sparse.kvcomp.kvcomp", "KvComp"
)
UcmSparseFactory.register_sparse_method("GSA", "ucm.ucm_sparse.gsa", "GSA")
UcmSparseFactory.register_sparse_method("KVStarMultiStep", "ucm.ucm_sparse.kvstar.multistep", "KVStarMultiStep")
UcmSparseFactory.register_sparse_method(
"KVStarMultiStep", "ucm.ucm_sparse.kvstar.multistep", "KVStarMultiStep"
)
Loading