[MM] Cache common token sequences (#53560)

Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>
Signed-off-by: Cyrus Leung <tlleungac@connect.ust.hk>
This commit is contained in:
Cyrus Leung
2026-08-24 07:48:10 -07:00
committed by GitHub
parent 4ca856b0b5
commit ecfa7bb373
14 changed files with 40 additions and 23 deletions
+2 -1
View File
@@ -535,7 +535,8 @@ class Phi3VMultiModalProcessor(BaseMultiModalProcessor[Phi3VProcessingInfo]):
# Keep the behavior in line with HF processor
if len(mm_prompt_updates) and (
token_ids[:2] == tokenizer.encode("<s> <|image|>", add_special_tokens=False)
token_ids[:2]
== cached_encode(tokenizer, "<s> <|image|>", add_special_tokens=False)
):
token_ids = [token_ids[0], *token_ids[2:]]
placeholders = {