eustlb HF Staff commited on
Commit
6ac3e3d
·
1 Parent(s): 0137f39

ensure BC with v4

Browse files
Files changed (1) hide show
  1. ultravox_model.py +10 -2
ultravox_model.py CHANGED
@@ -427,7 +427,11 @@ class UltravoxModel(transformers.LlamaPreTrainedModel, GenerationMixin):
427
  # But potentially other kwargs can be passed in. TODO
428
  kwargs = {"torch_dtype": config.torch_dtype}
429
  _default_device = getattr(torch, "get_default_device", lambda: None)()
430
- _is_init = _default_device is None or _default_device.type != "meta"
 
 
 
 
431
  if (
432
  _is_init
433
  and config.audio_model_id is not None
@@ -483,7 +487,11 @@ class UltravoxModel(transformers.LlamaPreTrainedModel, GenerationMixin):
483
  cls, config: UltravoxConfig
484
  ) -> transformers.LlamaForCausalLM:
485
  _default_device = getattr(torch, "get_default_device", lambda: None)()
486
- _is_init = _default_device is None or _default_device.type != "meta"
 
 
 
 
487
  if (
488
  _is_init
489
  and config.text_model_id is not None
 
427
  # But potentially other kwargs can be passed in. TODO
428
  kwargs = {"torch_dtype": config.torch_dtype}
429
  _default_device = getattr(torch, "get_default_device", lambda: None)()
430
+ _is_init = (
431
+ (hasattr(transformers.modeling_utils, "_init_weights") and transformers.modeling_utils._init_weights)
432
+ or _default_device is None
433
+ or _default_device.type != "meta"
434
+ )
435
  if (
436
  _is_init
437
  and config.audio_model_id is not None
 
487
  cls, config: UltravoxConfig
488
  ) -> transformers.LlamaForCausalLM:
489
  _default_device = getattr(torch, "get_default_device", lambda: None)()
490
+ _is_init = (
491
+ (hasattr(transformers.modeling_utils, "_init_weights") and transformers.modeling_utils._init_weights)
492
+ or _default_device is None
493
+ or _default_device.type != "meta"
494
+ )
495
  if (
496
  _is_init
497
  and config.text_model_id is not None