Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
191 commits
Select commit Hold shift + click to select a range
e253ef2
first batch, let's see
molbap Jan 29, 2026
4183863
propagate changes
molbap Jan 30, 2026
49b1547
fixup broken tests
molbap Jan 30, 2026
9382257
simplify more models
molbap Jan 30, 2026
e6c4b89
hack
molbap Jan 30, 2026
6c002b5
fix attentions
molbap Jan 30, 2026
0ca6f96
Merge branch 'main' into update_all_decorators
molbap Jan 30, 2026
b327b19
I'm bullied by the new fix-repo
molbap Jan 30, 2026
807b17f
this one too
molbap Jan 30, 2026
f0916ea
fix-repo
molbap Jan 30, 2026
24bf3b5
...fix-repo?
molbap Jan 30, 2026
15bf2d7
change up
molbap Feb 3, 2026
a0569c8
fixup merges with main
molbap Feb 3, 2026
8ae95c5
propagate changes again
molbap Feb 3, 2026
389dde9
more changes
molbap Feb 3, 2026
21b65ef
fixes
molbap Feb 3, 2026
37e2841
revert CLAP to the back burner
molbap Feb 3, 2026
6affc73
more changes
molbap Feb 3, 2026
b5f3996
some broken clap stuff
molbap Feb 3, 2026
2b53f63
New batch of models
molbap Feb 4, 2026
7867d98
something forgotten?
molbap Feb 4, 2026
6c22616
biiig batch + handle explicit None values for output_attentions in ge…
molbap Feb 4, 2026
becb675
make fixup
molbap Feb 4, 2026
41257e2
Merge branch 'main' into update_all_decorators
molbap Feb 4, 2026
7961fba
remove dummy record outputs
molbap Feb 5, 2026
2147358
Merge branch 'main' into update_all_decorators
molbap Feb 5, 2026
531919c
batch, with some difficult ones (dpt)
molbap Feb 6, 2026
77e4af8
ugly fix
molbap Feb 6, 2026
67dc0e9
update
molbap Feb 6, 2026
79cdb8c
fix
molbap Feb 6, 2026
7b62ce5
propagate changes
molbap Feb 6, 2026
bf77c9e
some more modifs
molbap Feb 6, 2026
6d24a2b
fixup
molbap Feb 6, 2026
edb124e
Merge branch 'main' into update_all_decorators
molbap Feb 6, 2026
fe0df51
be careful about this stuff
molbap Feb 6, 2026
cb2d2c8
style
molbap Feb 6, 2026
4f4b25a
fix repo
molbap Feb 6, 2026
4c51e57
fix more
molbap Feb 10, 2026
3002e8a
loose booleans
molbap Feb 10, 2026
ba87a9f
missing docstring
molbap Feb 10, 2026
6137c6b
fix import
molbap Feb 10, 2026
96f4f73
Fix many merge conflicts hopefully not breaking anything (merge with …
molbap Feb 10, 2026
ee96236
fixing fixing
molbap Feb 10, 2026
7f81eb1
hacky kosmos2.5...
molbap Feb 10, 2026
21ec95b
upgrade
molbap Feb 10, 2026
492d5a2
simplifyyy
molbap Feb 10, 2026
764541b
and another one
molbap Feb 10, 2026
84b1322
propagate many changes
molbap Feb 10, 2026
6864ff2
upgraaade
molbap Feb 11, 2026
082de92
fix
molbap Feb 11, 2026
059afac
ay
molbap Feb 11, 2026
a4d3535
fixes, many
molbap Feb 11, 2026
e53623f
fiiix
molbap Feb 11, 2026
73aac50
more more updates
molbap Feb 11, 2026
4f00326
might slow things down?
molbap Feb 11, 2026
a34d300
fix fix
molbap Feb 11, 2026
dbbc8e9
fiix
molbap Feb 11, 2026
9376382
Merge branch 'main' into update_all_decorators
molbap Feb 12, 2026
e79d92a
fix
molbap Feb 12, 2026
aeb63ff
fiiix meeeerge confliiiicts
molbap Feb 12, 2026
2009016
style
molbap Feb 12, 2026
aac3dc8
modular
molbap Feb 12, 2026
9203684
Merge branch 'main' into update_all_decorators
molbap Feb 12, 2026
3d96885
modular
molbap Feb 12, 2026
c6415a2
small update...
molbap Feb 12, 2026
15f8fe2
tests broken
molbap Feb 12, 2026
81aafcf
remapping a bunch of kwargs to encoder_kwargs to avoid contamination
molbap Feb 13, 2026
af2dc85
Merge branch 'main' into update_all_decorators
molbap Feb 13, 2026
1827905
style
molbap Feb 13, 2026
45fedbd
modular mess up
molbap Feb 13, 2026
6cd2ef6
more fixes
molbap Feb 13, 2026
e1aa015
fix more things
molbap Feb 13, 2026
5fca01d
more fixes
molbap Feb 13, 2026
43ffe22
style
molbap Feb 13, 2026
e452559
address comments 1
molbap Feb 16, 2026
2add677
argh
molbap Feb 16, 2026
6ed2c4e
fiiix
molbap Feb 16, 2026
4fc5abf
broken kosmos2 why
molbap Feb 17, 2026
f8a35e5
decorators
molbap Feb 17, 2026
93a1838
done
molbap Feb 17, 2026
303140e
fixup docs,
molbap Feb 17, 2026
20e04ed
last fixes?
molbap Feb 17, 2026
8adbf03
bring back typing!
molbap Feb 17, 2026
4731344
Merge branch 'main' into update_all_decorators
molbap Feb 17, 2026
dc95ece
modularities
molbap Feb 17, 2026
566e1d2
modulaaar
molbap Feb 17, 2026
f8e995c
style
molbap Feb 17, 2026
6bf065b
fix compile
molbap Feb 17, 2026
b9ed56c
autodocstringss
molbap Feb 18, 2026
235875d
Merge branch 'main' into update_all_decorators
molbap Feb 23, 2026
6c01379
The greatest decorator upgrade
molbap Feb 23, 2026
f71cd4c
fix modular
molbap Feb 23, 2026
93c1c5d
few fixes
molbap Feb 23, 2026
73e92ca
Merge branch 'main' into update_all_decorators
vasqu Mar 2, 2026
fb86e68
fixup wrong decorators
vasqu Mar 2, 2026
0fde2ff
fix gemma
vasqu Mar 2, 2026
a4043d9
fix align
vasqu Mar 2, 2026
9c9f942
revert numba changes
vasqu Mar 2, 2026
572d4b0
fixup pp v2 modular
vasqu Mar 2, 2026
9890f73
remove unnecessary merge with defaults and return tuple + refactor ko…
vasqu Mar 2, 2026
c693ee8
oops
vasqu Mar 2, 2026
68cbdb7
fixup repo
vasqu Mar 2, 2026
5b0e219
pass kwargs on idefics properly
vasqu Mar 2, 2026
f382c16
new should have beens
vasqu Mar 2, 2026
7ba0b70
dang copy pasting is not my strong suite
vasqu Mar 2, 2026
5dacd51
... no comment
vasqu Mar 2, 2026
748eb9f
fixup some pretrained stuff
vasqu Mar 2, 2026
511ba7e
Merge branch 'main' into update_all_decorators
vasqu Mar 2, 2026
2fc22d5
refactor zamba models properly + fixup gradient ckpting within merged…
vasqu Mar 3, 2026
a2d92d2
style
vasqu Mar 3, 2026
22b2e28
several fixups
vasqu Mar 3, 2026
e5620be
style + fixup
vasqu Mar 3, 2026
e8f2f6c
fix repo
vasqu Mar 3, 2026
0c1d62b
interesting
vasqu Mar 3, 2026
f8e9001
small fixes
vasqu Mar 3, 2026
780ed8e
fix align and other small fixes
vasqu Mar 3, 2026
b96e5ca
fix repo
vasqu Mar 3, 2026
ca46369
this time
vasqu Mar 3, 2026
9b00048
p1
vasqu Mar 3, 2026
032f339
p2
vasqu Mar 3, 2026
3021ea8
fix encoder got cache during generate
vasqu Mar 3, 2026
5b47a27
let's try this
vasqu Mar 3, 2026
d7c7b69
fix
vasqu Mar 3, 2026
4ce0480
revert higgs
vasqu Mar 3, 2026
eb064c4
fixup models
vasqu Mar 3, 2026
555c570
fix
vasqu Mar 3, 2026
5c931db
that copy is bad
vasqu Mar 3, 2026
27a08f5
new round of fixes
vasqu Mar 3, 2026
63f0f0c
fixup some backbones
vasqu Mar 3, 2026
33d2482
style
vasqu Mar 3, 2026
f0ef4d1
Merge branch 'main' into update_all_decorators
vasqu Mar 3, 2026
d138b47
Merge branch 'main' into update_all_decorators
vasqu Mar 4, 2026
4f5b1de
fix xlstm training inplace op
vasqu Mar 4, 2026
c9d4b1a
fix repo
vasqu Mar 4, 2026
7c6b0e0
revert the kwargs renames
vasqu Mar 4, 2026
27f539d
wrong decorator application
vasqu Mar 4, 2026
d26056f
style
vasqu Mar 4, 2026
28038bd
fix defaults for vision args
vasqu Mar 4, 2026
206f2b1
fix concistency
vasqu Mar 4, 2026
1d7046a
remove the user requested workaround, always return
vasqu Mar 4, 2026
fb19136
style
vasqu Mar 4, 2026
8112bc5
some type annotations
vasqu Mar 4, 2026
96dfc6a
p1
vasqu Mar 4, 2026
5cb7245
p2
vasqu Mar 4, 2026
90e392d
fix repo
vasqu Mar 4, 2026
b9b5974
readd the workaround
vasqu Mar 4, 2026
af47d89
Merge branch 'main' into update_all_decorators
vasqu Mar 4, 2026
c08dc4e
fix git
vasqu Mar 4, 2026
4be2830
fix vitpose backbone
vasqu Mar 4, 2026
2c87457
fixup
vasqu Mar 4, 2026
eb0a5f7
quick fixes
vasqu Mar 4, 2026
82dd509
repo
vasqu Mar 4, 2026
314415e
fix
vasqu Mar 4, 2026
7b97114
fix these
vasqu Mar 4, 2026
5e963f8
x clip was implemented so wrong ICANT
vasqu Mar 4, 2026
1c8dc74
clipseg fixups
vasqu Mar 4, 2026
0c1bf96
fix repo
vasqu Mar 4, 2026
a051182
Merge branch 'main' into update_all_decorators
vasqu Mar 5, 2026
c0fe07f
fixup weird hidden states treatment, backbones are inherently already…
vasqu Mar 5, 2026
7280031
style
vasqu Mar 5, 2026
19d20c2
fix last tests
vasqu Mar 5, 2026
aecbf09
change backbones mixin instead with a wrapper always applied to the s…
vasqu Mar 5, 2026
d719a26
style
vasqu Mar 5, 2026
074579f
force dict
vasqu Mar 5, 2026
d5a88ef
cleanup
vasqu Mar 5, 2026
60f7b1f
missed this one
vasqu Mar 5, 2026
e95ff50
wow this was nasty
vasqu Mar 5, 2026
655bc47
refactor a few models
vasqu Mar 5, 2026
3e40757
fixups
vasqu Mar 5, 2026
433f817
readd backbones to common tests
vasqu Mar 5, 2026
59b18b1
revert gc changes
vasqu Mar 6, 2026
ce1c616
fix repo
vasqu Mar 6, 2026
f0cc979
explicit decorators
vasqu Mar 6, 2026
b034aa5
revert zamba
vasqu Mar 6, 2026
9b7cef9
fixup the unrelated renaming in dino 3 vit
vasqu Mar 6, 2026
12298cd
Merge branch 'main' into update_all_decorators
vasqu Mar 6, 2026
b9890c8
fixup some modular stuff
vasqu Mar 9, 2026
3887673
fixup weird zamba2 workaround
vasqu Mar 9, 2026
10d278e
fixup dino stuff
vasqu Mar 9, 2026
14029fe
idefics simplifications
vasqu Mar 9, 2026
c1b69ce
small fixes
vasqu Mar 9, 2026
346cc0f
fix kosmos 2.5
vasqu Mar 10, 2026
a8b8fd4
fixup
vasqu Mar 11, 2026
fdaa667
Merge branch 'main' into update_all_decorators
vasqu Mar 11, 2026
e8b24d1
fix clvp, same failure as main when fixing the return dict stuff
vasqu Mar 11, 2026
2e30c62
same fix as in the other pr
vasqu Mar 11, 2026
b1e7d9f
fixup some ci stuff
vasqu Mar 11, 2026
2c1678f
style
vasqu Mar 12, 2026
d6fb85a
revert pr to capturing
vasqu Mar 12, 2026
0a647b5
Merge branch 'main' into update_all_decorators
vasqu Mar 12, 2026
6770bea
Merge branch 'main' into update_all_decorators
vasqu Mar 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/transformers/backbone_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""Collection of utils to be used by backbones and their components."""

import enum
import functools
import inspect

from huggingface_hub import repo_exists
Expand Down Expand Up @@ -156,6 +157,27 @@ def to_dict(self):
return output


def filter_output_hidden_states(forward_function):
"""
Wrapper to filer out `hidden_states` as backbones tend to always use them to get their feature maps, i.e.
they also always output `hidden_states`. This controls for user-defined behavior again.

NOTE: We assume a `can_return_tuple` decorator to be applied before so that we always expect a dict like
object to remove the hidden states.
"""

@functools.wraps(forward_function)
def wrapper(self, *args, **kwargs):
output_hidden_states = kwargs.get("output_hidden_states", getattr(self.config, "output_hidden_states", False))
output = forward_function(self, *args, **kwargs)
if not output_hidden_states:
filtered_output_data = {k: v for k, v in output.items() if k not in ("hidden_states")}
output = type(output)(**filtered_output_data)
return output
Comment on lines +169 to +176

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is the new wrapper to make backbones behave like expected: They always output hidden states so we control this here.

output = type(output)(**filtered_output_data) is a bit weird but it allows us to construct our modeling outputs properly as there is no delete function and I don't think we want one


return wrapper


class BackboneMixin:
backbone_type: BackboneType | None = None

Expand Down
2 changes: 2 additions & 0 deletions src/transformers/conversion_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@

def _build_checkpoint_conversion_mapping():
mapping = {
"dinov3_convnext": [WeightRenaming(r"(?<!model\.)stages", r"model.stages")],
"dinov3_vit": [WeightRenaming(r"(?<!model\.)layer.", r"model.layer.")],
"timesfm2_5": [
WeightRenaming("ff0", "fc1"),
WeightRenaming("ff1", "fc2"),
Expand Down
2 changes: 1 addition & 1 deletion src/transformers/generation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ def _prepare_encoder_decoder_kwargs_for_generation(
add_hook_to_module(encoder, AlignDevicesHook(io_same_device=True))

# 2. Prepare encoder args and encoder kwargs from model kwargs and generation config.
irrelevant_prefix = ["decoder_", "cross_attn", "use_cache"]
irrelevant_prefix = ["decoder_", "cross_attn", "use_cache", "past_key_values", "cache_params"]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is needed as encoder oftentimes share the same attention module from the decoder, meaning that if we pass the cache there everything gets messy

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Humm, I don't get why we need this suddenly? Even encoder may want the cache with EncoderDecoder cache no?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

But the encoder module itself never wants a cache, it's only forwarded once and then "saved" for each subsequent step. Only the decoder needs the cache to properly overwrite states.

If the encoder also gets the cache, then it can update the cache as well which makes generate being broken for certain methods (not sure which anymore but CI was broken for a few tests on bart then).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ha yes, cause you made sure to propagate kwargs now as well! Makes sense then!

encoder_kwargs = {
argument: value
for argument, value in model_kwargs.items()
Expand Down
5 changes: 1 addition & 4 deletions src/transformers/models/aimv2/modeling_aimv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ class Aimv2Output(ModelOutput):
vision_model_output: BaseModelOutputWithPooling = None

def to_tuple(self) -> tuple[Any]:
return tuple(
self[k] if k not in ["text_model_output", "vision_model_output"] else getattr(self, k).to_tuple()
for k in self.keys()
)
return tuple(v.to_tuple() if isinstance(v, ModelOutput) else v for v in self.values())


@use_kernel_forward_from_hub("RMSNorm")
Expand Down
Loading
Loading