Download url to the local cache, verify SHA-256, return the path.
Idempotent — when the file already exists in cache and verifies, it is returned without re-fetching. A cached file that fails verification is treated as corrupt and re-downloaded.
Parameters
urlstrRemote location of the checkpoint blob.
sha256strHex-encoded expected SHA-256 digest. Validated after download
and on every cache hit.
name(str, keyword - only)Short identifier (typically
"<model>/<tag>") used to compose
the cache subdirectory so different checkpoints never collide.Returns
pathlib.PathLocal path of the verified checkpoint.
Raises
RuntimeErrorIf the freshly downloaded file fails SHA-256 verification.
OSError / urllib.error.URLErrorFrom
urllib.request.urlopen when the network is unreachable
or the URL is invalid.Notes
Cache layout:
{cache_root}/{name}/{sha256[:8]}/{url-basename}
Download is atomic: bytes go to a temp file in the cache directory, the SHA is verified, then the temp file is renamed into place. On failure the temp file is removed; the cache directory is kept for the next attempt.