"""U-Cast (#10467) rescue: run the REAL ERA5 forecasting benchmark on Modal. Uses the paper's standalone inference script with the released checkpoint, streams ERA5 from public WeatherBench2 GCS, computes RMSE + CRPS (--score). This targets U-Cast's actual performance claim, not just its param count. """ import modal REPO = "u-cast" image = (modal.Image.debian_slim(python_version="3.11") .pip_install("torch", "xarray", "netCDF4", "zarr<3", "einops", "tqdm", "pyyaml", "huggingface_hub", "gcsfs", "numpy", "scipy", "dask") .add_local_dir(REPO, f"/root/{REPO}", copy=True)) app = modal.App("ucast-inference", image=image) @app.function(gpu="A10G", timeout=3600) def run_infer(ic_date="2020-01-01", ensemble=5, horizon=10): import subprocess, os, re os.chdir(f"/root/{REPO}") cmd = [ "python", "run_inference_standalone.py", "--ckpt-path", "hf:salv47/u-cast/ucast.ckpt", "--data-dir", "gs://weatherbench2/datasets/era5", "--config-path", "configs/config_inference.yaml", "--ic-start-dates", ic_date, "--ensemble-size", str(ensemble), "--prediction-horizon", str(horizon), "--score", ] p = subprocess.run(cmd, capture_output=True, text=True, timeout=3200) out = p.stdout + "\n" + p.stderr # capture score lines (RMSE / CRPS) scores = [l for l in out.splitlines() if re.search(r"RMSE|CRPS|crps|rmse|score", l, re.I)] return {"returncode": p.returncode, "score_lines": scores[-40:], "tail": out.splitlines()[-40:]} @app.local_entrypoint() def main(): import json r = run_infer.remote() print(json.dumps(r, indent=2)) with open("ucast_inference_results.json", "w") as f: json.dump(r, f, indent=2)