Skip to content

feature: Hugging Face Transformers 4.12 for Pt1.9/TF2.5 #2752

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

Merged
merged 6 commits into from
Nov 12, 2021
Merged
Show file tree
Hide file tree
Changes from 5 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
149 changes: 145 additions & 4 deletions src/sagemaker/image_uri_config/huggingface.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"4.5": "4.5.0",
"4.6": "4.6.1",
"4.10": "4.10.2",
"4.11": "4.11.0"
"4.11": "4.11.0",
"4.12": "4.12.3"
},
"versions": {
"4.4.2": {
Expand Down Expand Up @@ -416,8 +417,7 @@
"repository": "huggingface-tensorflow-training",
"container_version": {"gpu": "cu112-ubuntu18.04"}
}
}
,
},
"4.11.0": {
"version_aliases": {
"pytorch1.9": "pytorch1.9.0",
Expand Down Expand Up @@ -487,6 +487,76 @@
"repository": "huggingface-tensorflow-training",
"container_version": {"gpu": "cu112-ubuntu18.04"}
}
},
"4.12.3": {
"version_aliases": {
"pytorch1.9": "pytorch1.9.1",
"tensorflow2.5": "tensorflow2.5.1"
},
"pytorch1.9.1": {
"py_versions": ["py38"],
"registries": {
"af-south-1": "626614931356",
"ap-east-1": "871362719292",
"ap-northeast-1": "763104351884",
"ap-northeast-2": "763104351884",
"ap-northeast-3": "364406365360",
"ap-south-1": "763104351884",
"ap-southeast-1": "763104351884",
"ap-southeast-2": "763104351884",
"ca-central-1": "763104351884",
"cn-north-1": "727897471807",
"cn-northwest-1": "727897471807",
"eu-central-1": "763104351884",
"eu-north-1": "763104351884",
"eu-west-1": "763104351884",
"eu-west-2": "763104351884",
"eu-west-3": "763104351884",
"eu-south-1": "692866216735",
"me-south-1": "217643126080",
"sa-east-1": "763104351884",
"us-east-1": "763104351884",
"us-east-2": "763104351884",
"us-gov-west-1": "442386744353",
"us-iso-east-1": "886529160074",
"us-west-1": "763104351884",
"us-west-2": "763104351884"
},
"repository": "huggingface-pytorch-training",
"container_version": {"gpu": "cu111-ubuntu20.04"}
},
"tensorflow2.5.1": {
"py_versions": ["py37"],
"registries": {
"af-south-1": "626614931356",
"ap-east-1": "871362719292",
"ap-northeast-1": "763104351884",
"ap-northeast-2": "763104351884",
"ap-northeast-3": "364406365360",
"ap-south-1": "763104351884",
"ap-southeast-1": "763104351884",
"ap-southeast-2": "763104351884",
"ca-central-1": "763104351884",
"cn-north-1": "727897471807",
"cn-northwest-1": "727897471807",
"eu-central-1": "763104351884",
"eu-north-1": "763104351884",
"eu-south-1": "692866216735",
"eu-west-1": "763104351884",
"eu-west-2": "763104351884",
"eu-west-3": "763104351884",
"me-south-1": "217643126080",
"sa-east-1": "763104351884",
"us-east-1": "763104351884",
"us-east-2": "763104351884",
"us-gov-west-1": "442386744353",
"us-iso-east-1": "886529160074",
"us-west-1": "763104351884",
"us-west-2": "763104351884"
},
"repository": "huggingface-tensorflow-training",
"container_version": {"gpu": "cu112-ubuntu18.04"}
}
}
}
},
Expand All @@ -496,7 +566,8 @@
"version_aliases": {
"4.6": "4.6.1",
"4.10": "4.10.2",
"4.11": "4.11.0"
"4.11": "4.11.0",
"4.12": "4.12.3"
},
"versions": {
"4.6.1": {
Expand Down Expand Up @@ -806,6 +877,76 @@
"repository": "huggingface-tensorflow-inference",
"container_version": {"gpu": "cu112-ubuntu18.04", "cpu": "ubuntu18.04" }
}
},
"4.12.3": {
"version_aliases": {
"pytorch1.9": "pytorch1.9.1",
"tensorflow2.5": "tensorflow2.5.1"
},
"pytorch1.9.1": {
"py_versions": ["py38"],
"registries": {
"af-south-1": "626614931356",
"ap-east-1": "871362719292",
"ap-northeast-1": "763104351884",
"ap-northeast-2": "763104351884",
"ap-northeast-3": "364406365360",
"ap-south-1": "763104351884",
"ap-southeast-1": "763104351884",
"ap-southeast-2": "763104351884",
"ca-central-1": "763104351884",
"cn-north-1": "727897471807",
"cn-northwest-1": "727897471807",
"eu-central-1": "763104351884",
"eu-north-1": "763104351884",
"eu-west-1": "763104351884",
"eu-west-2": "763104351884",
"eu-west-3": "763104351884",
"eu-south-1": "692866216735",
"me-south-1": "217643126080",
"sa-east-1": "763104351884",
"us-east-1": "763104351884",
"us-east-2": "763104351884",
"us-gov-west-1": "442386744353",
"us-iso-east-1": "886529160074",
"us-west-1": "763104351884",
"us-west-2": "763104351884"
},
"repository": "huggingface-pytorch-inference",
"container_version": {"gpu": "cu111-ubuntu20.04", "cpu": "ubuntu20.04" }
},
"tensorflow2.5.1": {
"py_versions": ["py37"],
"registries": {
"af-south-1": "626614931356",
"ap-east-1": "871362719292",
"ap-northeast-1": "763104351884",
"ap-northeast-2": "763104351884",
"ap-northeast-3": "364406365360",
"ap-south-1": "763104351884",
"ap-southeast-1": "763104351884",
"ap-southeast-2": "763104351884",
"ca-central-1": "763104351884",
"cn-north-1": "727897471807",
"cn-northwest-1": "727897471807",
"eu-central-1": "763104351884",
"eu-north-1": "763104351884",
"eu-south-1": "692866216735",
"eu-west-1": "763104351884",
"eu-west-2": "763104351884",
"eu-west-3": "763104351884",
"me-south-1": "217643126080",
"sa-east-1": "763104351884",
"us-east-1": "763104351884",
"us-east-2": "763104351884",
"us-gov-west-1": "442386744353",
"us-iso-east-1": "886529160074",
"us-west-1": "763104351884",
"us-west-2": "763104351884"
},
"repository": "huggingface-tensorflow-inference",
"container_version": {"gpu": "cu112-ubuntu18.04", "cpu": "ubuntu18.04" }
}
}
}
}
Expand Down
25 changes: 17 additions & 8 deletions tests/data/huggingface/run_tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from datasets import load_dataset

