Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 6 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,12 @@
stale_egg_info = Path(__file__).parent / "transformers.egg-info"
if stale_egg_info.exists():
print(
(
"Warning: {} exists.\n\n"
"If you recently updated transformers to 3.0 or later, this is expected,\n"
"but it may prevent transformers from installing in editable mode.\n\n"
"This directory is automatically generated by Python's packaging tools.\n"
"I will remove it now.\n\n"
"See https://github.com/pypa/pip/issues/5466 for details.\n"
).format(stale_egg_info)
f"Warning: {stale_egg_info} exists.\n\n"
"If you recently updated transformers to 3.0 or later, this is expected,\n"
"but it may prevent transformers from installing in editable mode.\n\n"
"This directory is automatically generated by Python's packaging tools.\n"
"I will remove it now.\n\n"
"See https://github.com/pypa/pip/issues/5466 for details.\n"
)
shutil.rmtree(stale_egg_info)

Expand Down
6 changes: 0 additions & 6 deletions src/transformers/generation/configuration_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,12 +564,6 @@ def validate(self, strict=False):
)
# 1.4. Watermarking attributes
if self.watermarking_config is not None:
if not (isinstance(self.watermarking_config, (WatermarkingConfig, SynthIDTextWatermarkingConfig))):
minor_issues["watermarking_config"] = (
"`watermarking_config` as a dict is deprecated and will be removed in v4.54.0. Please construct "
"`watermarking_config` object with `WatermarkingConfig` or `SynthIDTextWatermarkingConfig` class."
)
self.watermarking_config = WatermarkingConfig.from_dict(self.watermarking_config)
self.watermarking_config.validate()

