[Bugfix] Make siglip/clip compatible with transformers v5 #37200
[Bugfix] Make siglip/clip compatible with transformers v5 #37200hmellor merged 1 commit intovllm-project:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request addresses a compatibility issue with transformers v5 in the siglip and clip model tests. The changes adapt the tests to handle the new BaseModelOutputWithPooling return type from feature extraction methods. My review includes suggestions to make the implementation more concise and idiomatic by using getattr for accessing the pooler_output, which simplifies the logic for handling different transformers versions.
| if not isinstance(pooled_output, torch.Tensor): | ||
| pooled_output = pooled_output.pooler_output |
There was a problem hiding this comment.
For better readability and conciseness, you can use getattr to handle both cases (tensor output from older transformers versions and BaseModelOutputWithPooling from newer versions). This avoids the explicit type check and makes the intent clearer.
pooled_output = getattr(pooled_output, 'pooler_output', pooled_output)| if not isinstance(pooled_output, torch.Tensor): | ||
| pooled_output = pooled_output.pooler_output |
…ct#37200) Signed-off-by: raushan <raushan@huggingface.co>
…ct#37200) Signed-off-by: raushan <raushan@huggingface.co>
…ct#37200) Signed-off-by: raushan <raushan@huggingface.co>
…ct#37200) Signed-off-by: raushan <raushan@huggingface.co>
…ct#37200) Signed-off-by: raushan <raushan@huggingface.co> Signed-off-by: Monishver Chandrasekaran <monishverchandrasekaran@gmail.com>
…ct#37200) Signed-off-by: raushan <raushan@huggingface.co>
…ct#37200) Signed-off-by: raushan <raushan@huggingface.co> Signed-off-by: Vinay Damodaran <vrdn@hey.com>
…ct#37200) Signed-off-by: raushan <raushan@huggingface.co> Signed-off-by: EricccYang <yangyang4991@gmail.com>
…ct#37200) Signed-off-by: raushan <raushan@huggingface.co>
…ct#37200) Signed-off-by: raushan <raushan@huggingface.co>
…ct#37200) Signed-off-by: raushan <raushan@huggingface.co>
From v5 we are returning a
BaseModelOutputWithPoolingfromget_xxx_features. This PR fixes the test to be compatible with v4-format tensor output and v5-format dict outputcc @hmellor