Skip to content

Commit e465c7f

Browse files
authored
Upgrade transformers to 4.47 for ipex (huggingface#1113)
* upgrade transformers to 4.47 version; upgrade xpu to 2.5 version in Dockerfile Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com> * upgrade to transformers 4.47 Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com> * update transformers version in CI Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com> --------- Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com>
1 parent 61d85f7 commit e465c7f

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

.github/workflows/test_ipex.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
transformers-version: ["4.46.0", "4.46.3"]
21+
transformers-version: ["4.47.0", "4.47.1"]
2222
torch-version: ["2.4.0", "2.5.*"]
2323

2424
runs-on: ubuntu-22.04

Dockerfile.ipex

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ ARG KMP_HW_SUBSET=1T
4343
ENV KMP_HW_SUBSET=${KMP_HW_SUBSET}
4444
ENV LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libtcmalloc.so"
4545

46-
FROM intel/intel-extension-for-pytorch:2.3.110-xpu as xpu
46+
FROM intel/intel-extension-for-pytorch:2.5.10-xpu as xpu
4747
WORKDIR /usr/src/
4848

4949
RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \

optimum/exporters/ipex/cache_utils.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,23 @@ class IPEXPagedCache(Cache):
3434
def __init__(
3535
self,
3636
config: PretrainedConfig,
37-
batch_size: int,
37+
max_batch_size: int,
3838
max_cache_len: int,
3939
device,
4040
dtype=None,
4141
layer_device_map=None,
4242
**kwargs,
4343
) -> None:
4444
super().__init__()
45-
self.batch_size = batch_size
45+
self.max_batch_size = max_batch_size
4646
# Used in `generate` to keep tally of how many tokens the cache has seen
47-
self._seen_tokens = torch.zeros([batch_size], dtype=torch.int32, device=device)
47+
48+
self._seen_tokens = torch.zeros([max_batch_size], dtype=torch.int32, device=device)
4849
default_block_size = 16 if device.type == "cpu" else 64
4950
self.block_size = int(os.environ.get("OI_PAGED_ATTN_BLOCK_SIZE", str(default_block_size)))
50-
self.num_blocks = (max_cache_len // self.block_size + (max_cache_len % self.block_size != 0)) * batch_size
51+
self.num_blocks = (max_cache_len // self.block_size + (max_cache_len % self.block_size != 0)) * max_batch_size
5152
self.block_tables = -1 * torch.ones([self.num_blocks], dtype=torch.int32, device=device).reshape(
52-
batch_size, -1
53+
max_batch_size, -1
5354
)
5455
self.free_blocks = torch.ones([self.num_blocks], dtype=torch.int32, device=device)
5556
self.max_cache_len = max_cache_len
@@ -193,7 +194,7 @@ def get_max_length(self) -> Optional[int]:
193194

194195
def reset(self):
195196
"""Resets the cache values while preserving the objects"""
196-
self._seen_tokens = torch.zeros([self.batch_size], dtype=torch.int32, device=self.block_tables.device)
197+
self._seen_tokens = torch.zeros([self.max_batch_size], dtype=torch.int32, device=self.block_tables.device)
197198
self.block_tables.fill_(-1)
198199
self.free_blocks = torch.ones([self.num_blocks], dtype=torch.int32, device=self.block_tables.device)
199200
self.max_seq_len = 0

optimum/exporters/ipex/model_patcher.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141

4242

4343
# Please also update in the setup.py and .github/workflows/test_ipex.yml if you change the transformers version
44-
_TRANSFORMERS_MIN_VERSION = "4.46.0"
45-
_TRANSFORMERS_MAX_VERSION = "4.46.99"
44+
_TRANSFORMERS_MIN_VERSION = "4.47.0"
45+
_TRANSFORMERS_MAX_VERSION = "4.47.99"
4646

4747
_IPEX_EXPORTED_GENERATION_TASKS = ("text-generation",)
4848

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"nncf": ["nncf>=2.14.0"],
6767
"openvino": ["nncf>=2.14.0", "openvino>=2024.5.0", "openvino-tokenizers>=2024.5.0"],
6868
"neural-compressor": ["neural-compressor[pt]>3.0", "accelerate", "transformers<4.46"],
69-
"ipex": ["intel-extension-for-pytorch>=2.4", "transformers>4.45,<4.47", "accelerate"],
69+
"ipex": ["intel-extension-for-pytorch>=2.4", "transformers>4.46,<4.48", "accelerate"],
7070
"diffusers": ["diffusers"],
7171
"quality": QUALITY_REQUIRE,
7272
"tests": TESTS_REQUIRE,

0 commit comments

Comments
 (0)