Fix bug
This commit is contained in:
parent
7a531b7c65
commit
be310cac1e
2 changed files with 9 additions and 3 deletions
|
|
@ -285,6 +285,8 @@ pass
|
|||
|
||||
# =============================================
|
||||
# Fix new Xformers versions TypeError: Multiple dispatch failed for 'torch._ops.aten.to.dtype_layout'
|
||||
accelerate_old_send_to_device = None
|
||||
accelerate_new_send_to_device = None
|
||||
if Version(xformers_version) >= Version("0.0.27"):
|
||||
import accelerate.utils.operations
|
||||
if hasattr(accelerate.utils.operations, "send_to_device") and \
|
||||
|
|
|
|||
|
|
@ -1371,8 +1371,10 @@ def _wrap_fast_inference(generate, device_type, dtype, model):
|
|||
internal_model._flag_for_generation = True
|
||||
|
||||
# Must patch accelerate for Xformers
|
||||
import accelerate.utils.operations
|
||||
accelerate.utils.operations.send_to_device = accelerate_new_send_to_device
|
||||
if accelerate_new_send_to_device is not None:
|
||||
import accelerate.utils.operations
|
||||
accelerate.utils.operations.send_to_device = accelerate_new_send_to_device
|
||||
pass
|
||||
|
||||
# For newer HF
|
||||
kwargs["cache_implementation"] = "dynamic"
|
||||
|
|
@ -1411,7 +1413,9 @@ def _wrap_fast_inference(generate, device_type, dtype, model):
|
|||
if hasattr(internal_model, "_flag_for_generation"): del internal_model._flag_for_generation
|
||||
|
||||
# Return accelerate back
|
||||
accelerate.utils.operations.send_to_device = accelerate_old_send_to_device
|
||||
if accelerate_new_send_to_device is not None:
|
||||
accelerate.utils.operations.send_to_device = accelerate_old_send_to_device
|
||||
pass
|
||||
|
||||
return output
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue