Repository: huggingface/transformers
Pull request: Small fixes amd

This PR fixes two small things:
- `janus` decoder handling to avoid a multiple device error (will soon be merged in main, #38488 )
- `modernbert` has a `pos_idx_in_fp32` kwargs for RotaryEmbedding which is no longer an argument for init in the parent class (https://github.com/Dao-AILab/flash-attention/commit/1870a0dc0285266c83ff2effbcc2a383cc4ee8c7)

Changed files:
filename: src/transformers/models/janus/modeling_janus.py
patch: @@ -1083,6 +1083,12 @@ def get_image_features(self, pixel_values):
         image_embeds = self.aligner(image_embeds.last_hidden_state)
         return image_embeds
 
+    def set_decoder(self, decoder):
+        self.language_model = decoder
+
+    def get_decoder(self):
+        return self.language_model
+
     @can_return_tuple
     @auto_docstring
     def forward(
@@ -1192,10 +1198,10 @@ def set_output_embeddings(self, new_embeddings):
         self.lm_head = new_embeddings
 
     def set_decoder(self, decoder):
-        self.model = decoder
+        self.model.set_decoder(decoder)
 
     def get_decoder(self):
-        return self.model
+        return self.model.get_decoder()
 
     @can_return_tuple
     @auto_docstring

filename: src/transformers/models/janus/modular_janus.py
patch: @@ -921,6 +921,12 @@ def get_image_features(self, pixel_values):
         image_embeds = self.aligner(image_embeds.last_hidden_state)
         return image_embeds
 
+    def set_decoder(self, decoder):
+        self.language_model = decoder
+
+    def get_decoder(self):
+        return self.language_model
+
     @can_return_tuple
     @auto_docstring
     def forward(
@@ -1030,10 +1036,10 @@ def set_output_embeddings(self, new_embeddings):
         self.lm_head = new_embeddings
 
     def set_decoder(self, decoder):
-        self.model = decoder
+        self.model.set_decoder(decoder)
 
     def get_decoder(self):
-        return self.model
+        return self.model.get_decoder()
 
     @can_return_tuple
     @auto_docstring

filename: src/transformers/models/modernbert/modeling_modernbert.py
patch: @@ -154,7 +154,7 @@ def __init__(
             up to max_seqlen. If the max_seqlen, device, or dtype during training/inference differ,
             the cos_sin_cache will be recomputed during the forward pass.
         """
-        super().__init__(dim=dim, base=base, pos_idx_in_fp32=True, device=device, interleaved=False)
+        super().__init__(dim=dim, base=base, device=device, interleaved=False)
         self.max_seqlen = max_seqlen
 
         if max_seqlen is not None and device is not None and dtype is not None:

filename: src/transformers/models/modernbert/modular_modernbert.py
patch: @@ -417,7 +417,7 @@ def __init__(
             up to max_seqlen. If the max_seqlen, device, or dtype during training/inference differ,
             the cos_sin_cache will be recomputed during the forward pass.
         """
-        super().__init__(dim=dim, base=base, pos_idx_in_fp32=True, device=device, interleaved=False)
+        super().__init__(dim=dim, base=base, device=device, interleaved=False)
         self.max_seqlen = max_seqlen
 
         if max_seqlen is not None and device is not None and dtype is not None: