Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
|
|
|
| 144 |
|
| 145 |
-
# β
HARD FAIL β never serve a random-weight model silently
|
| 146 |
if not ckpt_found:
|
| 147 |
-
raise RuntimeError("β NO CHECKPOINT
|
|
|
|
| 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())
|