Widen match condition for _can_record_outputs#43762
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. |
| for key, specs in capture_tasks: | ||
| # The second check is for multimodals where only backbone layer suffix is available | ||
| if (specs.target_class is not None and isinstance(module, specs.target_class)) or ( | ||
| specs.class_name is not None and name.endswith(specs.class_name) |
There was a problem hiding this comment.
This line of check for class_name was added for AyaVision, but I think it's not needed anymore. At least tests don't complain 😄
There was a problem hiding this comment.
aah :D makes sense, wdyt of the added check though? not sure how to handle reloading more elegantly
There was a problem hiding this comment.
I think it's the best we can do with importlib.reload and shouldn't backfire with false positives. Lemme approve, forgot to
| outputs = model(pixel_values=pixel_values, output_hidden_states=True) | ||
| self.assertIsNotNone(outputs.hidden_states) | ||
|
|
||
| importlib.reload(modeling_clip) |
There was a problem hiding this comment.
maybe we can move it under test_modeling_common.py, for make smth similar to this test and reload the module at some point before checking if config.output_attentions works?
transformers/tests/test_modeling_common.py
Lines 1754 to 1757 in ace7c37
There was a problem hiding this comment.
yeah I hesitated, I didn't want to add yet another test for 400+ models 🫣 but you may be right
ArthurZucker
left a comment
There was a problem hiding this comment.
great catch actually! 🤗
|
I want to think that great minds think alike 👀 @Cyrilvallez 's PR solves more problems with |
In case of module reloading, we currently lose tracking hooks for hidden states and attentions . Widening the matching condition a bit.
Should fix #43761, also mentioned in linkedin/Liger-Kernel#1061
Reproducer for CLIP:
Second reload will currently fail, and this is a fix proposal.
Added a test as well (specific to CLIP, likely enough)