Repository navigation
Conversation
f9df960 to
456719b
Compare
lfengad
left a comment
There was a problem hiding this comment.
Could you confirm an online cold-cache download through CheckpointDirHf.download() in the supported processor runtime, with its normal Python environment and staged hf_cli configuration? On a cache miss the new code imports huggingface_hub and resolves metadata in the calling interpreter before invoking the locked CLI. Previously the CLI environment handled that lookup. This matters for callers that use the HF class directly. A test or CI job that exercises this path with an empty cache, together with the caller-side SDK version, would settle my compatibility question before approval.
lfengad
left a comment
There was a problem hiding this comment.
I checked the dependency lock and the integration tests after my earlier question. The caller environment pins huggingface-hub 0.36.2. The staged test exercises caller-side metadata lookup followed by a real CLI transfer of a missing weights file, and the SDK fallback test downloads a previously uncached revision against the mock Hub. That addresses my compatibility question for the standard locked runtime. No additional run is needed for this review.
2ad6249 to
32947fb
Compare
…and verify inventory sizes Resolves cached Hugging Face checkpoints in-process without requiring uv at run time, with cache/symlink validation and online fallback, and preserves expected file sizes from trees/<commit_hash>.json so both offline resolution and pinned-revision online cache shortcuts reject truncated files and mixed partial snapshots repair in a single online download. Signed-off-by: Kane <153349620+kane-vln@users.noreply.github.com>
32947fb to
0f4e388
Compare
Summary
Fixes #416 (related: #417).
Previously,
CheckpointFileHf._downloadandCheckpointDirHf._downloadincosmos_framework/utils/checkpoint_db.pyunconditionally spawneduv run ... hf download --format=json, even whenHF_HUB_OFFLINE=1was set and every required checkpoint (Cosmos3-Edge,Cosmos-Guardrail1, processor,Wan2.2_VAE.pth) was already present in the local Hugging Face cache. In runtime containers or Python environments withoutuvonPATH, inference failed immediately withFileNotFoundError: [Errno 2] No such file or directory: 'uv'.Key Changes
cosmos_framework/utils/checkpoint_db.py):HF_HUB_OFFLINE/TRANSFORMERS_OFFLINEfor offline routing, cache-root precedence (HF_HUB_CACHE>HUGGINGFACE_HUB_CACHE><HF_HOME>/hub><XDG_CACHE_HOME>/huggingface/hub>~/.cache/huggingface/hub), endpoint precedence (HUGGINGFACE_CO_STAGING/HF_ENDPOINT), and live token environment variables (HF_HUB_DISABLE_IMPLICIT_TOKEN/HF_TOKEN/HUGGING_FACE_HUB_TOKEN) per call without mutatingos.environ. Two upstreamhuggingface_hubSDK import-time limitations remain and are documented in the helper docstrings: ifhuggingface_hubwas initially imported withHF_HUB_OFFLINE=1, its in-process HTTP sessions keepOfflineAdaptermounted; and when no token environment variable is set,huggingface_hub.utils.get_token()falls back tohuggingface_hub.constants.HF_TOKEN_PATHas resolved at import time.huggingface_hubandrequestsinside helper functions socosmos_framework.utils.checkpoint_dbkeeps minimal top-level import overhead./,\, drive prefixes,./..traversal, invalidCACHEDIR.TAGentries, symlinked.locks/models--*/refs//trees//blobs//.no_exist//snapshots//snapshots/<sha>containers or entries, and file symlinks resolving outside the repository's cache (blobs/orsnapshots/<sha>/), validating existing cache write destinations (including negative-cache.no_existmarker paths) before online transfers execute while preserving legitimate relative Hugging Face blob pointer paths, ordinary existing.no_existmarker files, and trailing-slash directory patterns.trees/<commit_hash>.json(format_version == 1, relative file entries, integer sizes, non-emptyblob_id) and guards against zero-matchincludefilters.HF_HUB_OFFLINE=1/TRANSFORMERS_OFFLINE=1) completely in-process with zerouvor network calls, enforcingtrees/<sha>.jsoncompleteness when available and preserving legacy cache OR-filter,*.safetensors.index.jsonshard completeness, singleton literalinclude, and selected dangling/external symlink checks.CheckpointFileHf, validatedtrees/<sha>.json, or singleton literalinclude).uv-optional transfer fallback, & exact snapshot verification:HfApi.repo_info(..., files_metadata=False)/get_hf_file_metadatawith 40-hexX-Repo-Commitvalidation) from commit-pinned inventory listing (HfApi.list_repo_files(..., revision=commit_hash)) so partial caches (config.json-only) cannot pass on HTTP401or transient connection errors, and once a mutable ref resolves to a newer SHA, connectivity fallback only accepts provably complete snapshots of that resolved SHA rather than stale local refs.uvfrom the active Python environment (sys.executable/sys.prefixscripts dir ->uv.find_uv_bin()->PATH), uses a same-invocation startup marker immediately beforehuggingface_hub.cli.hf:mainsouvbootstrap failures fall back to in-processhuggingface_hub(snapshot_download/hf_hub_download) without retrying realhferrors, and verifies both pre-transfer cache destinations and post-transfer materialization at the exact expectedsnapshots/<commit_hash>path before updatingrefs/<revision>atomically.cosmos_framework/utils/checkpoint_db_test.py):[pytest.mark.L0, pytest.mark.CPU]unit and stagedhf_cliintegration tests isolated fromhuggingface_hubimport order and hostuvinstallations, including online pre-transfer symlink-destination and staged404 EntryNotFound.no_existregressions against both the real Hub SDK and the lockedhfCLI.Upstream Sync Note
cosmos_framework/utils/checkpoint_db.pyis mapped in.file_mapping.json(imaginaire/utils/checkpoint_db.py) and should be mirrored/coordinated with upstream sync ownership as appropriate.Verification
ruff check cosmos_framework/utils/checkpoint_db.py cosmos_framework/utils/checkpoint_db_test.pyruff format --check cosmos_framework/utils/checkpoint_db.py cosmos_framework/utils/checkpoint_db_test.pypyrefly check -c pyrefly.toml cosmos_framework/utils/checkpoint_db.py cosmos_framework/utils/checkpoint_db_test.py(pyrefly==0.55.0,0 errors)--noconftestCPU runner withuvpackage installed:27 passed(0 skipped)pytest cosmos_framework/utils/checkpoint_db_test.py tests/hf_cli_resources_test.py(29 passed,0 skippedwith stagedIMAGINAIRE_HF_CLI_ENVIRONMENT)pytest --skip-mapped-non-gpu-tests cosmos_framework/utils/checkpoint_db_test.py(27 passed)cosmos_framework/utils/checkpoint_db_test.py,tests/hf_cli_resources_test.py,cosmos_framework/utils/safe_unpickle_test.pyin both forward and reverse orders:51 passed)