From 0e7e42abd81f224db003813fc685d67c882d3a8b Mon Sep 17 00:00:00 2001 From: Disty0 Date: Tue, 2 Jan 2024 11:44:14 +0300 Subject: [PATCH] Update changelog --- CHANGELOG.md | 7 +++++-- modules/intel/ipex/diffusers.py | 4 ++-- modules/intel/ipex/hijacks.py | 10 +++++----- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a473ba58..53061c564 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,10 @@ And it also includes fixes for all reported issues so far example: `python cli/sdapi.py /sdapi/v1/sd-models` - memory: add ram usage monitoring in addition to gpu memory usage monitoring - updated core requirements +- **IPEX**, thanks @disty0 + - rewrote IPEX hijacks to get rid of CondFunc + - dropped IPEX 2.0 specific fixes, update to IPEX 2.1 + - add `IPEX_SDPA_SLICE_TRIGGER_RATE` and `IPEX_ATTENTION_SLICE_RATE` env variables - **Fixes** - ipadapter: allow changing of model/image on-the-fly - python: fix python 3.9 compatibility @@ -33,8 +37,7 @@ And it also includes fixes for all reported issues so far - sampler: guard against invalid sampler index - config: reset default cfg scale to 6.0 - processing: correct display metadata - - upscale: fix ldsr - - ipex: fix torch.load, thanks @Disty0 + - upscale: fix ldsr ## Update for 2023-12-29 diff --git a/modules/intel/ipex/diffusers.py b/modules/intel/ipex/diffusers.py index 617c12369..cf3d73dde 100644 --- a/modules/intel/ipex/diffusers.py +++ b/modules/intel/ipex/diffusers.py @@ -112,7 +112,7 @@ class SlicedAttnProcessor: # pylint: disable=too-few-public-methods for i in range(batch_size_attention // split_slice_size): start_idx = i * split_slice_size end_idx = (i + 1) * split_slice_size - if do_split_2: + if do_split_2 and query.device.type == "xpu": for i2 in range(query_tokens // split_2_slice_size): # pylint: disable=invalid-name start_idx_2 = i2 * split_2_slice_size end_idx_2 = (i2 + 1) * split_2_slice_size @@ -229,7 +229,7 @@ class AttnProcessor: hidden_states = torch.zeros(query.shape, device=query.device, dtype=query.dtype) do_split, do_split_2, do_split_3, split_slice_size, split_2_slice_size, split_3_slice_size = find_attention_slice_sizes(query.shape, query.element_size()) - if do_split: + if do_split and query.device.type == "xpu": for i in range(batch_size_attention // split_slice_size): start_idx = i * split_slice_size end_idx = (i + 1) * split_slice_size diff --git a/modules/intel/ipex/hijacks.py b/modules/intel/ipex/hijacks.py index 0e19e4d3e..4a44920e2 100644 --- a/modules/intel/ipex/hijacks.py +++ b/modules/intel/ipex/hijacks.py @@ -126,12 +126,12 @@ def torch_cat(tensor, *args, **kwargs): return original_torch_cat(tensor, *args, **kwargs) # SwinIR BF16: -original_funtional_pad = torch.nn.functional.pad -def funtional_pad(input, pad, mode='constant', value=None): +original_functional_pad = torch.nn.functional.pad +def functional_pad(input, pad, mode='constant', value=None): if mode == 'reflect' and input.dtype == torch.bfloat16: - return original_funtional_pad(input.to(torch.float32), pad, mode=mode, value=value).to(dtype=torch.bfloat16) + return original_functional_pad(input.to(torch.float32), pad, mode=mode, value=value).to(dtype=torch.bfloat16) else: - return original_funtional_pad(input, pad, mode=mode, value=value) + return original_functional_pad(input, pad, mode=mode, value=value) original_torch_tensor = torch.tensor @@ -244,7 +244,7 @@ def ipex_hijacks(): torch.nn.functional.linear = functional_linear torch.nn.functional.conv2d = functional_conv2d torch.nn.functional.interpolate = interpolate - torch.nn.functional.pad = funtional_pad + torch.nn.functional.pad = functional_pad torch.bmm = torch_bmm torch.cat = torch_cat