Oussama Elachqar
commited on
Commit
·
37ff428
1
Parent(s):
f19f7fc
fix cache
Browse files- modeling_molmo.py +5 -1
modeling_molmo.py
CHANGED
@@ -2275,7 +2275,11 @@ class MolmoForCausalLM(PreTrainedModel):
|
|
2275 |
del model_kwargs["images"]
|
2276 |
del model_kwargs["image_masks"]
|
2277 |
del model_kwargs["image_input_idx"]
|
2278 |
-
|
|
|
|
|
|
|
|
|
2279 |
model_kwargs[cache_name] = cache
|
2280 |
model_kwargs["cache_position"] = model_kwargs["cache_position"][-1:] + num_new_tokens
|
2281 |
return model_kwargs
|
|
|
2275 |
del model_kwargs["images"]
|
2276 |
del model_kwargs["image_masks"]
|
2277 |
del model_kwargs["image_input_idx"]
|
2278 |
+
try:
|
2279 |
+
cache_name, cache = super()._extract_past_from_model_output(outputs)
|
2280 |
+
except AttributeError:
|
2281 |
+
past_key_values = outputs.past_key_values if "past_key_values" in outputs else None
|
2282 |
+
cache_name, cache = "past_key_values", past_key_values
|
2283 |
model_kwargs[cache_name] = cache
|
2284 |
model_kwargs["cache_position"] = model_kwargs["cache_position"][-1:] + num_new_tokens
|
2285 |
return model_kwargs
|