Skip to content

Commit

Permalink
Fix warmup for xpu (#1090)
Browse files Browse the repository at this point in the history
* fix crash in warmup for xpu

Signed-off-by: Wang, Yi A <[email protected]>

* use recursive_to_device instead

Signed-off-by: Wang, Yi A <[email protected]>

---------

Signed-off-by: Wang, Yi A <[email protected]>
  • Loading branch information
sywangyi authored Dec 25, 2024
1 parent 87c431c commit 5fa9602
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions optimum/intel/generation/modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

from ..utils.constant import _TASK_ALIASES
from ..utils.import_utils import is_torch_version
from ..utils.modeling_utils import MULTI_QUERY_ATTN_MODELS
from ..utils.modeling_utils import MULTI_QUERY_ATTN_MODELS, recursive_to_device


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -63,7 +63,11 @@ def prepare_jit_inputs(model: PreTrainedModel, task: str, use_cache: bool = Fals

dummy_inputs = onnx_config.generate_dummy_inputs(framework="pt")

return {key: dummy_inputs[key] for key in signature.parameters if dummy_inputs.get(key, None) is not None}
return {
key: recursive_to_device(dummy_inputs[key], model.device)
for key in signature.parameters
if dummy_inputs.get(key, None) is not None
}


def jit_trace(model: PreTrainedModel, task: str, use_cache: bool = False):
Expand Down

0 comments on commit 5fa9602

Please sign in to comment.