NiftyOracleAI commited on
Commit
d2398e2
Β·
verified Β·
1 Parent(s): 8546bd8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -127,12 +127,17 @@ print("⏳ Loading CodeSymb-1B model...")
127
  model = CodeSymb1B(vocab=VOCAB) # βœ… architecture built to match REAL vocab size
128
 
129
  ckpt_found = False
 
130
  for ckpt_name in ["checkpoints/sft_latest.pt",
131
  "checkpoints/latest.pt",
132
  "checkpoints/sft_chat_latest.pt"]:
133
  try:
134
  ckpt_path = hf_hub_download(REPO_ID, ckpt_name, token=HF_TOKEN or None)
135
- state = torch.load(ckpt_path, map_location="cpu", mmap=True)
 
 
 
 
136
  model_state = state.get("model", state)
137
  model.load_state_dict(model_state, strict=False)
138
  step = state.get("step", 0)
@@ -140,11 +145,12 @@ for ckpt_name in ["checkpoints/sft_latest.pt",
140
  ckpt_found = True
141
  break
142
  except Exception as e:
143
- print(f" Not found: {ckpt_name}")
 
144
 
145
- # βœ… HARD FAIL β€” never serve a random-weight model silently
146
  if not ckpt_found:
147
- raise RuntimeError("❌ NO CHECKPOINT FOUND on HF! Fix repo before deploying!")
 
148
 
149
  model.eval()
150
  n_params = sum(p.numel() for p in model.parameters())
 
127
  model = CodeSymb1B(vocab=VOCAB) # βœ… architecture built to match REAL vocab size
128
 
129
  ckpt_found = False
130
+ last_err = None
131
  for ckpt_name in ["checkpoints/sft_latest.pt",
132
  "checkpoints/latest.pt",
133
  "checkpoints/sft_chat_latest.pt"]:
134
  try:
135
  ckpt_path = hf_hub_download(REPO_ID, ckpt_name, token=HF_TOKEN or None)
136
+ print(f"⬇️ Downloaded {ckpt_name} β€” loading weights...")
137
+ try:
138
+ state = torch.load(ckpt_path, map_location="cpu") # βœ… NO mmap
139
+ except Exception:
140
+ state = torch.load(ckpt_path, map_location="cpu", weights_only=False)
141
  model_state = state.get("model", state)
142
  model.load_state_dict(model_state, strict=False)
143
  step = state.get("step", 0)
 
145
  ckpt_found = True
146
  break
147
  except Exception as e:
148
+ last_err = e
149
+ print(f" ⚠️ {ckpt_name} failed: {type(e).__name__}: {e}") # βœ… show REAL error
150
 
 
151
  if not ckpt_found:
152
+ raise RuntimeError(f"❌ NO CHECKPOINT LOADED! Last error: {last_err}")
153
+
154
 
155
  model.eval()
156
  n_params = sum(p.numel() for p in model.parameters())