diff --git a/src/axolotl/loaders/model.py b/src/axolotl/loaders/model.py index fbf1117d8..3ebf291ad 100644 --- a/src/axolotl/loaders/model.py +++ b/src/axolotl/loaders/model.py @@ -163,6 +163,15 @@ class ModelLoader: # Build the model PLUGIN_MANAGER.pre_model_load(self.cfg) skip_move_to_device = self._build_model() + + # Check if the model is a GraniteConfig object + if hasattr(self, 'model') and self.model.__class__.__name__ == "GraniteConfig": + LOG.error("The model loaded is a GraniteConfig object, not a proper model.") + LOG.error("This is likely because the model type 'GraniteConfig' is not supported.") + LOG.error("Please use a different model type or ensure the model is properly configured.") + LOG.error("Setting trust_remote_code=True might help if the model requires custom code.") + raise ValueError("Model loaded is a GraniteConfig object, not a proper model. Use a supported model type or set trust_remote_code=True.") + PLUGIN_MANAGER.post_model_build(self.cfg, self.model) # Post-build model configuration diff --git a/src/axolotl/train.py b/src/axolotl/train.py index 3a206d3da..d16e127b6 100644 --- a/src/axolotl/train.py +++ b/src/axolotl/train.py @@ -80,6 +80,14 @@ def setup_model_and_tokenizer( model_loader = ModelLoader(cfg, tokenizer, processor=processor) model, peft_config = model_loader.load() + + # Check if model is actually a GraniteConfig object + if model.__class__.__name__ == "GraniteConfig": + LOG.error("The model loaded is a GraniteConfig object, not a proper model.") + LOG.error("This is likely because the model type 'GraniteConfig' is not supported.") + LOG.error("Please use a different model type or ensure the model is properly configured.") + raise ValueError("Model loaded is a GraniteConfig object, not a proper model. Use a supported model type.") + if hasattr(model, "generation_config") and model.generation_config is not None: model.generation_config.do_sample = True