Repository navigation
🚨🚨 Rename past_key_values/cache_params to cache - #50585
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. Pages changed in this PR:
|
There was a problem hiding this comment.
Model linter — first pass
transformers-mlinter found 18 item(s) in the model files this PR touches. These are structural conventions a maintainer would otherwise flag by hand.
This is automated and advisory — it does not block merging.
| rule | count | what it checks |
|---|---|---|
TRF057 |
18 | Public model, config, output and processor classes and their public methods must carry @auto_docstring. |
2 item(s) outside this diff
src/transformers/models/embedding_gemma2/modular_embedding_gemma2.py:477TRF057 — TRF057:EmbeddingGemma2TextModel.forwardin modeling_embedding_gemma2.py has no @auto_docstring. No parent method it could inherit the decorator from declares it. Add @auto_docstring as the innermost decorator here.src/transformers/models/flint/modular_flint.py:249TRF057 — TRF057:FlintForCausalLM.forwardin modeling_flint.py has no @auto_docstring. No parent method it could inherit the decorator from declares it. Add @auto_docstring as the innermost decorator here.
There was a problem hiding this comment.
Thanks, checked it against TRL: nothing there uses the old names, but two things break though:
- Continuous batching fails with
'PagedAttentionCache' object has no attribute 'get_query_offset'. - The BC handling covers
outputs["past_key_values"]but notoutputs.past_key_values, so liger-kernel 0.8.1's patched forwards (use_liger_kernel=True) fail withAttributeError: 'BaseModelOutputWithPast' object has no attribute 'past_key_values'. A__getattr__alias like the__getitem__one would keep them working.
|
Indeed @qgallouedec, it's still a work in progress but thanks for the early review! For the |
|
Ok, we have a lot of offline discussion on this with @vasqu and @ArthurZucker, and eventually agreed on it! Especially with the last commit, remote code should almost not experience any disruption at all (but once again we cannot predict everything, and they tend to have very ingenious ways to break 🙃). |
The model is new, so it has no old cache name to keep: skip test_bc_cache_name_forward, like Dory.
What does this PR do?
As per the title. We finally can have a single and meaningful name for the cache!
I made sure that all the following hold:
transformersBC compatibilitygenerateand model outputs classes (such asCausalLMOutputWithPast,...)past_key_values/cache_paramsin their signaturekwargs=kwargsin theupdate()method of the Cache. This means that CB knowupdates itscachethe exact same way as the standardCachedo inside theAttentionclasses instead of forcing it inside theattn_implementationfunction, which is much more elegantvllm: it does not forward any specific cache object inside thekwargs, so fully safesglang: the cache here is forwarded through thekwargs, but not under the same name so fully safetrl: all goodpeft: needs some local change directly in the peft codebase, as they sometimes check"past_key_values" in inspect.signature(forward), and we cannot easily trick the inspection of signature of course. However, the only peft integration test failing istest_prefix_tuning_trainer_load_best_model_at_end_error, so the blast radius is probably quite small🤖 mlinter review state
92492cb2b632b5c3past_key_values/cache_paramstocache#50585 (review)