Check docstring inside modular files as well#38988
Conversation
04262f8 to
c1d16a8
Compare
|
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. |
| # Adapted from transformers.models.jamba.modeling_jamba.HybridMambaAttentionDynamicCache for the v2 mixer | ||
| class HybridMambaAttentionDynamicCache(modeling_jamba.HybridMambaAttentionDynamicCache): | ||
| class HybridMambaAttentionDynamicCache(HybridMambaAttentionDynamicCache): |
There was a problem hiding this comment.
Should never have been here
| auto_docstring, | ||
| is_torch_flex_attn_available, | ||
| logger, | ||
| logging, |
There was a problem hiding this comment.
logger does not exist
| ) | ||
| from ..paligemma.modeling_paligemma import ( | ||
| PaligemmaCausalLMOutputWithPast, | ||
| PaliGemmaCausalLMOutputWithPast, |
There was a problem hiding this comment.
PaligemmaCausalLMOutputWithPast does not exist - missing an uppercase for the correct one
| # Adapted from transformers.models.jamba.modeling_jamba.HybridMambaAttentionDynamicCache for the v2 mixer | ||
| class HybridMambaAttentionDynamicCache(modeling_jamba.HybridMambaAttentionDynamicCache): | ||
| class HybridMambaAttentionDynamicCache(DynamicCache): |
There was a problem hiding this comment.
Should never have been here
6062757 to
9949fbc
Compare
yonigozlan
left a comment
There was a problem hiding this comment.
Nice! Just raised a potential issue with check_auto_docstrings
| r""" | ||
| pixel_attention_mask (`torch.Tensor` of shape `(batch_size, image_size, image_size)`, *optional*): | ||
| Mask to avoid performing attention on padding pixel indices. | ||
| image_hidden_states (`torch.FloatTensor` of shape `(batch_size, num_channels, image_size, image_size)`): | ||
| The hidden states of the image encoder after modality projection. | ||
| """ |
There was a problem hiding this comment.
Do we really need this here? It's the same as Idefics3
There was a problem hiding this comment.
Actually I had to add it because the class explicitly was overrideing @auto_docstring, so check_auto_docstrings was adding empty placeholders -> this is why I thought that check_auto_docstrings was correctly working, but maybe my change is not enough? In any case, I removed both the docstring and decorator now, as it's indeed redundant from Idefics3
| python utils/check_copies.py --fix_and_overwrite | ||
| python utils/check_docstrings.py --fix_and_overwrite | ||
| python utils/check_modular_conversion.py --fix_and_overwrite | ||
| python utils/check_dummies.py --fix_and_overwrite | ||
| python utils/check_pipeline_typing.py --fix_and_overwrite | ||
| python utils/check_doctest_list.py --fix_and_overwrite | ||
| python utils/check_docstrings.py --fix_and_overwrite |
There was a problem hiding this comment.
Agreed on changing the order here on principle, although it will kind of break check_auto_docstrings (included in python utils/check_docstrings.py --fix_and_overwrite command), as there is the same issue you described in this PR for check_auto_docstrings, but it's only fixed for check_docstrings here.
So for models with modular, check_auto_docstrings will overwrite the docstring in the modeling files if there's any issue, which will then be overridden by modular, making it as if nothing has changed after fix-copies even if there is something wrong with auto_docstring.
This is really more of an issue with check_auto_docstrings not checking the modular files for now, as there is some more difficult logic to handle compared to modeling files. It's on my to-do list, but seeing as this will break check_auto_docstrings, maybe for the scope of this PR, we can at least split python utils/check_docstrings.py --fix_and_overwrite in two to separate check_docstrings and check_auto_docstrings, and place python utils/check_auto_docstrings.py --fix_and_overwrite after modular conversion.
Wdyt @Cyrilvallez ?
There was a problem hiding this comment.
Humm, I thought I added sufficient code here for check_auto_docstring to check modular files as well - at least, it worked well on your above comment (see my answer as well) - but maybe it's not enough based on your most recent changes?
|
We discussed offline with @yonigozlan:
In any case, @yonigozlan said he wanted to refactor |
7ddfe6e to
680d665
Compare
|
[For maintainers] Suggested jobs to run (before merge) run-slow: aya_vision, bamba, biogpt, colpali, colqwen2, conditional_detr, data2vec, deformable_detr, dinov2_with_registers, dpt, falcon_h1, gemma3, gemma3n, got_ocr2, granitemoehybrid, grounding_dino |
What does this PR do?
We should check docstring in modular files as well! Otherwise, most of the time if the docstring is wrong in modular, e.g. in a Config,
make fix-copieswill apply modular with wrong docstring, thencheck_docstringwill fix it, but we still have inconsistency between the modular (which was not fixed automatically) and the modeling which has been fixed! Thus reapplying the modular later will lead to wrong docstrings again.This PR solves this circular inconsistency, and improves the overall modular workflow.
Also fixes some bad modulars at the same time (use relative imports everywhere, and remove bad inheritance of BambaCache)
cc @yonigozlan as you touched it a lot quite recently, and cc @ArthurZucker