Skip to content

Conversation

shuminghu
Copy link
Contributor

@shuminghu shuminghu commented Sep 5, 2025

@auto_docstring for PerceptionLMForConditionalGeneration's forward would pin the doc for the method in modeling file to a stale version even if the doc was manually updated in the modular file.

Removing it and then run

 python utils/modular_model_converter.py --files_to_parse src/transformers/models/perception_lm/modular_perception_lm.py

updated the example in doc modeling file.

@zucchini-nlp

@@ -317,7 +317,6 @@ def prepare_inputs_for_generation(
return model_inputs

@can_return_tuple
@auto_docstring
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we still need to keep auto docstring, it will add docs about forward args

Copy link
Contributor Author

@shuminghu shuminghu Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auto_docstring make the modeling file doc stale (don't see modular file doc change)
Maybe a simple workaround is to remove, convert then add it back

Copy link
Member

@zucchini-nlp zucchini-nlp Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean, modular doesn't copy the example snippet if we keep it? We can't delete it from modeling file as well, so it is not about modular and we can't add it back :)

"content": [
{
"type": "image",
"url": test_image_file,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to download, we can put image link here (https://huggingface.co/datasets/shumingh/perception_lm_test_images/resolve/main/14496_0.PNG) and it will also work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. let me test this out. I've already left Meta, let me find a GPU somewhere lol.

@shuminghu
Copy link
Contributor Author

shuminghu commented Sep 8, 2025 via email

@zucchini-nlp
Copy link
Member

That is weird, similar pattern works fine with other models (e.g.

@can_return_tuple
@auto_docstring
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
pixel_values: Optional[torch.FloatTensor] = None,
pixel_mask: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.Tensor] = None,
position_ids: Optional[torch.LongTensor] = None,
past_key_values: Optional[Cache] = None,
inputs_embeds: Optional[torch.FloatTensor] = None,
labels: Optional[torch.LongTensor] = None,
use_cache: Optional[bool] = None,
logits_to_keep: Union[int, torch.Tensor] = 0,
cache_position: Optional[torch.LongTensor] = None,
**kwargs: Unpack[TransformersKwargs],
) -> Union[tuple, AriaCausalLMOutputWithPast]:
r"""
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
config.vocab_size]` or `model.image_token_id` (where `model` is your instance of `AriaForConditionalGeneration`).
Tokens with indices set to `model.image_token_id` are ignored (masked), the loss is only
computed for the tokens with labels in `[0, ..., config.vocab_size]`.
)

Could it be caused by version mismatch with one of the packages? 🤔

@shuminghu
Copy link
Contributor Author

shuminghu commented Sep 8, 2025 via email

@zucchini-nlp
Copy link
Member

Ah yeah, modular copied from llava because it had no example from Perception itself. Sorry, missed that one. As long as we add docstring it should be fine, togetheer with the decorator

@shuminghu
Copy link
Contributor Author

shuminghu commented Sep 8, 2025 via email

@zucchini-nlp
Copy link
Member

both, same as in aria and it should work

@shuminghu
Copy link
Contributor Author

shuminghu commented Sep 8, 2025 via email

@zucchini-nlp
Copy link
Member

ahhh oke, misunderstood then. In any case, we will need to have both files updated and with identical docs to pass CI :)

@zucchini-nlp
Copy link
Member

zucchini-nlp commented Sep 10, 2025

Lets merge it, it only had the decorator missing :)

@zucchini-nlp zucchini-nlp enabled auto-merge (squash) September 10, 2025 09:28
Copy link
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: perception_lm

@HuggingFaceDocBuilderDev

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.

Copy link
Member

@zucchini-nlp zucchini-nlp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, have to approve first

@zucchini-nlp zucchini-nlp merged commit 0997c2f into huggingface:main Sep 10, 2025
14 checks passed
@shuminghu
Copy link
Contributor Author

shuminghu commented Sep 10, 2025 via email

@zucchini-nlp
Copy link
Member

Congrats, hope you got a GPU as well 😆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants