diff --git a/.github/workflows/test_inf1.yml b/.github/workflows/test_inf1.yml index 8b6638098..780d4df3f 100644 --- a/.github/workflows/test_inf1.yml +++ b/.github/workflows/test_inf1.yml @@ -42,16 +42,16 @@ jobs: - name: Run CLI tests run: | source aws_neuron_venv_pytorch/bin/activate - HF_TOKEN_OPTIMUM_NEURON_CI=${{ secrets.HF_TOKEN_OPTIMUM_NEURON_CI }} pytest -m is_inferentia_test tests/cli + HF_TOKEN=${{ secrets.HF_TOKEN_OPTIMUM_NEURON_CI }} pytest -m is_inferentia_test tests/cli - name: Run export tests run: | source aws_neuron_venv_pytorch/bin/activate - HF_TOKEN_OPTIMUM_NEURON_CI=${{ secrets.HF_TOKEN_OPTIMUM_NEURON_CI }} pytest -m is_inferentia_test tests/exporters + HF_TOKEN=${{ secrets.HF_TOKEN_OPTIMUM_NEURON_CI }} pytest -m is_inferentia_test tests/exporters - name: Run inference tests run: | source aws_neuron_venv_pytorch/bin/activate - HF_TOKEN_OPTIMUM_NEURON_CI=${{ secrets.HF_TOKEN_OPTIMUM_NEURON_CI }} pytest -m is_inferentia_test tests/inference + HF_TOKEN=${{ secrets.HF_TOKEN_OPTIMUM_NEURON_CI }} pytest -m is_inferentia_test tests/inference - name: Run pipelines tests run: | source aws_neuron_venv_pytorch/bin/activate - HF_TOKEN_OPTIMUM_NEURON_CI=${{ secrets.HF_TOKEN_OPTIMUM_NEURON_CI }} pytest -m is_inferentia_test tests/pipelines + HF_TOKEN=${{ secrets.HF_TOKEN_OPTIMUM_NEURON_CI }} pytest -m is_inferentia_test tests/pipelines diff --git a/.github/workflows/test_inf2.yml b/.github/workflows/test_inf2.yml index 24de447e9..e6db238ca 100644 --- a/.github/workflows/test_inf2.yml +++ b/.github/workflows/test_inf2.yml @@ -38,20 +38,20 @@ jobs: - name: Run CLI tests run: | source aws_neuron_venv_pytorch/bin/activate - HF_TOKEN_OPTIMUM_NEURON_CI=${{ secrets.HF_TOKEN_OPTIMUM_NEURON_CI }} pytest -m is_inferentia_test tests/cli + HF_TOKEN=${{ secrets.HF_TOKEN_OPTIMUM_NEURON_CI }} pytest -m is_inferentia_test tests/cli - name: Run exporters tests run: | source aws_neuron_venv_pytorch/bin/activate - HF_TOKEN_OPTIMUM_NEURON_CI=${{ secrets.HF_TOKEN_OPTIMUM_NEURON_CI }} pytest -m is_inferentia_test tests/exporters + HF_TOKEN=${{ secrets.HF_TOKEN_OPTIMUM_NEURON_CI }} pytest -m is_inferentia_test tests/exporters - name: Run inference tests run: | source aws_neuron_venv_pytorch/bin/activate - HF_TOKEN_OPTIMUM_NEURON_CI=${{ secrets.HF_TOKEN_OPTIMUM_NEURON_CI }} pytest -m is_inferentia_test tests/inference + HF_TOKEN=${{ secrets.HF_TOKEN_OPTIMUM_NEURON_CI }} pytest -m is_inferentia_test tests/inference - name: Run generation tests run: | source aws_neuron_venv_pytorch/bin/activate - HF_TOKEN_OPTIMUM_NEURON_CI=${{ secrets.HF_TOKEN_OPTIMUM_NEURON_CI }} pytest -m is_inferentia_test tests/generation + HF_TOKEN=${{ secrets.HF_TOKEN_OPTIMUM_NEURON_CI }} pytest -m is_inferentia_test tests/generation - name: Run pipelines tests run: | source aws_neuron_venv_pytorch/bin/activate - HF_TOKEN_OPTIMUM_NEURON_CI=${{ secrets.HF_TOKEN_OPTIMUM_NEURON_CI }} pytest -m is_inferentia_test tests/pipelines + HF_TOKEN=${{ secrets.HF_TOKEN_OPTIMUM_NEURON_CI }} pytest -m is_inferentia_test tests/pipelines diff --git a/.github/workflows/test_trainium_common.yml b/.github/workflows/test_trainium_common.yml index b1f2a4155..e665aefa1 100644 --- a/.github/workflows/test_trainium_common.yml +++ b/.github/workflows/test_trainium_common.yml @@ -36,6 +36,6 @@ jobs: run: pip install .[tests,neuronx] - name: Run tests on Neuron cores run: | - HF_TOKEN_OPTIMUM_NEURON_CI=${{ secrets.HF_TOKEN_OPTIMUM_NEURON_CI }} USE_VENV="false" pytest -m "is_trainium_test" $TESTS_TO_IGNORE_FLAGS tests + HF_TOKEN=${{ secrets.HF_TOKEN_OPTIMUM_NEURON_CI }} USE_VENV="false" pytest -m "is_trainium_test" $TESTS_TO_IGNORE_FLAGS tests - name: Run staging tests on Neuron cores run: HUGGINGFACE_CO_STAGING=1 pytest -m "is_trainium_test and is_staging_test" $TESTS_TO_IGNORE_FLAGS tests -s diff --git a/.github/workflows/test_trainium_distributed.yml b/.github/workflows/test_trainium_distributed.yml index 2b242a442..1c2ebf3e8 100644 --- a/.github/workflows/test_trainium_distributed.yml +++ b/.github/workflows/test_trainium_distributed.yml @@ -35,5 +35,5 @@ jobs: run: pip install .[tests,neuronx] - name: Run tests on Neuron cores run: | - HF_TOKEN_OPTIMUM_NEURON_CI=${{ secrets.HF_TOKEN_OPTIMUM_NEURON_CI }} pytest -m "is_trainium_test" tests/distributed/ + HF_TOKEN=${{ secrets.HF_TOKEN_OPTIMUM_NEURON_CI }} pytest -m "is_trainium_test" tests/distributed/ diff --git a/.github/workflows/test_trainium_examples.yml b/.github/workflows/test_trainium_examples.yml index 6b648c9ae..18386db27 100644 --- a/.github/workflows/test_trainium_examples.yml +++ b/.github/workflows/test_trainium_examples.yml @@ -75,7 +75,7 @@ jobs: run: pip install .[tests,neuronx] - name: Run example tests on Neuron cores run: | - HF_TOKEN_OPTIMUM_NEURON_CI=${{ secrets.HF_TOKEN_OPTIMUM_NEURON_CI }} USE_VENV=false COVERAGE=${{ github.event.inputs.priority }} RUN_TINY=$RUN_TINY RUN_SLOW=1 pytest -m "is_trainium_test" tests/test_examples.py -v + HF_TOKEN=${{ secrets.HF_TOKEN_OPTIMUM_NEURON_CI }} USE_VENV=false COVERAGE=${{ github.event.inputs.priority }} RUN_TINY=$RUN_TINY RUN_SLOW=1 pytest -m "is_trainium_test" tests/test_examples.py -v stop-runner: name: Stop self-hosted EC2 runner needs: diff --git a/optimum/neuron/pipelines/diffusers/pipeline_stable_diffusion_inpaint.py b/optimum/neuron/pipelines/diffusers/pipeline_stable_diffusion_inpaint.py index 79768b220..a00de9ba8 100644 --- a/optimum/neuron/pipelines/diffusers/pipeline_stable_diffusion_inpaint.py +++ b/optimum/neuron/pipelines/diffusers/pipeline_stable_diffusion_inpaint.py @@ -185,6 +185,8 @@ def __call__( # 1. Check inputs self.check_inputs( prompt, + image, + mask_image, height, width, strength, diff --git a/setup.py b/setup.py index 844165c37..ed4490c91 100644 --- a/setup.py +++ b/setup.py @@ -13,10 +13,10 @@ INSTALL_REQUIRES = [ - "transformers == 4.35.0", + "transformers == 4.36.2", "accelerate == 0.23.0", "optimum >= 1.14.0", - "huggingface_hub >= 0.14.0", + "huggingface_hub >= 0.20.1", "numpy>=1.22.2, <=1.25.2", "protobuf<4", ] @@ -29,7 +29,7 @@ "sentencepiece", "datasets", "sacremoses", - "diffusers >= 0.23.0", + "diffusers >= 0.25.0", "safetensors", ] diff --git a/tests/inference/inference_utils.py b/tests/inference/inference_utils.py index 41a56137e..8d4331ce4 100644 --- a/tests/inference/inference_utils.py +++ b/tests/inference/inference_utils.py @@ -13,15 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os import shutil import tempfile import unittest from io import BytesIO from typing import Dict +import huggingface_hub import requests -from huggingface_hub import HfFolder from PIL import Image from transformers import set_seed @@ -61,12 +60,7 @@ class NeuronModelIntegrationTestMixin(unittest.TestCase): @classmethod def setUpClass(cls): - if os.environ.get("HF_TOKEN_OPTIMUM_NEURON_CI", None) is not None: - token = os.environ.get("HF_TOKEN_OPTIMUM_NEURON_CI") - HfFolder.save_token(token) - else: - raise RuntimeError("Please specify the token via the HF_TOKEN_OPTIMUM_NEURON_CI environment variable.") - cls._token = HfFolder.get_token() + cls._token = huggingface_hub.get_token() model_name = cls.MODEL_ID.split("/")[-1] model_dir = tempfile.mkdtemp(prefix=f"{model_name}_") @@ -82,8 +76,6 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - if cls._token is not None: - HfFolder.save_token(cls._token) if cls.local_model_path is not None: shutil.rmtree(cls.local_model_path) diff --git a/tests/test_examples.py b/tests/test_examples.py index 2850275fb..149486e65 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -24,7 +24,7 @@ from typing import Any, Callable, Dict, List, Optional, Set, Tuple, TypeVar, Union from unittest import TestCase -from huggingface_hub import HfFolder +import huggingface_hub from transformers import ( CONFIG_MAPPING, MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING, @@ -56,9 +56,7 @@ TypeOrDictOfType = Union[T, Dict[str, T]] -TOKEN = HfFolder.get_token() -if os.environ.get("HF_TOKEN_OPTIMUM_NEURON_CI", None) is not None: - TOKEN = os.environ.get("HF_TOKEN_OPTIMUM_NEURON_CI") +TOKEN = huggingface_hub.get_token() DEFAULT_CACHE_REPO = "optimum-internal-testing/optimum-neuron-cache-for-testing" SAVED_CUSTOM_CACHE_REPO = load_custom_cache_repo_name_from_hf_home() diff --git a/tests/test_runner.py b/tests/test_runner.py index 4201fbd44..56c18dc38 100644 --- a/tests/test_runner.py +++ b/tests/test_runner.py @@ -17,7 +17,7 @@ import os from unittest import TestCase -from huggingface_hub import HfFolder +import huggingface_hub from parameterized import parameterized from optimum.neuron.utils.cache_utils import ( @@ -58,21 +58,14 @@ class TestExampleRunner(TestCase): @classmethod def setUpClass(cls): - cls._token = HfFolder.get_token() + cls._token = huggingface_hub.get_token() cls._cache_repo = load_custom_cache_repo_name_from_hf_home() cls._env = dict(os.environ) - if os.environ.get("HF_TOKEN_OPTIMUM_NEURON_CI", None) is not None: - token = os.environ.get("HF_TOKEN_OPTIMUM_NEURON_CI") - HfFolder.save_token(token) - set_custom_cache_repo_name_in_hf_home(cls.CACHE_REPO_NAME) - else: - raise RuntimeError("Please specify the token via the HF_TOKEN_OPTIMUM_NEURON_CI environment variable.") + set_custom_cache_repo_name_in_hf_home(cls.CACHE_REPO_NAME) @classmethod def tearDownClass(cls): os.environ = cls._env - if cls._token is not None: - HfFolder.save_token(cls._token) if cls._cache_repo is not None: try: set_custom_cache_repo_name_in_hf_home(cls._cache_repo)