jatingocodeo commited on
Commit
bbaff56
·
verified ·
1 Parent(s): 7276d4c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -51,6 +51,7 @@ class SmolLM2Config(PretrainedConfig):
51
 
52
  class SmolLM2ForCausalLM(PreTrainedModel):
53
  config_class = SmolLM2Config
 
54
 
55
  def __init__(self, config):
56
  super().__init__(config)
@@ -94,12 +95,17 @@ def load_model():
94
  }
95
  tokenizer.add_special_tokens(special_tokens)
96
 
 
97
  model = AutoModelForCausalLM.from_pretrained(
98
  model_id,
99
  torch_dtype=torch.float16,
100
- device_map="auto",
101
  pad_token_id=tokenizer.pad_token_id
102
  )
 
 
 
 
 
103
  # Resize token embeddings to match new tokenizer
104
  model.resize_token_embeddings(len(tokenizer))
105
  return model, tokenizer
 
51
 
52
  class SmolLM2ForCausalLM(PreTrainedModel):
53
  config_class = SmolLM2Config
54
+ _no_split_modules = ["LlamaDecoderLayer"]
55
 
56
  def __init__(self, config):
57
  super().__init__(config)
 
95
  }
96
  tokenizer.add_special_tokens(special_tokens)
97
 
98
+ # Load model without device_map
99
  model = AutoModelForCausalLM.from_pretrained(
100
  model_id,
101
  torch_dtype=torch.float16,
 
102
  pad_token_id=tokenizer.pad_token_id
103
  )
104
+
105
+ # Move model to device manually
106
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
107
+ model = model.to(device)
108
+
109
  # Resize token embeddings to match new tokenizer
110
  model.resize_token_embeddings(len(tokenizer))
111
  return model, tokenizer