# 2. Validation of attribute combinations
Expand Down
4 changes: 0 additions & 4 deletions src/transformers/models/bloom/modeling_bloom.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,10 +545,6 @@ def forward(
if inputs_embeds is None:
inputs_embeds = self.word_embeddings(input_ids)

# TODO (joao): remove this exception in v4.56 -- it exists for users that try to pass a legacy cache
if not isinstance(past_key_values, (type(None), Cache)):
raise ValueError("The `past_key_values` should be either a `Cache` object or `None`.")

if use_cache and past_key_values is None:
past_key_values = DynamicCache(config=self.config)

Expand Down
4 changes: 0 additions & 4 deletions src/transformers/models/codegen/modeling_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,6 @@ def forward(
if inputs_embeds is None:
inputs_embeds = self.wte(input_ids)

# TODO (joao): remove this exception in v4.56 -- it exists for users that try to pass a legacy cache
if not isinstance(past_key_values, (type(None), Cache)):
raise ValueError("The `past_key_values` should be either a `Cache` object or `None`.")

if use_cache and past_key_values is None:
past_key_values = DynamicCache(config=self.config)

Expand Down
14 changes: 0 additions & 14 deletions src/transformers/models/cohere2/configuration_cohere2.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import warnings

from ...configuration_utils import PretrainedConfig, layer_type_validation
from ...modeling_rope_utils import rope_config_validation

Expand Down Expand Up @@ -230,17 +228,5 @@ def __init__(
]
layer_type_validation(self.layer_types)

@property
def sliding_window_pattern(self):
warnings.warn(
"The `sliding_window_pattern` attribute is deprecated and will be removed in v4.55.0.",
FutureWarning,
)
return self._sliding_window_pattern

@sliding_window_pattern.setter
def sliding_window_pattern(self, value):
self._sliding_window_pattern = value


__all__ = ["Cohere2Config"]
13 changes: 0 additions & 13 deletions src/transformers/models/cohere2/modular_cohere2.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import warnings
from typing import Callable, Optional

import torch
Expand Down Expand Up @@ -250,18 +249,6 @@ def __init__(
]
layer_type_validation(self.layer_types)

@property
def sliding_window_pattern(self):
warnings.warn(
"The `sliding_window_pattern` attribute is deprecated and will be removed in v4.55.0.",
FutureWarning,
)
return self._sliding_window_pattern

@sliding_window_pattern.setter
def sliding_window_pattern(self, value):
self._sliding_window_pattern = value


class Cohere2RotaryEmbedding(CohereRotaryEmbedding):
pass
Expand Down
4 changes: 0 additions & 4 deletions src/transformers/models/dbrx/modeling_dbrx.py
Original file line number Diff line number Diff line change
Expand Up @@ -910,10 +910,6 @@ def forward(

inputs_embeds = nn.functional.dropout(inputs_embeds, p=self.emb_pdrop, training=self.training)

# TODO (joao): remove this exception in v4.56 -- it exists for users that try to pass a legacy cache
if not isinstance(past_key_values, (type(None), Cache)):
raise ValueError("The `past_key_values` should be either a `Cache` object or `None`.")

if use_cache and past_key_values is None:
past_key_values = DynamicCache(config=self.config)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,15 +570,6 @@ def forward(
if use_cache:
if past_key_values is None:
past_key_values = DynamicCache(config=self.config)
elif isinstance(past_key_values, tuple):
logger.warning_once(
"Passing a tuple of `past_key_values` is deprecated and will be removed in Transformers v4.53.0. "
"You should pass an instance of `Cache` instead, e.g. "
"`past_key_values=DynamicCache.from_legacy_cache(past_key_values)`."
)
past_key_values = DynamicCache.from_legacy_cache(past_key_values)
elif past_key_values is None:
past_key_values = DynamicCache(config=self.config)
Comment on lines -580 to -581
Copy link
Member

Choose a reason for hiding this comment

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

Why did we end up with twice the same branch? 😆😆 Thanks for removing!


if self.config.add_cross_attention and not isinstance(past_key_values, EncoderDecoderCache):
past_key_values = EncoderDecoderCache(past_key_values, DynamicCache(config=self.config))
Expand Down
4 changes: 0 additions & 4 deletions src/transformers/models/falcon/modeling_falcon.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,10 +760,6 @@ def forward(
if inputs_embeds is None:
inputs_embeds = self.word_embeddings(input_ids)

# TODO (joao): remove this exception in v4.56 -- it exists for users that try to pass a legacy cache
if not isinstance(past_key_values, (type(None), Cache)):
raise ValueError("The `past_key_values` should be either a `Cache` object or `None`.")

if use_cache and past_key_values is None:
past_key_values = DynamicCache(config=self.config)

Expand Down
13 changes: 0 additions & 13 deletions src/transformers/models/gemma3/configuration_gemma3.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import warnings
from typing import Any, Optional, Union

from ...configuration_utils import PretrainedConfig, layer_type_validation
Expand Down Expand Up @@ -241,18 +240,6 @@ def __init__(
]
layer_type_validation(self.layer_types)

@property
def sliding_window_pattern(self):
warnings.warn(
"The `sliding_window_pattern` attribute is deprecated and will be removed in v4.55.0.",
FutureWarning,
)
return self._sliding_window_pattern

@sliding_window_pattern.setter
def sliding_window_pattern(self, value):
self._sliding_window_pattern = value


class Gemma3Config(PretrainedConfig):
r"""
Expand Down
13 changes: 0 additions & 13 deletions src/transformers/models/gemma3/modular_gemma3.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import copy
import warnings
from collections.abc import Callable
from typing import Any, Optional, Union

Expand Down Expand Up @@ -252,18 +251,6 @@ def __init__(
]
layer_type_validation(self.layer_types)

@property
def sliding_window_pattern(self):
warnings.warn(
"The `sliding_window_pattern` attribute is deprecated and will be removed in v4.55.0.",
FutureWarning,
)
return self._sliding_window_pattern

@sliding_window_pattern.setter
def sliding_window_pattern(self, value):
self._sliding_window_pattern = value


class Gemma3Config(PretrainedConfig):
r"""
Expand Down
4 changes: 0 additions & 4 deletions src/transformers/models/git/modeling_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,6 @@ def forward(
)
use_cache = False

# TODO (joao): remove this exception in v4.56 -- it exists for users that try to pass a legacy cache
if not isinstance(past_key_values, (type(None), Cache)):
raise ValueError("The `past_key_values` should be either a `Cache` object or `None`.")

if use_cache and past_key_values is None:
past_key_values = DynamicCache(config=self.config)

Expand Down
18 changes: 2 additions & 16 deletions src/transformers/models/glm4v/modeling_glm4v.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,11 @@
from ...modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_update
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
from ...processing_utils import Unpack
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, is_torchdynamo_compiling, logging
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, is_torchdynamo_compiling
from ...utils.generic import check_model_inputs
from .configuration_glm4v import Glm4vConfig, Glm4vTextConfig, Glm4vVisionConfig


logger = logging.get_logger(__name__)


@use_kernel_forward_from_hub("RMSNorm")
class Glm4vRMSNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-6):
Expand Down Expand Up @@ -304,18 +301,7 @@ def forward(
query_states, key_states, value_states = (
self.qkv(hidden_states).reshape(seq_length, 3, self.num_heads, -1).permute(1, 0, 2, 3).unbind(0)
)
if position_embeddings is None:
logger.warning_once(
"The attention layers in this model are transitioning from computing the RoPE embeddings internally "
"through `rotary_pos_emb` (2D tensor of RoPE theta values), to using externally computed "
"`position_embeddings` (Tuple of tensors, containing cos and sin). In v4.54 `rotary_pos_emb` will be "
"removed and `position_embeddings` will be mandatory."
)
emb = torch.cat((rotary_pos_emb, rotary_pos_emb), dim=-1)
cos = emb.cos()
sin = emb.sin()
else:
cos, sin = position_embeddings
cos, sin = position_embeddings
query_states, key_states = apply_rotary_pos_emb_vision(query_states, key_states, cos, sin)

query_states = query_states.transpose(0, 1).unsqueeze(0)
Expand Down
18 changes: 2 additions & 16 deletions src/transformers/models/glm4v_moe/modeling_glm4v_moe.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,12 @@
from ...modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_update
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
from ...processing_utils import Unpack
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, is_torchdynamo_compiling, logging
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, is_torchdynamo_compiling
from ...utils.deprecation import deprecate_kwarg
from ...utils.generic import check_model_inputs
from .configuration_glm4v_moe import Glm4vMoeConfig, Glm4vMoeTextConfig, Glm4vMoeVisionConfig


logger = logging.get_logger(__name__)


@use_kernel_forward_from_hub("RMSNorm")
class Glm4vMoeRMSNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-6):
Expand Down Expand Up @@ -648,18 +645,7 @@ def forward(
query_states, key_states, value_states = (
self.qkv(hidden_states).reshape(seq_length, 3, self.num_heads, -1).permute(1, 0, 2, 3).unbind(0)
)
if position_embeddings is None:
logger.warning_once(
"The attention layers in this model are transitioning from computing the RoPE embeddings internally "
"through `rotary_pos_emb` (2D tensor of RoPE theta values), to using externally computed "
"`position_embeddings` (Tuple of tensors, containing cos and sin). In v4.54 `rotary_pos_emb` will be "
"removed and `position_embeddings` will be mandatory."
)
emb = torch.cat((rotary_pos_emb, rotary_pos_emb), dim=-1)
cos = emb.cos()
sin = emb.sin()
else:
cos, sin = position_embeddings
cos, sin = position_embeddings
query_states, key_states = apply_rotary_pos_emb_vision(query_states, key_states, cos, sin)

query_states = query_states.transpose(0, 1).unsqueeze(0)
Expand Down
4 changes: 0 additions & 4 deletions src/transformers/models/gpt_neo/modeling_gpt_neo.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,10 +571,6 @@ def forward(
if inputs_embeds is None:
inputs_embeds = self.wte(input_ids)

# TODO (joao): remove this exception in v4.56 -- it exists for users that try to pass a legacy cache
if not isinstance(past_key_values, (type(None), Cache)):
raise ValueError("The `past_key_values` should be either a `Cache` object or `None`.")

if use_cache and past_key_values is None:
past_key_values = DynamicCache(config=self.config)

Expand Down
4 changes: 0 additions & 4 deletions src/transformers/models/gpt_neox/modeling_gpt_neox.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,6 @@ def forward(
if inputs_embeds is None:
inputs_embeds = self.embed_in(input_ids)

# TODO (joao): remove this exception in v4.56 -- it exists for users that try to pass a legacy cache
if not isinstance(past_key_values, (type(None), Cache)):
raise ValueError("The `past_key_values` should be either a `Cache` object or `None`.")

if use_cache and past_key_values is None:
past_key_values = DynamicCache(config=self.config)

Expand Down
4 changes: 0 additions & 4 deletions src/transformers/models/gpt_neox/modular_gpt_neox.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,6 @@ def forward(
if inputs_embeds is None:
inputs_embeds = self.embed_in(input_ids)

# TODO (joao): remove this exception in v4.56 -- it exists for users that try to pass a legacy cache
if not isinstance(past_key_values, (type(None), Cache)):
raise ValueError("The `past_key_values` should be either a `Cache` object or `None`.")

if use_cache and past_key_values is None:
past_key_values = DynamicCache(config=self.config)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,10 +450,6 @@ def forward(
if inputs_embeds is None:
inputs_embeds = self.embed_in(input_ids)

# TODO (joao): remove this exception in v4.56 -- it exists for users that try to pass a legacy cache
if not isinstance(past_key_values, (type(None), Cache)):
raise ValueError("The `past_key_values` should be either a `Cache` object or `None`.")

if use_cache and past_key_values is None:
past_key_values = DynamicCache(config=self.config)

Expand Down
4 changes: 0 additions & 4 deletions src/transformers/models/gptj/modeling_gptj.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,10 +654,6 @@ def forward(
if inputs_embeds is None:
inputs_embeds = self.wte(input_ids)

# TODO (joao): remove this exception in v4.56 -- it exists for users that try to pass a legacy cache
if not isinstance(past_key_values, (type(None), Cache)):
raise ValueError("The `past_key_values` should be either a `Cache` object or `None`.")

if use_cache and past_key_values is None:
past_key_values = DynamicCache(config=self.config)

Expand Down
4 changes: 0 additions & 4 deletions src/transformers/models/granitemoe/modeling_granitemoe.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,10 +673,6 @@ def forward(

inputs_embeds = inputs_embeds * self.embedding_multiplier

# TODO (joao): remove this exception in v4.56 -- it exists for users that try to pass a legacy cache
if not isinstance(past_key_values, (type(None), Cache)):
raise ValueError("The `past_key_values` should be either a `Cache` object or `None`.")

if use_cache and past_key_values is None:
past_key_values = DynamicCache(config=self.config)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -649,10 +649,6 @@ def forward(

inputs_embeds = inputs_embeds * self.embedding_multiplier

# TODO (joao): remove this exception in v4.56 -- it exists for users that try to pass a legacy cache
if not isinstance(past_key_values, (type(None), Cache)):
raise ValueError("The `past_key_values` should be either a `Cache` object or `None`.")

if use_cache and past_key_values is None:
past_key_values = DynamicCache(config=self.config)

Expand Down
4 changes: 0 additions & 4 deletions src/transformers/models/idefics/modeling_idefics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1048,10 +1048,6 @@ def forward(
if inputs_embeds is None:
inputs_embeds = self.embed_tokens(input_ids)

# TODO (joao): remove this exception in v4.56 -- it exists for users that try to pass a legacy cache
if not isinstance(past_key_values, (type(None), Cache)):
raise ValueError("The `past_key_values` should be either a `Cache` object or `None`.")

if use_cache and past_key_values is None:
past_key_values = DynamicCache(config=self.config)

Expand Down
4 changes: 0 additions & 4 deletions src/transformers/models/idefics2/modeling_idefics2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1053,10 +1053,6 @@ def forward(
else:
raise ValueError("You have to specify either input_ids or inputs_embeds")

# TODO (joao): remove this exception in v4.56 -- it exists for users that try to pass a legacy cache
if not isinstance(past_key_values, (type(None), Cache)):
raise ValueError("The `past_key_values` should be either a `Cache` object or `None`.")

if use_cache and past_key_values is None:
past_key_values = DynamicCache(config=self.config)

Expand Down
4 changes: 0 additions & 4 deletions src/transformers/models/jetmoe/modeling_jetmoe.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,10 +921,6 @@ def forward(
if inputs_embeds is None:
inputs_embeds = self.embed_tokens(input_ids)

# TODO (joao): remove this exception in v4.56 -- it exists for users that try to pass a legacy cache
if not isinstance(past_key_values, (type(None), Cache)):
raise ValueError("The `past_key_values` should be either a `Cache` object or `None`.")

if use_cache and past_key_values is None:
past_key_values = DynamicCache(config=self.config)

Expand Down
Loading