Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable transformers v4.47 support #2119

Merged
merged 6 commits into from
Dec 12, 2024
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
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"datasets>=1.2.1",
"evaluate",
"protobuf>=3.20.1",
"transformers>=4.36,<4.47.0",
"transformers>=4.36,<4.48.0",
],
"onnxruntime-gpu": [
"onnx",
Expand All @@ -60,19 +60,19 @@
"evaluate",
"protobuf>=3.20.1",
"accelerate", # ORTTrainer requires it.
"transformers>=4.36,<4.47.0",
"transformers>=4.36,<4.48.0",
],
"exporters": [
"onnx",
"onnxruntime",
"timm",
"transformers>=4.36,<4.47.0",
"transformers>=4.36,<4.48.0",
],
"exporters-gpu": [
"onnx",
"onnxruntime-gpu",
"timm",
"transformers>=4.36,<4.47.0",
"transformers>=4.36,<4.48.0",
],
"exporters-tf": [
"tensorflow>=2.4,<=2.12.1",
Expand Down
4 changes: 2 additions & 2 deletions tests/onnx/test_onnx_export_custom_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

if is_torch_available():
import torch
from transformers.models.deberta import modeling_deberta
from transformers.models.sew_d import modeling_sew_d
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

StableDropout was removed from modeling_deberta in huggingface/transformers#22105


from optimum.utils import check_if_torch_greater

Expand All @@ -36,7 +36,7 @@ def test_training(self):
"""Tests export of StableDropout in training mode."""
devnull = open(os.devnull, "wb")
# drop_prob must be > 0 for the test to be meaningful
sd = modeling_deberta.StableDropout(0.1)
sd = modeling_sew_d.StableDropout(0.1)
# Avoid warnings in training mode
do_constant_folding = False
# Dropout is a no-op in inference mode
Expand Down
24 changes: 8 additions & 16 deletions tests/test_configuration_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
# 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 os
import tempfile
import unittest

from huggingface_hub import HfFolder, delete_repo
from requests.exceptions import HTTPError
from transformers.testing_utils import TOKEN, USER, is_staging_test
from transformers.testing_utils import TOKEN, TemporaryHubRepo, is_staging_test

from optimum.configuration_utils import BaseConfig

Expand Down Expand Up @@ -69,28 +68,21 @@ def tearDownClass(cls):

def test_push_to_hub(self):
config = FakeConfig(attribute=15)
with tempfile.TemporaryDirectory() as tmp_dir:
config.save_pretrained(
os.path.join(tmp_dir, "optimum-test-base-config"), push_to_hub=True, token=self._token
)

new_config = FakeConfig.from_pretrained(f"{USER}/optimum-test-base-config")
with TemporaryHubRepo(token=self._token) as tmp_repo:
config.push_to_hub(tmp_repo.repo_id, token=self._token)

new_config = FakeConfig.from_pretrained(tmp_repo.repo_id)
for k, v in config.to_dict().items():
if k != "optimum_version" and k != "transformers_version":
self.assertEqual(v, getattr(new_config, k))

def test_push_to_hub_in_organization(self):
config = FakeConfig(attribute=15)

with tempfile.TemporaryDirectory() as tmp_dir:
config.save_pretrained(
os.path.join(tmp_dir, "optimum-test-base-config-org"),
push_to_hub=True,
token=self._token,
organization="valid_org",
)

new_config = FakeConfig.from_pretrained("valid_org/optimum-test-base-config-org")
with TemporaryHubRepo(namespace="valid_org", token=self._token) as tmp_repo:
config.push_to_hub(tmp_repo.repo_id, token=self._token)
new_config = FakeConfig.from_pretrained(tmp_repo.repo_id)
for k, v in config.to_dict().items():
if k != "optimum_version" and k != "transformers_version":
self.assertEqual(v, getattr(new_config, k))
Loading