p-e-w/heretic · critical · RuntimeError

Could not fetch uploaded model hashes.

Error message

Could not fetch uploaded model hashes.

What it means

upload_reproduce_folder fetches the uploaded model's file metadata (including LFS hashes) from the Hugging Face Hub via api.model_info. If the response has no file siblings at all, it cannot compute the model hash comparison needed for the reproduction record and raises this RuntimeError.

Source

Thrown at src/heretic/utils.py:707

    # Copy Optuna study journal.
    checkpoint_file = Path(checkpoint_path)
    if checkpoint_file.exists():
        (reproduce_dir / checkpoint_file.name).write_bytes(checkpoint_file.read_bytes())


def upload_reproduce_folder(
    repo_id: str,
    settings: Settings,
    token: str,
    checkpoint_path: str | Path,
    trial: Trial | FrozenTrial,
    include_system_information: bool,
):
    api = huggingface_hub.HfApi()
    info = api.model_info(repo_id=repo_id, files_metadata=True, token=token)

    if not info.siblings:
        raise RuntimeError("Could not fetch uploaded model hashes.")

    # For weights, we only care about safetensors.
    weight_extensions = (".safetensors",)

    uploaded_model_hashes = {}

    for file in info.siblings:
        if file.rfilename.endswith(weight_extensions):
            sha256 = getattr(file, "lfs", {}).get("sha256")
            if not sha256:
                raise RuntimeError("Could not fetch uploaded model hashes.")
            uploaded_model_hashes[file.rfilename] = sha256

    with tempfile.TemporaryDirectory() as tmpdir:
        tmp_path = Path(tmpdir)
        create_reproduce_folder(
            tmp_path,
            settings,

View on GitHub (pinned to bedb94ef11)

Solutions

  1. Verify repo_id and that the model upload completed successfully before calling upload_reproduce_folder.
  2. Pass a valid HF token with read access to the repo (token parameter or logged-in account).
  3. Re-run the upload; check the repo's Files tab on the Hub actually contains safetensors weights.

Example fix

// before
api.upload_file(...)  # upload that silently failed
upload_reproduce_folder(...)
// after
api.upload_large_folder(repo_id=repo_id, folder_path=..., repo_type="model")
info = huggingface_hub.HfApi().model_info(repo_id, files_metadata=True, token=token)
assert info.siblings, "upload produced no files"
upload_reproduce_folder(...)
Defensive patterns

Strategy: try-catch

Validate before calling

api = huggingface_hub.HfApi(token=token)
info = api.model_info(repo_id=repo_id, files_metadata=True, token=token)
if not info.siblings:
    raise RuntimeError(f"Repo {repo_id} has no visible files; check upload/token")

Type guard

def model_files_are_listable(info) -> bool:
    return bool(info and info.siblings)

Try / catch

try:
    upload_reproduce_folder(...)
except RuntimeError as e:
    if str(e) == "Could not fetch uploaded model hashes.":
        print("Verify repo_id, token permissions, and that the upload completed")
    else:
        raise

Prevention

When it happens

Trigger: api.model_info returns info with an empty/None siblings list — e.g. the repo exists but has no visible files, wrong repo_id, or insufficient token permissions to list files.

Common situations: Typos in repo_id, a private repo accessed with an expired or unauthorized token, uploading to a repo that failed to receive files, or Hub API glitches.

Related errors


AI-assisted analysis of p-e-w/heretic@bedb94ef11 (2026-08-29). Data as JSON: /api/errors/3a497ff3e85e3ce8. Report an issue: GitHub.