From db98a90dc2810acb3d2fb70b36106be155c37068 Mon Sep 17 00:00:00 2001 From: "Liu, Kaixuan" Date: Tue, 14 Jan 2025 13:11:42 -0500 Subject: [PATCH 1/3] upgrade transformers to 4.47 version; upgrade xpu to 2.5 version in Dockerfile Signed-off-by: Liu, Kaixuan --- Dockerfile.ipex | 2 +- optimum/exporters/ipex/model_patcher.py | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile.ipex b/Dockerfile.ipex index a03b1d26a3..9b41dec344 100644 --- a/Dockerfile.ipex +++ b/Dockerfile.ipex @@ -43,7 +43,7 @@ ARG KMP_HW_SUBSET=1T ENV KMP_HW_SUBSET=${KMP_HW_SUBSET} ENV LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libtcmalloc.so" -FROM intel/intel-extension-for-pytorch:2.3.110-xpu as xpu +FROM intel/intel-extension-for-pytorch:2.5.10-xpu as xpu WORKDIR /usr/src/ RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \ diff --git a/optimum/exporters/ipex/model_patcher.py b/optimum/exporters/ipex/model_patcher.py index 03937754a6..392f305ebf 100644 --- a/optimum/exporters/ipex/model_patcher.py +++ b/optimum/exporters/ipex/model_patcher.py @@ -41,7 +41,7 @@ # Please also update in the setup.py and .github/workflows/test_ipex.yml if you change the transformers version _TRANSFORMERS_MIN_VERSION = "4.46.0" -_TRANSFORMERS_MAX_VERSION = "4.46.99" +_TRANSFORMERS_MAX_VERSION = "4.47.99" _IPEX_EXPORTED_GENERATION_TASKS = ("text-generation",) diff --git a/setup.py b/setup.py index 0f02ef15cf..bfb2747474 100644 --- a/setup.py +++ b/setup.py @@ -66,7 +66,7 @@ "nncf": ["nncf>=2.14.0"], "openvino": ["nncf>=2.14.0", "openvino>=2024.5.0", "openvino-tokenizers>=2024.5.0"], "neural-compressor": ["neural-compressor[pt]>3.0", "accelerate", "transformers<4.46"], - "ipex": ["intel-extension-for-pytorch>=2.4", "transformers>4.45,<4.47", "accelerate"], + "ipex": ["intel-extension-for-pytorch>=2.4", "transformers>4.45,<4.48", "accelerate"], "diffusers": ["diffusers"], "quality": QUALITY_REQUIRE, "tests": TESTS_REQUIRE, From 63f3b8daf0f0ab571b89f77b32d0614a8b1855f2 Mon Sep 17 00:00:00 2001 From: "Liu, Kaixuan" Date: Thu, 16 Jan 2025 14:23:38 -0500 Subject: [PATCH 2/3] upgrade to transformers 4.47 Signed-off-by: Liu, Kaixuan --- optimum/exporters/ipex/cache_utils.py | 12 ++++++------ optimum/exporters/ipex/model_patcher.py | 2 +- setup.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/optimum/exporters/ipex/cache_utils.py b/optimum/exporters/ipex/cache_utils.py index 91821989fd..c20c136ffd 100755 --- a/optimum/exporters/ipex/cache_utils.py +++ b/optimum/exporters/ipex/cache_utils.py @@ -33,7 +33,7 @@ class IPEXPagedCache(Cache): def __init__( self, config: PretrainedConfig, - batch_size: int, + max_batch_size: int, max_cache_len: int, device, dtype=None, @@ -41,13 +41,13 @@ def __init__( **kwargs, ) -> None: super().__init__() - self.batch_size = batch_size + self.max_batch_size = max_batch_size # Used in `generate` to keep tally of how many tokens the cache has seen - self._seen_tokens = torch.zeros([batch_size], dtype=torch.int32, device=device) + self._seen_tokens = torch.zeros([max_batch_size], dtype=torch.int32, device=device) self.block_size = 16 - self.num_blocks = (max_cache_len // self.block_size + (max_cache_len % self.block_size != 0)) * batch_size + self.num_blocks = (max_cache_len // self.block_size + (max_cache_len % self.block_size != 0)) * max_batch_size self.block_tables = -1 * torch.ones([self.num_blocks], dtype=torch.int32, device=device).reshape( - batch_size, -1 + max_batch_size, -1 ) self.free_blocks = torch.ones([self.num_blocks], dtype=torch.int32, device=device) self.max_cache_len = max_cache_len @@ -191,7 +191,7 @@ def get_max_length(self) -> Optional[int]: def reset(self): """Resets the cache values while preserving the objects""" - self._seen_tokens = torch.zeros([self.batch_size], dtype=torch.int32, device=self.block_tables.device) + self._seen_tokens = torch.zeros([self.max_batch_size], dtype=torch.int32, device=self.block_tables.device) self.block_tables.fill_(-1) self.free_blocks = torch.ones([self.num_blocks], dtype=torch.int32, device=self.block_tables.device) self.max_seq_len = 0 diff --git a/optimum/exporters/ipex/model_patcher.py b/optimum/exporters/ipex/model_patcher.py index 392f305ebf..6ded5836e5 100644 --- a/optimum/exporters/ipex/model_patcher.py +++ b/optimum/exporters/ipex/model_patcher.py @@ -40,7 +40,7 @@ # Please also update in the setup.py and .github/workflows/test_ipex.yml if you change the transformers version -_TRANSFORMERS_MIN_VERSION = "4.46.0" +_TRANSFORMERS_MIN_VERSION = "4.47.0" _TRANSFORMERS_MAX_VERSION = "4.47.99" _IPEX_EXPORTED_GENERATION_TASKS = ("text-generation",) diff --git a/setup.py b/setup.py index bfb2747474..ab9226dcc2 100644 --- a/setup.py +++ b/setup.py @@ -66,7 +66,7 @@ "nncf": ["nncf>=2.14.0"], "openvino": ["nncf>=2.14.0", "openvino>=2024.5.0", "openvino-tokenizers>=2024.5.0"], "neural-compressor": ["neural-compressor[pt]>3.0", "accelerate", "transformers<4.46"], - "ipex": ["intel-extension-for-pytorch>=2.4", "transformers>4.45,<4.48", "accelerate"], + "ipex": ["intel-extension-for-pytorch>=2.4", "transformers>4.46,<4.48", "accelerate"], "diffusers": ["diffusers"], "quality": QUALITY_REQUIRE, "tests": TESTS_REQUIRE, From ff03f724c1cde4d7360caecf6f47e72954804e02 Mon Sep 17 00:00:00 2001 From: "Liu, Kaixuan" Date: Fri, 17 Jan 2025 05:39:54 -0500 Subject: [PATCH 3/3] update transformers version in CI Signed-off-by: Liu, Kaixuan --- .github/workflows/test_ipex.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_ipex.yml b/.github/workflows/test_ipex.yml index de933e3795..0aa881badc 100644 --- a/.github/workflows/test_ipex.yml +++ b/.github/workflows/test_ipex.yml @@ -18,7 +18,7 @@ jobs: strategy: fail-fast: false matrix: - transformers-version: ["4.46.0", "4.46.3"] + transformers-version: ["4.47.0", "4.47.1"] torch-version: ["2.4.0", "2.5.*"] runs-on: ubuntu-22.04