U-Cast param-count Modal job
Browse files- ucast_params.py +35 -0
ucast_params.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Non-blocked U-Cast claim: count parameters from the RELEASED checkpoint
|
| 2 |
+
(salv47/u-cast/ucast.ckpt) — weights confirmed present on HF, no ERA5 needed."""
|
| 3 |
+
import modal
|
| 4 |
+
|
| 5 |
+
image = (modal.Image.debian_slim(python_version="3.11")
|
| 6 |
+
.pip_install("torch", "huggingface_hub", "safetensors"))
|
| 7 |
+
app = modal.App("ucast-params", image=image)
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
@app.function(timeout=1200)
|
| 11 |
+
def count():
|
| 12 |
+
import torch, collections
|
| 13 |
+
from huggingface_hub import hf_hub_download
|
| 14 |
+
p = hf_hub_download("salv47/u-cast", "ucast.ckpt")
|
| 15 |
+
ckpt = torch.load(p, map_location="cpu", weights_only=False)
|
| 16 |
+
sd = ckpt.get("state_dict", ckpt)
|
| 17 |
+
# model weights only (exclude optimizer/EMA duplicates if any obvious prefix)
|
| 18 |
+
total = sum(v.numel() for v in sd.values() if hasattr(v, "numel"))
|
| 19 |
+
# try to separate EMA / model if both present
|
| 20 |
+
groups = collections.Counter()
|
| 21 |
+
for k in sd:
|
| 22 |
+
groups[k.split(".")[0]] += sd[k].numel() if hasattr(sd[k], "numel") else 0
|
| 23 |
+
return {"total_state_dict_params": int(total),
|
| 24 |
+
"millions": round(total / 1e6, 1),
|
| 25 |
+
"top_level_groups": dict(groups.most_common(8)),
|
| 26 |
+
"num_tensors": len(sd)}
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
@app.local_entrypoint()
|
| 30 |
+
def main():
|
| 31 |
+
import json
|
| 32 |
+
r = count.remote()
|
| 33 |
+
print(json.dumps(r, indent=2))
|
| 34 |
+
with open("ucast_params.json", "w") as f:
|
| 35 |
+
json.dump(r, f, indent=2)
|