Skip to content

Commit ab11657

Browse files
wrap cpu warning in reference_compile
1 parent 46065d4 commit ab11657

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/transformers/models/modernbert/modeling_modernbert.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -671,10 +671,11 @@ def _maybe_set_compile(self):
671671
self.config.reference_compile = False
672672

673673
if self.device.type == "cpu":
674-
logger.warning_once(
675-
"Compiling the model with `torch.compile` and using a `torch.cpu` device is not supported. "
676-
"Falling back to non-compiled mode."
677-
)
674+
if self.config.reference_compile:
675+
logger.warning_once(
676+
"Compiling the model with `torch.compile` and using a `torch.cpu` device is not supported. "
677+
"Falling back to non-compiled mode."
678+
)
678679
self.config.reference_compile = False
679680

680681
if self.config.reference_compile is None:

src/transformers/models/modernbert/modular_modernbert.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -901,10 +901,11 @@ def _maybe_set_compile(self):
901901
self.config.reference_compile = False
902902

903903
if self.device.type == "cpu":
904-
logger.warning_once(
905-
"Compiling the model with `torch.compile` and using a `torch.cpu` device is not supported. "
906-
"Falling back to non-compiled mode."
907-
)
904+
if self.config.reference_compile:
905+
logger.warning_once(
906+
"Compiling the model with `torch.compile` and using a `torch.cpu` device is not supported. "
907+
"Falling back to non-compiled mode."
908+
)
908909
self.config.reference_compile = False
909910

910911
if self.config.reference_compile is None:

0 commit comments

Comments
 (0)