From 22319182abad03703a4604930588c790d7440614 Mon Sep 17 00:00:00 2001 From: Wing Lian Date: Sat, 7 Dec 2024 22:23:52 -0500 Subject: [PATCH] fix for auto_map check when using remote code and multipack for models like deepseek (#2151) [skip ci] --- src/axolotl/utils/models.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/axolotl/utils/models.py b/src/axolotl/utils/models.py index f2ee93c3c7..88a8aa581f 100644 --- a/src/axolotl/utils/models.py +++ b/src/axolotl/utils/models.py @@ -406,10 +406,14 @@ def apply_patches(self) -> None: and self.cfg.flash_attention and self.cfg.sample_packing ): - has_remote_code = ( - "auto_map" in self.model_config - and "AutoModelForCausalLM" in self.model_config["auto_map"] - ) + if "auto_map" in self.model_config: + try: + auto_map_config = self.model_config["auto_map"] + except TypeError: + auto_map_config = self.model_config.auto_map + has_remote_code = "AutoModelForCausalLM" in auto_map_config + else: + has_remote_code = False if has_remote_code and self.cfg.trust_remote_code is False: # if explicitly set in the YAML, we should prefer that, for example if explicitly disabled has_remote_code = self.cfg.trust_remote_code