from transformers import AutoTokenizer, TFAutoModelForSequenceClassification
import transformers


if __name__ == "__main__":
Expand Down Expand Up @@ -57,10 +58,14 @@
)
train_dataset.set_format(type="tensorflow", columns=["input_ids", "attention_mask", "label"])

train_features = {
x: train_dataset[x].to_tensor(default_value=0, shape=[None, tokenizer.model_max_length])
for x in ["input_ids", "attention_mask"]
}
if transformers.__version__ > "4.12.0":
train_features = {x: train_dataset[x] for x in ["input_ids", "attention_mask"]}
else:
train_features = {
x: train_dataset[x].to_tensor(default_value=0, shape=[None, tokenizer.model_max_length])
for x in ["input_ids", "attention_mask"]
}

tf_train_dataset = tf.data.Dataset.from_tensor_slices(
(train_features, train_dataset["label"])
).batch(args.per_device_train_batch_size)
Expand All @@ -71,10 +76,14 @@
)
test_dataset.set_format(type="tensorflow", columns=["input_ids", "attention_mask", "label"])

test_features = {
x: test_dataset[x].to_tensor(default_value=0, shape=[None, tokenizer.model_max_length])
for x in ["input_ids", "attention_mask"]
}
if transformers.__version__ > "4.12.0":
test_features = {x: test_dataset[x] for x in ["input_ids", "attention_mask"]}
else:
test_features = {
x: test_dataset[x].to_tensor(default_value=0, shape=[None, tokenizer.model_max_length])
for x in ["input_ids", "attention_mask"]
}

tf_test_dataset = tf.data.Dataset.from_tensor_slices(
(test_features, test_dataset["label"])
).batch(args.per_device_eval_batch_size)
Expand Down
2 changes: 1 addition & 1 deletion tests/integ/test_huggingface.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def test_huggingface_inference(
huggingface_pytorch_latest_inference_py_version,
):
env = {
"HF_MODEL_ID": "sshleifer/tiny-distilbert-base-uncased-finetuned-sst-2-english",
"HF_MODEL_ID": "philschmid/tiny-distilbert-classification",
Copy link
Contributor

Choose a reason for hiding this comment

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

@philschmid Can we please give this a generic name to this model?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure what you mean by that. That is not a model which will be created it is stored on the hf.co/models hub and used to run tests. I changed it because to a model which we can control. https://huggingface.co/philschmid/tiny-distilbert-classification.

"HF_TASK": "text-classification",
}
endpoint_name = unique_name_from_base("test-hf-inference")
Expand Down